Management's reports (spec 13) get their own module that reads the other modules through ports. The first report sums hours by person in a period, narrowed by service unit or customer, with breakdowns, a chart and CSV. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
37 lines
1.3 KiB
PHP
37 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Modules\Reports\Infrastructure\Adapters;
|
|
|
|
use App\Modules\Jobs\Application\Contracts\CustomerJobQueries;
|
|
use App\Modules\Jobs\Application\DTOs\JobReportInfo;
|
|
use App\Modules\Jobs\Domain\Enums\PaymentBasis;
|
|
use App\Modules\Reports\Application\Contracts\ReportJobs;
|
|
use App\Modules\Reports\Application\DTOs\ReportJob;
|
|
|
|
/**
|
|
* Customer jobs for reports through the Jobs module. As in billing, a job
|
|
* without a payment basis is billed by its hours.
|
|
*/
|
|
class JobsForReports implements ReportJobs
|
|
{
|
|
public function __construct(private CustomerJobQueries $jobs) {}
|
|
|
|
public function infoOf(array $ids): array
|
|
{
|
|
return array_map(fn (JobReportInfo $job): ReportJob => new ReportJob(
|
|
$job->id,
|
|
$job->number,
|
|
$job->name,
|
|
$job->customerId,
|
|
$job->customerName,
|
|
$job->isInternal,
|
|
$job->status->value,
|
|
$job->paymentBasis?->value,
|
|
! $job->isInternal && $job->paymentBasis !== PaymentBasis::NotBillable,
|
|
! $job->isInternal && in_array($job->paymentBasis, [null, PaymentBasis::Hourly, PaymentBasis::PriceList], true),
|
|
$job->quotedAmountCents,
|
|
$job->serviceUnitIds,
|
|
), $this->jobs->reportInfoOf($ids));
|
|
}
|
|
}
|