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,46 @@
<?php
namespace App\Modules\Reports\Presentation\Csv;
use App\Modules\Inventory\Domain\ValueObjects\StockQuantity;
use App\Modules\Reports\Application\UseCases\StockUsageReport;
use Illuminate\Http\Request;
/**
* Stock usage as CSV: a row per item, quantities with a decimal comma and
* values in cents (VAT 0).
*/
class StockUsageCsv implements ReportCsv
{
public function __construct(private StockUsageReport $report) {}
public function fileName(Request $request): string
{
$period = CsvFilters::period($request);
return __('reports.stock_usage.file').'-'.$period->from.'-'.$period->to;
}
public function headers(): array
{
return array_values(__('reports.stock_usage.csv'));
}
public function rows(Request $request): iterable
{
foreach ($this->report->execute(CsvFilters::period($request))->items as $row) {
yield [
$row->label,
(string) $row->group,
__('inventory.units.'.$row->unit),
StockQuantity::inputValue($row->usedMilli),
$row->usedCents,
StockQuantity::inputValue($row->writtenOffMilli),
$row->writtenOffCents,
StockQuantity::inputValue($row->adjustedMilli),
$row->adjustedCents,
$row->totalCents(),
];
}
}
}