@php $isInvoice = $docType === 'invoice'; $isDN = $docType === 'delivery-note'; $isReceipt = $docType === 'receipt'; // For invoice + DN $docNumber = $isInvoice ? ($document->invoice_number ?? '—') : ($isDN ? ($document->dn_number ?? '—') : ($payment->receipt_number ?? '—')); $docDate = $isInvoice ? $document->created_at->format('M d, Y') : ($isDN ? ($document->issued_at?->format('M d, Y') ?? now()->format('M d, Y')) : ($payment->created_at->format('M d, Y'))); // Reference for consignment — flight_no (air slot) takes priority, HAWB shown as sub-line $reference = isset($consignment) ? ($consignment->flight_no ?? $consignment->container_no ?? $consignment->house_waybill_no ?? "CON-{$consignment->id}") : ($payment->consignment->flight_no ?? $payment->consignment->container_no ?? $payment->consignment->house_waybill_no ?? '—'); @endphp {{-- ── Toolbar ───────────────────────────────────────────────── --}}
{{ $isInvoice ? 'Invoice' : ($isDN ? 'Delivery Note' : 'Receipt') }}
Back
{{-- ── RECEIPT — rendered outside the fancy doc wrapper ────────── --}} @if($isReceipt)
{{-- Company header --}}
Salihiya World Cargo Limited
Nairobi, Kenya

