41 lines
1.2 KiB
PHP
41 lines
1.2 KiB
PHP
<?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') : '',
|
|
];
|
|
}
|
|
}
|
|
}
|