Report stock usage and value, add material cost to profitability, document phase 5

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
2026-11-26 17:24:07 +02:00
co-authored by Claude Sonnet 5.5
parent 38b8075a9c
commit 3207d0064a
34 changed files with 1145 additions and 24 deletions
@@ -9,6 +9,7 @@ use App\Modules\Reports\Application\Contracts\ReportExpenses;
use App\Modules\Reports\Application\Contracts\ReportHours;
use App\Modules\Reports\Application\Contracts\ReportJobs;
use App\Modules\Reports\Application\Contracts\ReportRevenue;
use App\Modules\Reports\Application\Contracts\ReportStock;
use App\Modules\Reports\Application\DTOs\JobProfit;
use App\Modules\Reports\Application\DTOs\ProfitabilityReport;
use App\Modules\Reports\Application\DTOs\ServiceUnitProfit;
@@ -30,6 +31,7 @@ final readonly class ProfitabilityByJob
private ReportRevenue $revenue,
private ReportJobs $jobs,
private ReportCatalog $catalog,
private ReportStock $stock,
) {}
public function execute(ReportPeriod $period, bool $includeInternal = false): ProfitabilityReport
@@ -40,10 +42,11 @@ final readonly class ProfitabilityByJob
}
$expenseCosts = $this->expenses->costsByJob($period);
$materialCosts = $this->stock->materialCostsByJob($period);
$revenue = $this->revenue->byJob($period);
$hourlyCost = $this->catalog->internalHourlyCostCents();
$jobIds = array_values(array_unique([...array_keys($quarters), ...array_keys($expenseCosts), ...array_keys($revenue)]));
$jobIds = array_values(array_unique([...array_keys($quarters), ...array_keys($expenseCosts), ...array_keys($materialCosts), ...array_keys($revenue)]));
$jobs = $this->jobs->infoOf($jobIds);
$rows = [];
@@ -60,6 +63,7 @@ final readonly class ProfitabilityByJob
$billed->expenseCents ?? 0,
$expenseCosts[$job->id] ?? 0,
$hourlyCost,
$materialCosts[$job->id] ?? 0,
));
}