CluPilotCloud/resources/views/livewire/invoices.blade.php

63 lines
4.2 KiB
PHP

<div class="space-y-6">
<div class="animate-rise">
<h1 class="text-2xl font-bold tracking-tight text-ink">{{ __('invoices.title') }}</h1>
<p class="mt-1 text-sm text-muted">{{ __('invoices.subtitle') }}</p>
</div>
<div class="overflow-hidden rounded-lg border border-line bg-surface shadow-xs animate-rise [animation-delay:60ms]">
@if ($invoices->isEmpty())
<p class="p-8 text-center text-sm text-muted">{{ __('invoices.empty') }}</p>
@else
<div class="overflow-x-auto">
<table class="w-full text-sm">
<thead>
<tr class="border-b border-line bg-surface-2 text-left text-xs font-semibold text-muted">
<th class="px-4 py-3 font-semibold">{{ __('invoices.col_no') }}</th>
<th class="px-4 py-3 font-semibold">{{ __('invoices.col_date') }}</th>
<th class="px-4 py-3 text-right font-semibold">{{ __('invoices.col_net') }}</th>
<th class="px-4 py-3 text-right font-semibold">{{ __('invoices.col_gross') }}</th>
<th class="px-4 py-3"></th>
</tr>
</thead>
<tbody>
@foreach ($invoices as $invoice)
<tr wire:key="inv-{{ $invoice->uuid }}" class="border-b border-line last:border-0 hover:bg-surface-hover">
<td class="px-4 py-3">
<span class="font-mono text-xs font-semibold text-ink">{{ $invoice->number }}</span>
{{-- A cancellation says so on the row. Two documents
with opposite figures and nothing to tell them
apart reads as a double charge. --}}
@if ($invoice->cancels_invoice_id !== null)
<x-ui.badge status="warning" class="ml-2">{{ __('invoices.storno') }}</x-ui.badge>
@endif
</td>
{{-- ->local() even for a date (R19): stored in UTC, and
around midnight the wall clock is already tomorrow. --}}
<td class="px-4 py-3 text-muted">{{ $invoice->issued_on?->local()->format('d.m.Y') }}</td>
<td class="px-4 py-3 text-right font-mono tabular-nums text-muted">{{ \App\Services\Billing\InvoiceMath::money($invoice->net_cents) }}</td>
<td class="px-4 py-3 text-right font-mono font-semibold tabular-nums text-ink">{{ \App\Services\Billing\InvoiceMath::money($invoice->gross_cents) }} {{ $invoice->currency }}</td>
<td class="px-4 py-3 text-right">
{{-- A link, not a Livewire action: a PDF is a file
download, and routing one through a component
round-trip only adds a way for it to fail. The
route resolves the document against the
signed-in customer itself this link being
here is not what makes it theirs. --}}
<a href="{{ route('invoices.pdf', $invoice->uuid) }}"
class="inline-flex items-center gap-1.5 rounded-md border border-line px-2.5 py-1.5 text-xs font-medium text-body hover:border-accent-border hover:text-accent-text">
<x-ui.icon name="download" class="size-4" />{{ __('invoices.pdf') }}
</a>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@if ($invoices->hasPages())
<div class="border-t border-line p-4">{{ $invoices->links() }}</div>
@endif
@endif
</div>
</div>