{{ $invoice->getPdfDocumentTitle() }}
{{ $company->name ?? 'COMPANY NAME' }}
@if($company->tagline)
{{ $company->tagline }}
@endif
@if($company->address) @endif @if($company->city) @endif @if($company->vat_number) @endif @if($company->phone) @endif @if($company->email && stripos($company->email, 'sage-migration.local') === false) @endif @if($company->fax) @endif
Address: {{ $company->address }}
City: {{ $company->city }}
VAT Number: {{ $company->vat_number }}
Phone: {{ $company->phone }}
Email: {{ $company->email }}
Fax: {{ $company->fax }}

Banking Details

{{ $company->bank_account_name ?? $company->name }}

@if($company->bank_name)

Bank Name: {{ $company->bank_name }}

@endif @if($company->bank_account_number)

Acc No: {{ $company->bank_account_number }}

@endif @if($company->bank_sort_code)

Branch Code: {{ $company->bank_sort_code }}

@endif

To:

{{ $invoice->customer->account_code ?? 'N/A' }}

{{ $invoice->customer->name ?? 'CUSTOMER NAME' }}

@if($invoice->contact)

Attn: {{ $invoice->contact->name }}

@endif @if($invoice->customer->address)

{{ $invoice->customer->address }}

@endif @if($invoice->customer->city)

{{ $invoice->customer->city }}

@endif @if($invoice->customer->postal_code)

{{ $invoice->customer->postal_code }}

@endif @php $invoiceDisplayEmail = null; if ($invoice->email && stripos($invoice->email, 'sage-migration.local') === false) { $invoiceDisplayEmail = $invoice->email; } elseif ($invoice->customer->email && stripos($invoice->customer->email, 'sage-migration.local') === false) { $invoiceDisplayEmail = $invoice->customer->email; } @endphp @if($invoiceDisplayEmail)

{{ $invoiceDisplayEmail }}

@endif @if($invoice->phone)

{{ $invoice->phone }}

@elseif($invoice->customer->phone)

{{ $invoice->customer->phone }}

@endif
{{ $invoice->customer->vat_number ?? '-' }}
@if($invoice->description)

Description

{{ $invoice->description }}

@endif
Account {{ $invoice->customer->account_code ?? 'N/A' }}
Date {{ $invoice->invoice_date ? $company->formatLocalizedDate($invoice->invoice_date) : $company->formatLocalizedDate(now()) }}
Order No {{ $invoice->order_number ?? '' }}
Job No {{ $invoice->job_number ?? '' }}
Invoice No {{ $invoice->invoice_number ?? 'N/A' }}
@php $lineGroups = $invoice->lineGroups ?? collect(); $items = ($invoice->lineItems ?? collect())->filter(function ($item) { return strtolower(trim((string) ($item->description ?? ''))) !== 'rounding adjustment'; }); $resolvedGroups = collect(); $renderedItemIds = collect(); foreach ($lineGroups->sortBy('sort_order') as $group) { $groupItems = $items->where('line_group_id', $group->id); if ($groupItems->isNotEmpty()) { $resolvedGroups->push((object) [ 'name' => $group->name, 'items' => $groupItems, ]); $renderedItemIds = $renderedItemIds->merge($groupItems->pluck('id')); } } $ungroupedItems = $items->filter(function ($item) use ($renderedItemIds) { return !$renderedItemIds->contains($item->id); }); if ($resolvedGroups->isEmpty() && $items->isNotEmpty()) { $resolvedGroups->push((object) [ 'name' => 'Items', 'items' => $items, ]); } elseif ($ungroupedItems->isNotEmpty()) { $resolvedGroups->push((object) [ 'name' => 'Items', 'items' => $ungroupedItems, ]); } @endphp @foreach($resolvedGroups as $group) @if($group->name) @endif @foreach($group->items->sortBy('sort_order') as $item) @endforeach @endforeach
Item Description Item Code QTY Price (Ex) Discount Tax Total (Excl)
{{ $group->name }}
{{ $item->description ?? 'Item Description' }}
@if(!empty($item->serialNumbers) && $item->serialNumbers->count() > 0)
Serial Numbers: @foreach($item->serialNumbers as $serial) {{ $serial->serial_number }}{{ !$loop->last ? ', ' : '' }} @endforeach
@endif
{{ ($item->product->sku ?? $item->product->barcode ?? $item->product->item_code ?? '—') }} {{ $company->formatNumber($item->quantity ?? 0, 2) }} {{ $company->formatCurrencyZar($item->unit_price ?? 0) }} @if(($item->discount_percentage ?? 0) > 0) {{ $company->formatNumber($item->discount_percentage, 2) }}% @elseif(($item->discount_amount ?? 0) > 0) {{ $company->formatCurrencyZar($item->discount_amount) }} @else — @endif @if($item->taxRate) {{ $company->formatCurrencyZar($item->tax_amount ?? 0) }} @else — @endif {{ $company->formatCurrencyZar($item->total ?? 0) }}
@php $lineItemsForRoundingTotals = $invoice->lineItemsForRoundingTotals ?? $invoice->lineItems ?? collect(); $roundingAdjustment = $lineItemsForRoundingTotals->reduce(function ($sum, $item) { $description = strtolower(trim((string) ($item->description ?? ''))); if ($description !== 'rounding adjustment') { return $sum; } $lineTotal = (float) ($item->total ?? (($item->quantity ?? 0) * ($item->unit_price ?? 0))); return $sum + $lineTotal; }, 0.0); $subtotalExcludingRounding = $lineItemsForRoundingTotals->sum(function ($item) { if (\App\Models\Invoice::isRoundingAdjustmentLineItem($item->description ?? null)) { return 0.0; } return (float) ($item->total ?? 0); }); @endphp
Subtotal: {{ $company->formatCurrencyZar($subtotalExcludingRounding) }}
@if(($invoice->tax_amount ?? 0) > 0)
Tax: {{ $company->formatCurrencyZar($invoice->tax_amount) }}
@endif @if(($invoice->discount_amount ?? 0) > 0)
Discount: -{{ $company->formatCurrencyZar($invoice->discount_amount) }}
@endif @if(abs($roundingAdjustment) > 0.0001)
Rounding Adjustment: {{ $company->formatCurrencyZar($roundingAdjustment) }}
@endif
Total: {{ $company->formatCurrencyZar($invoice->total ?? 0) }}
@if($invoice->notes || $invoice->terms_conditions)
@if($invoice->notes)

Notes

{{ $invoice->notes }}

@endif @if($invoice->terms_conditions)

Terms & Conditions

{{ $invoice->terms_conditions }}

@endif
@endif @if(($company->enable_document_signing ?? false) && ($invoice->signatures ?? collect())->count() > 0)
Signatures
@foreach(($invoice->signatures ?? collect())->chunk(3) as $signatureRow)
@foreach($signatureRow as $signature)
{{ $signature->signer_name }} @if($signature->signed_at) - {{ $company->formatLocalizedDateTime($signature->signed_at) }} @endif
@php($signatureDataUri = $signature->getSignaturePathForPdf()) @if($signatureDataUri) Signature @endif
@endforeach @for($i = $signatureRow->count(); $i < 3; $i++)
 
@endfor
@endforeach
@elseif(! ($company->enable_document_signing ?? false))
Received by
Date
Signature
@endif