Files
Toiminnanohjaus/app/Modules/Reports/Presentation/Livewire/⚡reimbursements.blade.php
T
petriandClaude Sonnet 5.5 2de3733a3f Add browser accessibility tests for the reports
Fixes found by axe: the chart axis captions are darker and larger, the
period heading keeps its heading role with the live region inside it,
and scrollable tables are focusable regions named by their table.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-25 08:56:33 +02:00

126 lines
6.3 KiB
PHP

<?php
use App\Modules\Reports\Application\DTOs\ReimbursementEntry;
use App\Modules\Reports\Application\DTOs\ReimbursementReport;
use App\Modules\Reports\Application\UseCases\ReimbursementsReport;
use App\Modules\Reports\Presentation\Livewire\Concerns\ReportPage;
use App\Modules\Reports\Presentation\ReportFormat;
use App\Modules\Users\Application\Contracts\Clock;
use Livewire\Attributes\Computed;
use Livewire\Component;
/**
* Expense reimbursements (spec 10, 13): the expenses employees paid
* themselves in a period, by person, to print or download for payroll.
* Paying them is outside this system.
*/
new class extends Component
{
use ReportPage;
public function mount(Clock $clock): void
{
$this->startPeriod($clock, 'previous_month');
}
#[Computed]
public function report(): ?ReimbursementReport
{
$period = $this->period();
return $period === null ? null : app(ReimbursementsReport::class)->execute($period);
}
public function updated(): void
{
$this->authorize('reports.view');
unset($this->report);
}
public function kilometers(?int $tenths): string
{
return $tenths === null ? '' : ReportFormat::kilometers($tenths);
}
public function what(ReimbursementEntry $expense): string
{
return ReportFormat::expenseText($expense);
}
public function render(): mixed
{
return $this->view()->title(__('reports.reimbursements.title'));
}
};
?>
<div class="mx-auto max-w-6xl space-y-6 p-4 sm:p-6">
<div class="space-y-2">
<h1 class="text-2xl font-semibold">{{ __('reports.reimbursements.title') }}</h1>
<p class="max-w-3xl text-sm">{{ __('reports.reimbursements.intro') }}</p>
</div>
<x-reports.period-filter class="print:hidden" :presets="$this->periodPresets()" :valid="$this->period !== null" />
@php($report = $this->report)
@if ($report !== null)
<div class="flex flex-wrap items-center justify-between gap-3">
<h2 class="text-xl font-semibold"><span role="status" aria-live="polite">{{ $this->periodLabel() }}</span></h2>
<div class="flex flex-wrap gap-2 print:hidden">
<x-button x-on:click="window.print()" subtle color="black" icon="printer" :text="__('reports.reimbursements.print')" />
<x-button :href="$this->csvUrl('reimbursements')" subtle color="black" icon="arrow-down-tray" :text="__('reports.download_csv')" />
</div>
</div>
@if ($report->people === [])
<p>{{ __('reports.reimbursements.none') }}</p>
@else
<p class="font-semibold">
{{ __('reports.reimbursements.grand_total', ['amount' => $this->money($report->costCents), 'km' => $this->kilometers($report->kilometerTenths)]) }}
</p>
@foreach ($report->people as $person)
<section wire:key="person-{{ $person->userId }}" aria-labelledby="person-{{ $person->userId }}" class="space-y-2 break-inside-avoid">
<h3 id="person-{{ $person->userId }}" class="text-lg font-semibold">{{ $person->name }}</h3>
<div class="overflow-x-auto rounded focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600" tabindex="0" role="region" aria-label="{{ __('reports.reimbursements.table', ['name' => $person->name, 'period' => $this->periodLabel()]) }}">
<table class="w-full text-sm">
<caption class="sr-only">{{ __('reports.reimbursements.table', ['name' => $person->name, 'period' => $this->periodLabel()]) }}</caption>
<thead>
<tr class="border-b border-zinc-300 text-left dark:border-zinc-600">
<th scope="col" class="py-2 pr-3">{{ __('reports.reimbursements.day') }}</th>
<th scope="col" class="py-2 pr-3">{{ __('reports.reimbursements.category') }}</th>
<th scope="col" class="py-2 pr-3">{{ __('reports.reimbursements.what') }}</th>
<th scope="col" class="py-2 pr-3">{{ __('reports.reimbursements.job') }}</th>
<th scope="col" class="py-2 pr-3 text-right">{{ __('reports.reimbursements.km') }}</th>
<th scope="col" class="py-2 text-right">{{ __('reports.reimbursements.amount') }}</th>
</tr>
</thead>
<tbody class="divide-y divide-zinc-200 dark:divide-zinc-700">
@foreach ($person->lines as $line)
<tr class="align-top">
<td class="py-2 pr-3 whitespace-nowrap">{{ $this->dateLabel($line->expense->spentOn) }}</td>
<td class="py-2 pr-3">{{ __('expenses.categories.'.$line->expense->category) }}</td>
<td class="py-2 pr-3">{{ $this->what($line->expense) }}</td>
<td class="py-2 pr-3">{{ $line->jobNumber }} {{ $line->jobName }}</td>
<td class="py-2 pr-3 text-right whitespace-nowrap">{{ $this->kilometers($line->expense->kilometerTenths) }}</td>
<td class="py-2 text-right whitespace-nowrap">{{ $this->money($line->expense->costCents) }}</td>
</tr>
@endforeach
</tbody>
<tfoot>
<tr class="border-t-2 border-zinc-400 font-semibold dark:border-zinc-500">
<th scope="row" colspan="4" class="py-2 pr-3 text-left">{{ __('reports.reimbursements.person_total', ['name' => $person->name]) }}</th>
<td class="py-2 pr-3 text-right whitespace-nowrap">{{ $this->kilometers($person->kilometerTenths) }}</td>
<td class="py-2 text-right whitespace-nowrap">{{ $this->money($person->costCents) }}</td>
</tr>
</tfoot>
</table>
</div>
</section>
@endforeach
@endif
@endif
</div>