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
@@ -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())),
);
}
}