Add Reports module with the hours by person report

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]>
This commit is contained in:
2026-11-25 08:39:19 +02:00
co-authored by Claude Sonnet 5.5
parent f906f9a43f
commit 64f1e7c54a
45 changed files with 1828 additions and 3 deletions
@@ -0,0 +1,17 @@
<?php
declare(strict_types=1);
namespace App\Modules\Reports\Application\DTOs;
/**
* A part of a person's hours, e.g. one work type or one job, in quarter hours.
*/
final readonly class HoursBreakdown
{
public function __construct(
public string $label,
public int $quarters,
public ?int $jobId = null,
) {}
}
@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
namespace App\Modules\Reports\Application\DTOs;
/**
* A user's hours on a job's work type in quarter hours: all, those waiting
* for approval and those billed.
*/
final readonly class HoursEntry
{
public function __construct(
public int $userId,
public int $jobId,
public int $workTypeId,
public int $quarters,
public int $unapprovedQuarters,
public int $billedQuarters,
) {}
}
@@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
namespace App\Modules\Reports\Application\DTOs;
/**
* One row of the hours report: a person's hours on a job's work type, in
* quarter hours.
*/
final readonly class HoursLine
{
public function __construct(
public int $userId,
public string $userName,
public int $jobId,
public string $jobNumber,
public string $jobName,
public string $customerName,
public bool $isInternal,
public string $workTypeName,
public string $serviceUnitName,
public int $quarters,
public int $unapprovedQuarters,
public int $billedQuarters,
) {}
}
@@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
namespace App\Modules\Reports\Application\DTOs;
/**
* Hours by person: a row per person by name, their total, the rows behind
* them, and the customers and service units the hours can be narrowed to.
*/
final readonly class HoursReport
{
/**
* @param list<PersonHours> $people
* @param list<HoursLine> $lines
* @param array<int, string> $customers
* @param array<int, string> $serviceUnits
*/
public function __construct(
public array $people,
public PersonHours $total,
public array $lines,
public array $customers,
public array $serviceUnits,
) {}
}
@@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace App\Modules\Reports\Application\DTOs;
/**
* A person's hours in the period in quarter hours: in all, on customers'
* and on internal jobs, waiting for approval and billed, broken down by
* work type and by job (most hours first).
*/
final readonly class PersonHours
{
/**
* @param list<HoursBreakdown> $byWorkType
* @param list<HoursBreakdown> $byJob
*/
public function __construct(
public int $userId,
public string $name,
public int $quarters,
public int $customerQuarters,
public int $internalQuarters,
public int $unapprovedQuarters,
public int $billedQuarters,
public array $byWorkType = [],
public array $byJob = [],
) {}
}
@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
namespace App\Modules\Reports\Application\DTOs;
/**
* A customer job in a report. Status and payment basis are the Jobs
* module's keys (e.g. "done", "hourly"). A job bills its hours when its
* hours are priced by the hourly rates (hourly or price list work), and is
* billable when it is a customer's job that is billed at all.
*/
final readonly class ReportJob
{
/**
* @param list<int> $serviceUnitIds
*/
public function __construct(
public int $id,
public string $number,
public string $name,
public int $customerId,
public string $customerName,
public bool $isInternal,
public string $status,
public ?string $paymentBasis,
public bool $isBillable,
public bool $billsHours,
public ?int $quotedAmountCents,
public array $serviceUnitIds,
) {}
}
@@ -0,0 +1,19 @@
<?php
declare(strict_types=1);
namespace App\Modules\Reports\Application\DTOs;
/**
* A work type with its service unit and hourly rate in cents (VAT 0).
*/
final readonly class ReportWorkType
{
public function __construct(
public int $id,
public string $name,
public int $serviceUnitId,
public string $serviceUnitName,
public ?int $rateCents,
) {}
}
@@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
namespace App\Modules\Reports\Application\DTOs;
/**
* A job's unbilled hours on a work type in quarter hours, with the first
* day worked (Y-m-d).
*/
final readonly class UnbilledEntry
{
public function __construct(
public int $jobId,
public int $workTypeId,
public int $approvedQuarters,
public int $unapprovedQuarters,
public string $oldestDay,
) {}
}