Add the expense reimbursements report

The expenses employees paid themselves in a period, by person with
kilometres and amounts, printable and as CSV for payroll.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
2026-11-25 08:46:22 +02:00
co-authored by Claude Sonnet 5.5
parent 568871c9dc
commit 8079c272d2
21 changed files with 639 additions and 1 deletions
@@ -0,0 +1,46 @@
<?php
namespace App\Modules\Reports\Presentation\Csv;
use App\Modules\Reports\Application\UseCases\ReimbursementsReport;
use App\Modules\Reports\Presentation\ReportFormat;
use Illuminate\Http\Request;
/**
* Expense reimbursements as CSV: a row per expense, kilometres with a
* decimal comma and the cost in cents (VAT 0).
*/
class ReimbursementsCsv implements ReportCsv
{
public function __construct(private ReimbursementsReport $report) {}
public function fileName(Request $request): string
{
$period = CsvFilters::period($request);
return __('reports.reimbursements.file').'-'.$period->from.'-'.$period->to;
}
public function headers(): array
{
return array_values(__('reports.reimbursements.csv'));
}
public function rows(Request $request): iterable
{
foreach ($this->report->execute(CsvFilters::period($request))->people as $person) {
foreach ($person->lines as $line) {
yield [
$person->name,
$line->expense->spentOn,
__('expenses.categories.'.$line->expense->category),
ReportFormat::expenseText($line->expense),
$line->jobNumber,
$line->jobName,
$line->expense->kilometerTenths === null ? '' : ReportFormat::csvKilometers($line->expense->kilometerTenths),
$line->expense->costCents,
];
}
}
}
}