{{-- 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 Invoice {{ $inv['number'] ?? '' }} @vite(['resources/css/app.css']) {{-- Tailwind via Vite --}} {{-- ========================= SCREEN VIEW (single page) ========================= --}}
{{-- Decorative GREEN SHARDS background --}}
{{-- BIG CENTER STAMP (screen) --}} @if($STAMP_COLOR)
{{ $status }}
@endif {{-- Header --}}
Company Logo
{{ $company['name'] ?? 'Your Company Name' }}
{{ $company['tagline'] ?? 'Company tagline or description' }}
Cell
{{ !empty($cells) ? implode(' | ', $cells) : '—' }}
Email
{{ $company['email'] ?? ''}}

Invoice

{{ $status }}
Invoice No
{{ $inv['number'] ?? '' }}
Reference
{{ $inv['reference'] ?? '' }}
Date
{{ $inv['date'] ?? now()->toDateString() }}
{{-- Bill To / Contact --}}

Bill To

Client
{{ $client['name'] ?? '' }}
Reg No
{{ $client['reg_no'] ?? '' }}
Trading As
{{ $client['trading_as'] ?? '' }}
VAT No
{{ $client['vat_no'] ?? '' }}
Street
{{ data_get($client, 'address.street') }}
Town/City
{{ data_get($client, 'address.city') }}
Code
{{ data_get($client, 'address.code') }}

Contact

Executive
{{ data_get($meta, 'executive') }}
Cell
{{ data_get($meta, 'cell') }}
Email
{{ data_get($meta, 'email') }}
{{-- ITEMS (SCREEN: all items in one table) --}}
{{-- Description (flex) --}} {{-- Quantity --}} {{-- Sub --}} {{-- VAT 15% --}} {{-- Total --}} @forelse($items as $line) @php $qty = (float)($line['qty'] ?? 1); $unit = (float)($line['unit_price'] ?? 0); $sub = $qty * $unit; $vat = round($sub * $vatRate / 100, 2); $lineTotal = $sub + $vat; @endphp @empty @endforelse
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.
{{-- Banking + Totals (SCREEN) --}} @php $discount = (float)($totals['discount'] ?? 0); @endphp
{{-- Banking --}}

Banking & Payment Information

Account Name
{{ $bank['account_name'] ?? '' }}
Bank
{{ $bank['bank'] ?? '' }}
Account No
{{ $bank['account_no'] ?? '' }}
Branch Code
{{ $bank['branch_code'] ?? '' }}
Type
{{ $bank['type'] ?? 'Current Account' }}
Terms
{{ $bank['terms'] ?? 'Net 7 — Payment within 7 days of invoice' }}
@if(!empty($inv['payment_note']))
Payment
{{ $inv['payment_note'] }}
@endif
@if(!empty($inv['notes']))

Notes

{{ $inv['notes'] }}
@endif
{{-- Totals --}}
Sub-Total{{ zar($sumSub) }}
@if($discount !== 0.0)
Discount-{{ zar($discount) }}
@endif
VAT {{ $vatRate }}%{{ zar($sumVat) }}
Total Due {{ zar(max(0, $sumTotal - $discount)) }}
@if(!empty($inv['due_on']))
Due on {{ $inv['due_on'] }}
@endif
{{-- Screen footer / print button --}}
© {{ date('Y') }} {{ $company['name'] ?? 'Your Company' }} — All rights reserved.
• REG: {{ $company['registration'] ?? '' }} @if(!empty($company['vat'])) • VAT: {{ $company['vat'] }} @endif
{{-- ========================= PRINT VIEW (multi-page) ========================= --}}