@php $order = $getRecord(); $invoice = $order->invoice; $credits = $order->credits()->whereNull('voided_at')->orderBy('created_at')->get(); $hasDocuments = $invoice || $credits->isNotEmpty(); @endphp
{{-- Generate invoice CTA (shown only when no invoice exists) --}} @if (!$invoice)

No invoice generated yet

An invoice is auto-generated when the order status is set to Paid or Processing.

Generate & View Invoice
@endif {{-- Documents table --}} @if ($hasDocuments)
{{-- Invoice row --}} @if ($invoice) @endif {{-- Credit note rows --}} @foreach ($credits as $credit) @endforeach
Date Type Number Amount Actions
{{ $invoice->invoice_date ? \Carbon\Carbon::parse($invoice->invoice_date)->format('d M Y') : $invoice->created_at->format('d M Y') }} Tax Invoice {{ $invoice->invoice_number }} R {{ number_format($order->total_incl, 2) }} View / Print
{{ $credit->created_at->format('d M Y') }} {{ $credit->type === 'store_credit' ? 'Store Credit' : 'Refund' }} CN-{{ str_pad($credit->id, 6, '0', STR_PAD_LEFT) }}
{{ $credit->reason }}
R {{ number_format($credit->amount, 2) }} View / Print
@else

No documents yet for this order.

@endif