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:
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Reports\Infrastructure\Adapters;
|
||||
|
||||
use App\Modules\Inventory\Application\Contracts\StockReportQueries;
|
||||
use App\Modules\Machines\Application\Contracts\MachineQueries;
|
||||
use App\Modules\Reports\Application\Contracts\ReportStock;
|
||||
use App\Modules\Reports\Domain\ValueObjects\ReportPeriod;
|
||||
|
||||
/**
|
||||
* Stock for reports through the Inventory and Machines modules.
|
||||
*/
|
||||
class StockForReports implements ReportStock
|
||||
{
|
||||
public function __construct(
|
||||
private StockReportQueries $stock,
|
||||
private MachineQueries $machines,
|
||||
) {}
|
||||
|
||||
public function usage(ReportPeriod $period): array
|
||||
{
|
||||
return $this->stock->usage($period->from, $period->to);
|
||||
}
|
||||
|
||||
public function valueOn(string $day): array
|
||||
{
|
||||
return $this->stock->valueOn($day);
|
||||
}
|
||||
|
||||
public function materialCostsByJob(ReportPeriod $period): array
|
||||
{
|
||||
return $this->stock->materialCostsByJob($period->from, $period->to);
|
||||
}
|
||||
|
||||
public function machineNames(array $ids): array
|
||||
{
|
||||
$names = [];
|
||||
|
||||
foreach ($this->machines->machines(includeInactive: true) as $machine) {
|
||||
if (in_array($machine->id, $ids, true)) {
|
||||
$names[$machine->id] = $machine->name;
|
||||
}
|
||||
}
|
||||
|
||||
return $names;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user