@php $labels = $doc['labels']; $invoice = $doc['invoice']; $seller = $doc['seller']; $customer = $doc['customer'] ?? []; $billing = $doc['billing_address'] ?? []; $items = $doc['items'] ?? []; $currency = $invoice['currency_code'] ?? ''; $itemName = function (array $item) use ($doc): string { if (! empty($item['product_name_resolved'])) { return (string) $item['product_name_resolved']; } $name = $item['product_name'] ?? ''; if (is_array($name)) { return (string) ($name[$doc['locale']] ?? $name['en'] ?? $name['ar'] ?? reset($name) ?: ''); } return (string) $name; }; $addressLines = function (?array $address): array { if (! is_array($address) || $address === []) { return []; } $lines = []; foreach (['line1', 'line2', 'street', 'building', 'area', 'city', 'state', 'country', 'postal_code'] as $key) { if (! empty($address[$key]) && is_scalar($address[$key])) { $lines[] = (string) $address[$key]; } } if ($lines === [] && ! empty($address['formatted'])) { $lines[] = (string) $address['formatted']; } return $lines; }; @endphp

{{ $doc['document_title'] }}

{{ $labels['invoice_number'] }}: {{ $invoice['number'] }}
{{ $labels['issued_at'] }}: {{ $invoice['issued_at'] }}
{{ $labels['currency'] }}: {{ $currency }}
{{ $seller['legal_name'] ?? '' }} @if(!empty($seller['tax_registration_number']))
{{ $labels['tax_registration_number'] }}: {{ $seller['tax_registration_number'] }}
@endif @if(!empty($seller['commercial_registration_number']))
{{ $labels['commercial_registration_number'] }}: {{ $seller['commercial_registration_number'] }}
@endif @if(!empty($seller['tax_address']))
{{ $seller['tax_address'] }}
@endif

{{ $labels['customer'] }}

{{ $customer['name'] ?? ($customer['full_name'] ?? '—') }}
@if(!empty($customer['email']))
{{ $customer['email'] }}
@endif @if(!empty($customer['phone']))
{{ $customer['phone'] }}
@endif

{{ $labels['billing_address'] }}

@forelse($addressLines($billing) as $line)
{{ $line }}
@empty
—
@endforelse
@forelse($items as $item) @empty @endforelse
{{ $labels['item'] }} {{ $labels['qty'] }} {{ $labels['unit_price'] }} {{ $labels['tax'] }} {{ $labels['line_total'] }}
{{ $itemName($item) }} @if(!empty($item['variant_options_label']))
{{ is_array($item['variant_options_label']) ? implode(', ', $item['variant_options_label']) : $item['variant_options_label'] }}
@endif @if(!empty($item['product_sku']) || !empty($item['variant_sku']))
{{ $item['variant_sku'] ?? $item['product_sku'] }}
@endif
{{ $item['quantity'] ?? '' }} {{ $item['unit_price'] ?? '' }} {{ $item['line_tax_amount'] ?? $item['tax'] ?? '0.000' }} {{ $item['line_gross_amount'] ?? $item['line_total'] ?? '' }}
—
@if (($invoice['rounding_adjustment'] ?? '0.000') !== '0.000') @endif
{{ $labels['subtotal'] }} {{ $invoice['subtotal'] }} {{ $currency }}
{{ $labels['discount'] }} {{ $invoice['discount_amount'] }} {{ $currency }}
{{ $labels['taxable_amount'] }} {{ $invoice['taxable_amount'] }} {{ $currency }}
{{ $labels['tax_amount'] }} {{ $invoice['tax_amount'] }} {{ $currency }}
{{ $labels['shipping'] }} {{ $invoice['shipping_amount'] }} {{ $currency }}
{{ $labels['shipping_tax'] }} {{ $invoice['shipping_tax_amount'] }} {{ $currency }}
{{ $labels['rounding_adjustment'] }} {{ $invoice['rounding_adjustment'] }} {{ $currency }}
{{ $labels['grand_total'] }} {{ $invoice['grand_total'] }} {{ $currency }}
{{ $doc['disclaimer'] }}