@extends('layouts.app') @section('title', 'Invoice | ' . ($invoice->invoice_number ?? '')) @section('styles') @endsection @section('content') @php $hs = \App\Helpers\HospitalSettings::all(); $patient = $invoice->patient; $visit = $invoice->visit; // Resolve payment mode — invoice first, then visit, then actual payments $paymentMode = $invoice->payment_mode ?? $visit?->payment_mode ?? 'cash'; $insurancePayment = $invoice->payments->where('payment_method', 'insurance')->first(); if ($insurancePayment) { $paymentMode = 'insurance'; } $isInsurance = strtolower($paymentMode) === 'insurance'; // Resolve insurer name $insurerName = null; if ($isInsurance) { $insurerName = $invoice->insuranceCompany?->name ?? $visit?->insuranceCompany?->name ?? $insurancePayment?->description ?? 'Insurance'; } // Authorization code $authCode = $visit?->authorization_code ?? null; // Financial summary $subtotal = $invoice->subtotal ?? $invoice->total_amount; $discount = $invoice->discount_amount ?? 0; $waiver = $invoice->waiver_amount ?? 0; $grandTotal= $invoice->total_amount ?? 0; // Address split $addr = $hs['hospital_address'] ?? 'Utawala | 83 Park Estate, Kiguathi Rd'; if (str_contains($addr, '(')) { $addrLine1 = trim(substr($addr, 0, strpos($addr, '('))); $addrLine2 = trim(substr($addr, strpos($addr, '('))); } else { $addrLine1 = $addr; $addrLine2 = ''; } @endphp
Back Download PDF
{{-- ── LETTERHEAD ── --}}
Logo

{{ $hs['hospital_name'] ?? 'Clara Rosa Hospital Utawala' }}

{{ $addrLine1 }}

@if($addrLine2)

{{ $addrLine2 }}

@endif

Tel: {{ $hs['hospital_phone'] ?? '' }}

{{ $isInsurance ? 'INSURANCE INVOICE' : 'INVOICE' }}

No: {{ $invoice->invoice_number }}

Date: {{ $invoice->created_at->format('d M Y') }}

{{-- ── PATIENT + INSURANCE INFO (two columns) ── --}}
{{-- Patient Information --}}

PATIENT INFORMATION

Patient No.:{{ $patient->mrn ?? '' }}
Full Name:{{ $patient->full_name ?? '' }}
Date of Birth:{{ $patient->date_of_birth ? \Carbon\Carbon::parse($patient->date_of_birth)->format('d M Y') : '-' }}
Gender:{{ ucfirst($patient->gender ?? '-') }}
Clinician:{{ $visit?->clinician?->name ?? '-' }}
Visit Date:{{ $invoice->created_at->format('d M Y, H:i') }}
@if($isInsurance) {{-- Insurance Information --}}

INSURANCE INFORMATION

@if($patient->insurance_scheme ?? null) @endif @if($authCode) @endif
Insurer:{{ $insurerName }}
Scheme/Plan:{{ $patient->insurance_scheme }}
Auth. Code:{{ $authCode }}
Payer Type:Insurance
@endif
{{-- ── SERVICES RENDERED ── --}}

SERVICES RENDERED

@foreach($invoice->items as $item) @endforeach @if($discount > 0) @endif @if($waiver > 0) @endif
DESCRIPTION UNIT PRICE (KES) QTY TOTAL (KES)
{{ $item->description }} @if($item->category && $item->category !== 'General') · {{ $item->category }} @endif {{ number_format($item->unit_price) }} {{ $item->quantity }} {{ number_format($item->total) }}
Subtotal: {{ number_format($subtotal) }}
Discount{{ $invoice->discount_reason ? ' ('.$invoice->discount_reason.')' : '' }}: - {{ number_format($discount) }}
Waiver{{ $invoice->waiver_reason ? ' ('.$invoice->waiver_reason.')' : '' }}: - {{ number_format($waiver) }}
AMOUNT DUE: KES {{ number_format($grandTotal) }}
{{-- ── PAYER INFORMATION ── --}}

PAYER INFORMATION

PAYER NAME CURRENCY AMOUNT
PLEASE PAY: {{ $isInsurance ? $insurerName : ucfirst($paymentMode) }} KES {{ number_format($grandTotal) }}
{{-- ── PAYMENT INFORMATION ── --}}

PAYMENT INFORMATION

Paybill: 522533
Account Number: 6346132
KCB Bank, Clara Rosa Hospital Utawala

{{-- ── SIGNATURE BLOCK ── --}}

Authorized Signature & Stamp

Patient / Guardian Signature

Date

{{-- ── FOOTER ── --}}
Generated: {{ now()->format('d M Y, H:i') }} {{ $hs['hospital_name'] ?? 'Clara Rosa Hospital' }} · This is a computer-generated invoice Page 1 of 1
@endsection