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,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Reports\Application\UseCases;
|
||||
|
||||
use App\Modules\Inventory\Application\DTOs\StockValueEntry;
|
||||
use App\Modules\Reports\Application\Contracts\ReportStock;
|
||||
use App\Modules\Reports\Application\DTOs\StockValueReportData;
|
||||
|
||||
/**
|
||||
* Stock value (Varaston arvo, spec 19.8): every item's balance and book
|
||||
* value at the end of a day, the total, and the items to order.
|
||||
*/
|
||||
final readonly class StockValueReport
|
||||
{
|
||||
public function __construct(private ReportStock $stock) {}
|
||||
|
||||
public function execute(string $day): StockValueReportData
|
||||
{
|
||||
$items = $this->stock->valueOn($day);
|
||||
|
||||
return new StockValueReportData(
|
||||
$items,
|
||||
array_sum(array_map(fn (StockValueEntry $item): int => $item->valueCents, $items)),
|
||||
array_values(array_filter($items, fn (StockValueEntry $item): bool => $item->isActive && $item->needsReorder())),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user