Quick sales of a period by cash day, product, seller and VAT rate, with credits, open cash days flagged, a chart by day or month and CSV. VAT is taken out of each day's total of a rate, as on the cash day balance. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
41 lines
1.0 KiB
PHP
41 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Modules\Reports\Presentation\Csv;
|
|
|
|
use App\Modules\Reports\Application\UseCases\QuickSalesReport;
|
|
use Illuminate\Http\Request;
|
|
|
|
/**
|
|
* Quick sales as CSV: a row per cash day, amounts with VAT in cents.
|
|
*/
|
|
class SalesCsv implements ReportCsv
|
|
{
|
|
public function __construct(private QuickSalesReport $report) {}
|
|
|
|
public function fileName(Request $request): string
|
|
{
|
|
$period = CsvFilters::period($request);
|
|
|
|
return __('reports.sales.file').'-'.$period->from.'-'.$period->to;
|
|
}
|
|
|
|
public function headers(): array
|
|
{
|
|
return array_values(__('reports.sales.csv'));
|
|
}
|
|
|
|
public function rows(Request $request): iterable
|
|
{
|
|
foreach ($this->report->execute(CsvFilters::period($request))->days as $day) {
|
|
yield [
|
|
$day['day'],
|
|
$day['count'],
|
|
$day['cashCents'],
|
|
$day['cardCents'],
|
|
$day['totalCents'],
|
|
__($day['isClosed'] ? 'reports.yes' : 'reports.no'),
|
|
];
|
|
}
|
|
}
|
|
}
|