@php $k = fn ($v) => number_format((float) $v, 2); $p = $s['pricing']; $b = $s['buyer']; $v = $s['vehicle']; $sel = $s['seller']; $fin = $s['finance'] ?? null; $label = \App\Models\DealDocument::TYPES[$doc->type]; @endphp
|
{{ $sel['company'] }} {{ $sel['branch'] }} {{ $sel['address'] }} @if ($sel['phone']) Tel {{ $sel['phone'] }} @endif @if ($sel['email']) · {{ $sel['email'] }} @endif @if ($sel['kra_pin']) KRA PIN: {{ $sel['kra_pin'] }}@endif |
{{ $label }}{{ $doc->number }}Date: {{ $doc->issued_at->format('d M Y') }} Deal: {{ $s['deal_no'] }} @if ($doc->valid_until) {{ $doc->type === 'proforma' ? 'Valid until' : 'Valid until' }}: {{ $doc->valid_until->format('d M Y') }}@endif @if ($doc->etims_invoice_no) Fiscal invoice no: {{ $doc->etims_invoice_no }}@endif |
{{ $doc->type === 'receipt' ? 'Received from' : ($doc->type === 'gate_pass' ? 'Customer' : 'Buyer') }}{{ $b['name'] }}@if ($b['company']){{ $b['company'] }}@endif {{ $b['phone'] }}@if ($b['email']) · {{ $b['email'] }}@endif @if ($b['address']) {{ $b['address'] }}@endif @if ($b['kra_pin'] && in_array($doc->type, ['tax_invoice', 'agreement', 'proforma'])) KRA PIN: {{ $b['kra_pin'] }}@endif @if ($b['id_last4'] && $doc->type === 'agreement') {{ config('crm.id_types')[$b['id_type']] ?? 'ID' }}: ending {{ $b['id_last4'] }}@endif |
Vehicle{{ $v['name'] }}Stock {{ $v['stock_id'] }} · VIN/Chassis {{ $v['vin'] }} @if ($v['registration_no']) Reg. {{ $v['registration_no'] }} · @endif{{ $v['color'] }} · {{ $v['mileage'] }} @if ($v['engine_cc']) · {{ number_format($v['engine_cc']) }}cc @endif |
| Vehicle: {{ $v['name'] }} | KSh {{ $k($p['list_price']) }} |
| Discount | − {{ $k($p['discount']) }} |
| {{ $i['description'] }}{{ $i['quantity'] > 1 ? ' × '.$i['quantity'] : '' }} | {{ $k($i['line_total']) }} |
| {{ $p['tax_name'] ?? 'Tax' }} {{ rtrim(rtrim($p['tax_rate'], '0'), '.') }}% {{ $p['tax_inclusive'] ? '(included in the prices above)' : '(added)' }} | {{ $k($p['tax']) }} |
| TOTAL | KSh {{ $k($p['total']) }} |
Trade-in: {{ $s['trade_in']['description'] }}@if ($s['trade_in']['registration_no']) ({{ $s['trade_in']['registration_no'] }})@endif, grade {{ $s['trade_in']['grade'] }}, valued at KSh {{ $k($s['trade_in']['offered']) }}@if (bccomp($s['trade_in']['payoff'], '0', 2) > 0), less loan KSh {{ $k($s['trade_in']['payoff']) }} to {{ $s['trade_in']['lender'] ?: 'the lender' }}@endif. Credit applied: KSh {{ $k($p['trade_in_credit']) }}.
@endif @if (in_array($doc->type, ['proforma', 'agreement']))| Amount due after trade-in | KSh {{ $k($p['due_after_trade_in']) }} |
| Deposit | KSh {{ $k($p['deposit']) }} |
| Amount financed{{ $fin['financier'] ? ' by '.$fin['financier'] : '' }} | KSh {{ $k($fin['principal']) }} |
| Monthly instalment ({{ $fin['term'] }} months, {{ rtrim(rtrim($fin['rate'], '0'), '.') }}% {{ $fin['method'] === 'flat' ? 'flat' : 'reducing balance' }}; true yearly cost {{ $fin['effective_rate'] }}%) | KSh {{ $k($fin['installment']) }} |
| Total interest / total to repay | {{ $k($fin['total_interest']) }} / {{ $k($fin['total_repayable']) }} |
| Balance payable on or before collection | KSh {{ $k(bcsub($p['due_after_trade_in'], $p['deposit'], 2)) }} |
This pro-forma invoice is a quotation, not a tax invoice. The price is held until the date above. The vehicle is released only after full payment and a gate pass.
@endif @if ($doc->type === 'tax_invoice')Payment received in full. Vehicle details as above. Goods remain the property of the seller until payment has cleared.
@endif @endif {{-- ===== Agreement terms and signatures ===== --}} @if ($doc->type === 'agreement')Version {{ $s['agreement']['version'] }}. Between {{ $sel['company'] }} ("the Seller") and {{ $b['name'] }} ("the Buyer").
|
@if ($sig && isset($images[$role]))
{{ $rl }}: {{ $sig?->signer_name ?? '________________' }}@if ($sig?->signer_title), {{ $sig->signer_title }}@endif{{ $sig ? 'Signed '.$sig->signed_at->format('d M Y, H:i').' · ref '.substr($sig->hash, 0, 12) : 'Not yet signed' }} |
@endforeach
Witness: {{ $sig->signer_name }}, {{ $sig->signed_at->format('d M Y, H:i') }}
@endif @if ($doc->is_executed)Signed by both parties. Document reference {{ substr($doc->snapshot_hash, 0, 16) }}.
@endif @endif {{-- ===== Receipt ===== --}} @if ($doc->type === 'receipt') @php $pay = $s['payment']; @endphp| Amount received | KSh {{ $k($pay['amount']) }} |
| Paid by | {{ $pay['method'] }}{{ $pay['payer'] === 'financier' ? ' (loan paid by lender)' : '' }} |
| Reference | {{ $pay['reference'] }} |
| Date received | {{ \Illuminate\Support\Carbon::parse($pay['received_on'])->format('d M Y') }} |
| Of which tax | KSh {{ $k($pay['vat_portion']) }} |
| Total price of the deal | KSh {{ $k($p['total']) }} |
| Balance after this payment | {{ bccomp($pay['balance_after'], '0', 2) <= 0 ? 'Paid in full' : 'KSh '.$k($pay['balance_after']) }} |
This receipt confirms payment received. A tax invoice is issued when the deal is paid in full.
@endif {{-- ===== Gate pass ===== --}} @if ($doc->type === 'gate_pass') @php $g = $s['gate_pass']; @endphp|
The vehicle {{ $v['name'] }}, registration {{ $v['registration_no'] ?: 'not yet registered' }}, chassis {{ $v['vin'] }}, may leave the premises with: {{ $g['collector_name'] }} Valid until {{ $doc->valid_until->format('d M Y') }}. Payment status: {{ bccomp($g['balance_outstanding'], '0', 2) > 0 ? 'BALANCE OUTSTANDING KSh '.$k($g['balance_outstanding']).' (released on '.($g['override_reason'] ?: 'management authority').')' : 'Paid in full' }}. |
@if ($qr){!! $qr !!}@endif {{ $doc->number }} Scan to check this pass |
| Collector's signature | Gate officer ({{ $doc->released_at ? $doc->released_at->format('d M Y, H:i') : 'date and time' }}) |
Issued by {{ $doc->issuer?->name ?? 'the dealership' }}{{ $s['salesperson'] ? ' · Salesperson: '.$s['salesperson'] : '' }} · {{ $doc->number }}