{{-- resources/views/invoices/invoice_layout_1.blade.php --}} @php // Currency helper (R0.00 format) if (! function_exists('zar')) { function zar($amount) { return 'R' . number_format((float)($amount ?? 0), 2, '.', ','); } } $inv = $invoice ?? []; $company = $inv['company'] ?? []; //Licentia - Franchise - Province - info $client = $inv['client'] ?? []; //Business $items = array_values($inv['items'] ?? []); // ensure reindexed - services $totals = $inv['totals'] ?? []; // we can pull ourselves $bank = $inv['bank'] ?? []; //bankAccount $meta = $inv['meta'] ?? []; //useless $status = $inv['status']; $vatRate = (int)($totals['vat_rate'] ?? 15); // Excel-derived greens $GREEN_1 = '#297983'; $GREEN_2 = '#298C9C'; $GREEN_3 = '#4AC4D6'; // Big center stamp color by status //TODO: : let the colours comes from the enum colours set $STAMP_COLOR = match ($status) { Modules\Invoice\Enums\InvoiceStatus::DRAFT => Modules\Invoice\Enums\InvoiceStatus::DRAFT->getColor(), Modules\Invoice\Enums\InvoiceStatus::SENT => Modules\Invoice\Enums\InvoiceStatus::SENT->getColor(), Modules\Invoice\Enums\InvoiceStatus::VIEWED => Modules\Invoice\Enums\InvoiceStatus::VIEWED->getColor(), Modules\Invoice\Enums\InvoiceStatus::PAID => Modules\Invoice\Enums\InvoiceStatus::PAID->getColor(), Modules\Invoice\Enums\InvoiceStatus::OVERDUE => '#DC2626', // red default => null, }; // -------- PRINT-ONLY PAGINATION SETUP -------- // Tune these to your print density: $ITEMS_PER_PAGE_FIRST = $inv['print']['items_per_first'] ?? 18; // first page $ITEMS_PER_PAGE_OTHER = $inv['print']['items_per_other'] ?? 24; // subsequent pages $firstChunk = array_slice($items, 0, $ITEMS_PER_PAGE_FIRST); $rest = array_slice($items, $ITEMS_PER_PAGE_FIRST); $otherPages = $rest ? array_chunk($rest, $ITEMS_PER_PAGE_OTHER) : []; $pagesItems = []; $pagesItems[] = $firstChunk; foreach ($otherPages as $chunk) $pagesItems[] = $chunk; if (count($pagesItems) === 0) $pagesItems = [[]]; $totalPages = count($pagesItems); // Totals across ALL items (used on last print page) $sumSub = 0; $sumVat = 0; $sumTotal = 0; foreach ($items as $line) { $qty = (float)($line['qty'] ?? 1); $unit = (float)($line['unit_price'] ?? 0); $sub = $qty * $unit; $vat = round($sub * $vatRate / 100, 2); $sumSub += $sub; $sumVat += $vat; $sumTotal += ($sub + $vat); } $logoUrl = $company['logo_url'] ?? asset('images/logo_icon.jpg'); $cells = $company['cells'] ?? array_filter([data_get($meta,'cell'), data_get($meta,'cell_alt')]); $email = $company['email'] ?? data_get($meta,'email'); @endphp
Description | Quantity | Sub | VAT {{ $vatRate }}% | Total |
---|---|---|---|---|
{{ $line['description'] ?? '' }}
@if(!empty($line['note']))
{{ $line['note'] }}
@endif
|
{{ number_format($qty, 2, '.', '') }} | {{ zar($sub) }} | {{ zar($vat) }} | {{ zar($lineTotal) }} |
No items added. |
Description | Quantity | Sub | VAT {{ $vatRate }}% | Total |
---|---|---|---|---|
{{ $line['description'] ?? '' }}
@if(!empty($line['note']))
{{ $line['note'] }}
@endif
|
{{ number_format($qty, 2, '.', '') }} | {{ zar($sub) }} | {{ zar($vat) }} | {{ zar($lineTotal) }} |
No items added. |