Add the profitability report and the internal hourly cost

Profitability by job and service unit from a period's hours, expenses
and the created billing materials of its months. Hours are costed at one
internal hourly cost, set on the price list maintenance page; a job of
several service units is shared evenly between them.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
2026-11-25 08:50:30 +02:00
co-authored by Claude Sonnet 5.5
parent 8079c272d2
commit 8aa62c8e02
31 changed files with 1110 additions and 1 deletions
@@ -0,0 +1,18 @@
<?php
declare(strict_types=1);
namespace App\Modules\Reports\Application\DTOs;
use App\Modules\Reports\Domain\ValueObjects\Profit;
/**
* A job's profitability in the period.
*/
final readonly class JobProfit
{
public function __construct(
public ReportJob $job,
public Profit $profit,
) {}
}
@@ -0,0 +1,19 @@
<?php
declare(strict_types=1);
namespace App\Modules\Reports\Application\DTOs;
/**
* A job's billed amounts without VAT in cents: for the work (hours, fixed
* price, monthly fees) and for expenses, and the billed hours in quarters.
*/
final readonly class JobRevenue
{
public function __construct(
public int $jobId,
public int $workCents,
public int $expenseCents,
public int $billedQuarters,
) {}
}
@@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
namespace App\Modules\Reports\Application\DTOs;
use App\Modules\Reports\Domain\ValueObjects\Profit;
/**
* Profitability by job (by job number) and by service unit (catalog
* order), the total, and the internal hourly cost used (null when not set,
* and then there are no hour costs or margins).
*/
final readonly class ProfitabilityReport
{
/**
* @param list<JobProfit> $jobs
* @param list<ServiceUnitProfit> $serviceUnits
*/
public function __construct(
public array $jobs,
public array $serviceUnits,
public Profit $total,
public ?int $hourlyCostCents,
) {}
}
@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
namespace App\Modules\Reports\Application\DTOs;
use App\Modules\Reports\Domain\ValueObjects\Profit;
/**
* A service unit's profitability in the period: its jobs' figures, a job
* of several service units shared evenly between them.
*/
final readonly class ServiceUnitProfit
{
public function __construct(
public int $serviceUnitId,
public string $name,
public int $jobCount,
public Profit $profit,
) {}
}