Payment Receipt
Receipt No. {{ $payment->receipt_number }}
Date {{ $payment->created_at->format('d M Y, H:i') }}
@if($payment->cashier)
Served By {{ $payment->cashier->name }}
@endif
Name {{ $payment->consignment->customer_name }}
Phone {{ $payment->consignment->phone }}
Cargo Ref. {{ $reference }}
@if($payment->invoice)
Invoice No. {{ $payment->invoice->invoice_number }}
@endif
KES {{ number_format($payment->amount_kes, 2) }}
via {{ match($payment->method) { 'mpesa' => 'M-Pesa', 'cash' => 'Cash', 'bank' => 'Bank Transfer', 'cheque' => 'Cheque', default => ucfirst($payment->method), } }} @if($payment->reference)  • {{ $payment->reference }} @endif
@if($payment->invoice)
Invoice Total KES {{ number_format($payment->invoice->amount_kes, 2) }}
Total Paid KES {{ number_format($payment->invoice->amount_paid_kes, 2) }}
Balance Due KES {{ number_format($payment->invoice->outstanding_kes, 2) }}
@if($payment->invoice->payment_status === 'paid')
✓ Fully Paid
@elseif($payment->invoice->outstanding_kes > 0)
Balance: KES {{ number_format($payment->invoice->outstanding_kes, 2) }}
@endif @endif @if($payment->notes)
Notes{{ $payment->notes }}
@endif
{{-- Invoice & DN use the fancy doc wrapper --}} @else
{{-- Header --}}
{{ $isDN ? 'Delivery Note' : 'Invoice' }}
{{ $docNumber }}
{{ $docDate }}
{{-- placeholder so @elseif/$isInvoice block below works --}} @if(false) {{-- ── INVOICE ───────────────────────────────────────────── --}} @elseif($isInvoice) {{-- REPLACE only the INVOICE section inside document-print.blade.php Find the @elseif($isInvoice) block and replace everything inside it with the content below (keep the @elseif and @else lines themselves) --}} {{-- ── INVOICE ───────────────────────────────────────────── --}} {{-- Top info band --}}
Bill To
{{ $consignment->customer_name }}
{{ $consignment->phone }}
{{ $consignment->shipment->type === 'air' ? 'Flight No.' : 'Container No.' }}
{{ $reference }}
@if($consignment->shipment->type === 'air' && $consignment->house_waybill_no && $consignment->flight_no)
HAWB: {{ $consignment->house_waybill_no }}
@else
{{ strtoupper($consignment->shipment->type) }} Freight
@endif
Shipment
{{ $consignment->shipment->reference }}
{{ $consignment->shipment->origin }} → {{ $consignment->shipment->destination }}
{{-- Charge breakdown --}}
Charge Breakdown
@php $shipmentType = $consignment->shipment->type; $exRate = \App\Models\GlobalSetting::exchangeRate(); $extraUsd = (float) $document->extra_charge_usd; $totalUsd = (float) $document->amount_usd; $freightUsd = $shipmentType === 'air' ? round($totalUsd - $extraUsd, 2) : 0; @endphp
@if($shipmentType === 'air') {{-- Air: show freight USD + extra USD + exchange rate --}}
Freight @if($consignment->actual_weight_kgs) ({{ $consignment->actual_weight_kgs }} KGS × ${{ number_format(\App\Models\GlobalSetting::airRateForRoute($consignment->shipment->origin . $consignment->shipment->destination), 2) }}) @endif
$ {{ number_format($freightUsd, 2) }}
@else {{-- Sea: show CBM charge in KES --}} @php $cbmRate = \App\Models\GlobalSetting::seaRateForRoute($consignment->shipment->origin . $consignment->shipment->destination); $cbmCharge = round((float)$consignment->cbm * $cbmRate, 2); @endphp
Sea Freight @if($consignment->cbm) ({{ $consignment->cbm }} CBM × KES {{ number_format($cbmRate, 0) }}) @endif
KES {{ number_format($cbmCharge, 2) }}
@endif {{-- Extra charge --}}
Extra Charge
@if($extraUsd > 0) $ {{ number_format($extraUsd, 2) }}
= KES {{ number_format($extraUsd * $exRate, 2) }}
@else @endif
{{-- Exchange rate used --}} @if($shipmentType === 'air')
Exchange Rate
KES {{ number_format($exRate, 2) }}
per $1 USD
@endif
{{-- Totals box --}}
@if($shipmentType === 'air' && $document->amount_usd > 0)
Total (USD) $ {{ number_format($document->amount_usd, 2) }}
@endif
Invoice Total (KES) KES {{ number_format($document->amount_kes, 2) }}
Amount Paid KES {{ number_format($document->amount_paid_kes, 2) }}
Outstanding KES {{ number_format($document->outstanding_kes, 2) }}
{{-- Payment status note --}} @if($document->payment_status === 'paid')
✓ FULLY PAID
@elseif($document->payment_status === 'partial')
Partial Payment — Outstanding: KES {{ number_format($document->outstanding_kes, 2) }}
@endif {{-- ── DELIVERY NOTE ─────────────────────────────────────── --}} @else {{-- Delivery confirmed banner (shown once goods are released) --}} @if($consignment->status === 'delivered' && $consignment->collected_at)
GOODS RELEASED — DELIVERY CONFIRMED
This delivery note is final and cannot be modified.
Collected by: {{ $consignment->collected_by ?? $document->received_by ?? '—' }}
At: {{ $consignment->collected_at->format('d M Y, H:i') }}
@endif
Consignee
{{ $consignment->customer_name }}
{{ $consignment->phone }}
Reference
{{ $reference }}
{{ strtoupper($consignment->shipment->type) }} Freight
{{ $consignment->shipment->type === 'sea' ? 'Container Batch' : 'Flight Batch' }}
{{ $consignment->shipment->reference }}
{{ $consignment->destination }}
Cargo Details
@if($consignment->actual_weight_kgs) @endif @if($consignment->cbm) @endif @if($consignment->actual_weight_kgs) @endif @if($consignment->cbm) @endif
Description PCS/CTNWeight (KGS)CBM (m³)Destination
{{ $consignment->description ?? '—' }} {{ $consignment->pcs }}{{ $consignment->actual_weight_kgs }}{{ $consignment->cbm }}{{ $consignment->destination }}
@if($document->notes)
Notes

{{ $document->notes }}

@endif
Released By — Cargo Staff
Name & Signature
Received By — Consignee
@if($consignment->status === 'delivered') {{-- Goods taken: show confirmed details instead of blank line --}}
{{ $consignment->collected_by ?? $document->received_by ?? '—' }}
@if($consignment->collected_at)
{{ $consignment->collected_at->format('d M Y \a\t H:i') }}
@endif
@else
@if($document->received_by) {{ $document->received_by }} @else Name, Signature & Date @endif
@endif
@endif

Salihiya World Cargo Limited · Nairobi, Kenya

{{ $docNumber }} · Printed {{ now()->format('M d, Y H:i') }}

@endif {{-- end @else (invoice/DN doc wrapper) --}}