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,40 @@
<?php
namespace App\Modules\Reports\Presentation\Csv;
use App\Modules\Inventory\Domain\ValueObjects\StockQuantity;
use App\Modules\Reports\Application\UseCases\StockValueReport;
use Illuminate\Http\Request;
/**
* Stock value of a day as CSV: a row per item, the balance with a decimal
* comma and the value in cents (VAT 0).
*/
class StockValueCsv implements ReportCsv
{
public function __construct(private StockValueReport $report) {}
public function fileName(Request $request): string
{
return __('reports.stock_value.file').'-'.CsvFilters::day($request, 'paiva');
}
public function headers(): array
{
return array_values(__('reports.stock_value.csv'));
}
public function rows(Request $request): iterable
{
foreach ($this->report->execute(CsvFilters::day($request, 'paiva'))->items as $item) {
yield [
$item->itemName,
$item->groupName,
__('inventory.units.'.$item->unit),
StockQuantity::inputValue($item->balanceMilli),
$item->valueCents,
$item->needsReorder() ? __('inventory.status.reorder') : '',
];
}
}
}