@if(!empty($company['logo'])) {{-- A filesystem path, resolved and checked by the service: the PDF renderer does not fetch URLs. --}} @endif
{{ $company['name'] }}
@if($company['address'])
{{ $company['address'] }}
@endif @if(!empty($company['legal_name']) && $company['legal_name'] !== $company['name']) {{-- The registered title under the brand: the brand is what the customer recognises, the title is who invoiced them. --}}
{{ $company['legal_name'] }}
@endif @if($company['city'])
{{ trim(($company['postcode'] ?? '').' '.$company['city']) }} {{ $company['country'] }}
@endif @if(!empty($company['tax_office']))
{{ __('pdf.tax_office') }}: {{ $company['tax_office'] }}
@endif @if(!empty($company['mersis']))
{{ __('pdf.registry_no') }}: {{ $company['mersis'] }}
@endif @if($company['phone'])
{{ $company['phone'] }}
@endif @if($company['email'])
{{ $company['email'] }}
@endif @if($company['tax_id'])
{{ __('pdf.tax_id') }}: {{ $company['tax_id'] }}
@endif
{{ __('pdf.invoice') }}
#{{ $invoice->invoice_num ?? $invoice->id }}
@if($invoice->sourceInvoice)
{{ __('admin.invoices.source_proforma') }}: {{ $invoice->sourceInvoice->invoice_num }}
@endif
@php $statusClass = match(strtolower($invoice->status)) { 'paid' => 'status-paid', 'overdue' => 'status-overdue', 'cancelled', 'canceled' => 'status-cancelled', default => 'status-unpaid', }; @endphp {{ invoice_status_label($invoice->status) }}

{{ __('pdf.bill_to') }}

@if($invoice->client) {{-- Buyer as it stood when the invoice was issued (issue #7). For VAT the address and tax id on the document must be the ones that applied on the invoice date, so these read the snapshot; invoices issued before snapshots existed fall back to the live client record. --}} {{ $invoice->buyer('first_name') }} {{ $invoice->buyer('last_name') }}
@if($invoice->buyer('company_name')){{ $invoice->buyer('company_name') }}
@endif @if($invoice->buyer('address1')){{ $invoice->buyer('address1') }}
@endif @if($invoice->buyer('address2')){{ $invoice->buyer('address2') }}
@endif @if($invoice->buyer('city')){{ $invoice->buyer('city') }}, {{ $invoice->buyer('state') }} {{ $invoice->buyer('postcode') }}
@endif @if($invoice->buyer('country')){{ $invoice->buyer('country') }}
@endif @if($invoice->buyer('tax_id')){{ __('pdf.tax_id') ?? 'Tax ID' }}: {{ $invoice->buyer('tax_id') }}
@endif {{-- Custom fields marked "show on invoice" (e.g. NIP), as frozen at issue time; invoices before snapshots fall back to the live client record. --}} @foreach($invoice->buyerCustomFields() as $label => $value) {{ $label }}: {{ $value }}
@endforeach {{ $invoice->buyer('email') }} @endif

{{ __('pdf.invoice_details') }}

@if($invoice->date_paid) @endif @if($invoice->payment_method) @endif
{{ __('pdf.invoice_date') }}:{{ $invoice->date?->format(date_fmt()) ?? '-' }}
{{ __('pdf.due_date') }}:{{ $invoice->due_date?->format(date_fmt()) ?? '-' }}
{{ __('pdf.date_paid') }}:{{ $invoice->date_paid->format(date_fmt()) }}
{{ __('pdf.payment_method') }}:{{ payment_method_label((string) $invoice->payment_method) }}
@forelse($invoice->items as $item) @php $rate = $item->tax_rate !== null ? (float)$item->tax_rate : ($item->taxed ? (float)$invoice->tax_rate : 0.0); @endphp @empty @endforelse
{{ __('common.table.description') }} {{ __('common.table.qty') }} {{ __('common.table.price') }} {{ __('common.table.tax') }} {{ __('common.table.total') }}
{{ $item->description }} {{ (int) $item->qty }} {{ invoice_money_fmt((float)$item->amount, $invoice) }} {{ $rate > 0 ? rtrim(rtrim(number_format($rate, 2), '0'), '.') . '%' : '—' }} {{ invoice_money_fmt((float)$item->amount * (int)$item->qty, $invoice) }}
{{ __('pdf.no_items') }}
@php $vatGroups = []; foreach ($invoice->items as $it) { $r = $it->tax_rate !== null ? (float) $it->tax_rate : ($it->taxed ? (float) $invoice->tax_rate : 0.0); $label = $it->tax_label ?: ($r > 0 ? rtrim(rtrim(number_format($r, 2), '0'), '.').'%' : null); if ($label === null) { continue; } $tx = (float) $it->amount * (int) $it->qty * $r / 100; $net = (float) $it->amount * (int) $it->qty; if (! isset($vatGroups[$label])) { $vatGroups[$label] = ['amount' => 0.0, 'rate' => $r, 'net' => 0.0]; } $vatGroups[$label]['amount'] += $tx; $vatGroups[$label]['net'] += $net; } uasort($vatGroups, fn ($a, $b) => $b['rate'] <=> $a['rate']); @endphp
@foreach($vatGroups as $label => $g) @endforeach {{-- The second tax. An invoice has carried two since the tax screen grew a level for each; this document showed only the first, so the lines did not add up to the total being asked for. --}} @if((float)($invoice->tax2 ?? 0) > 0) @endif @if((float)$invoice->credit > 0) @endif @if(billing_rate_note($invoice)) {{-- What the customer actually pays, in the currency they pay in, under the rate the document was struck at. --}} @endif
{{ __('pdf.subtotal') }}:{{ invoice_money_fmt((float)$invoice->subtotal, $invoice) }}
{{ $label }}:{{ invoice_money_fmt($g['amount'], $invoice) }}{{ invoice_money_fmt($g['net'], $invoice) }}
{{ __('pdf.tax') }} 2{{ $invoice->tax_rate2 ? ' ('.rtrim(rtrim(number_format((float)$invoice->tax_rate2, 2), '0'), '.').'%)' : '' }}:{{ invoice_money_fmt((float)$invoice->tax2, $invoice) }}
{{ __('pdf.credit') }}:-{{ invoice_money_fmt((float)$invoice->credit, $invoice) }}
{{ __('pdf.total') }}:{{ invoice_money_fmt((float)$invoice->total, $invoice) }}
{{ __('pdf.amount_in') }} ({{ strtoupper($invoice->billing_currency) }}):{{ billing_money_fmt((float)$invoice->total, $invoice) }}
@if(billing_rate_note($invoice))
{{ billing_rate_note($invoice) }}
@endif
@if($invoice->notes)
{{ __('pdf.notes') }}:
{{ $invoice->notes }}
@endif @if(!empty($ksef) && $ksef['qr'] !== '')
KSeF
{{ __('pdf.ksef_number') }}
{{ $ksef['number'] }}
@endif