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]>
28 lines
993 B
PHP
28 lines
993 B
PHP
<?php
|
|
|
|
namespace App\Modules\Reports\Infrastructure\Adapters;
|
|
|
|
use App\Modules\Billing\Application\Contracts\BilledRevenueQueries;
|
|
use App\Modules\Billing\Application\DTOs\BilledJobRevenue;
|
|
use App\Modules\Reports\Application\Contracts\ReportRevenue;
|
|
use App\Modules\Reports\Application\DTOs\JobRevenue;
|
|
use App\Modules\Reports\Domain\ValueObjects\ReportPeriod;
|
|
|
|
/**
|
|
* Billed amounts for reports through the Billing module.
|
|
*/
|
|
class RevenueForReports implements ReportRevenue
|
|
{
|
|
public function __construct(private BilledRevenueQueries $queries) {}
|
|
|
|
public function byJob(ReportPeriod $period): array
|
|
{
|
|
return array_map(fn (BilledJobRevenue $revenue): JobRevenue => new JobRevenue(
|
|
$revenue->jobId,
|
|
$revenue->hoursNetCents + $revenue->fixedPriceNetCents + $revenue->monthlyFeeNetCents,
|
|
$revenue->expenseNetCents,
|
|
$revenue->billedQuarters,
|
|
), $this->queries->byJob($period->fromMonth(), $period->toMonth()));
|
|
}
|
|
}
|