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]>
36 lines
1.3 KiB
PHP
36 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Modules\Reports\Infrastructure\Adapters;
|
|
|
|
use App\Modules\Reports\Application\Contracts\ReportHours;
|
|
use App\Modules\Reports\Application\DTOs\HoursEntry;
|
|
use App\Modules\Reports\Application\DTOs\UnbilledEntry;
|
|
use App\Modules\Reports\Domain\ValueObjects\ReportPeriod;
|
|
use App\Modules\TimeTracking\Application\Contracts\TimeReportQueries;
|
|
use App\Modules\TimeTracking\Application\DTOs\ReportedHours;
|
|
use App\Modules\TimeTracking\Application\DTOs\UnbilledHours;
|
|
|
|
/**
|
|
* Hours for reports through the TimeTracking module.
|
|
*/
|
|
class HoursForReports implements ReportHours
|
|
{
|
|
public function __construct(private TimeReportQueries $queries) {}
|
|
|
|
public function between(ReportPeriod $period): array
|
|
{
|
|
return array_map(
|
|
fn (ReportedHours $hours): HoursEntry => new HoursEntry($hours->userId, $hours->jobId, $hours->workTypeId, $hours->quarters, $hours->unapprovedQuarters, $hours->billedQuarters),
|
|
$this->queries->hoursBetween($period->from, $period->to),
|
|
);
|
|
}
|
|
|
|
public function unbilledUntil(string $day): array
|
|
{
|
|
return array_map(
|
|
fn (UnbilledHours $hours): UnbilledEntry => new UnbilledEntry($hours->jobId, $hours->workTypeId, $hours->approvedQuarters, $hours->unapprovedQuarters, $hours->oldestDay),
|
|
$this->queries->unbilledUntil($day),
|
|
);
|
|
}
|
|
}
|