@extends('layouts.app') @section('title', 'Receipt | ' . $receipt->receipt_number) @section('styles') @endsection @section('content') @php // Pre-compute totals so the receipt always shows complete financial picture. $inv = $receipt->invoice; $invTotal = (float) ($inv?->total_amount ?? 0); $invPaid = (float) ($inv?->amount_paid ?? 0); $invBalance = (float) ($inv?->balance ?? max(0, $invTotal - $invPaid)); $isFullyPaid = $inv && $invBalance <= 0; // All payments on this invoice, grouped by method+description so splits // like "GA Insurance" and "SHA" each show as their own line. $allPayments = $inv?->payments ?? collect(); $paymentsGrouped = $allPayments->groupBy(function ($p) { $label = ucfirst(str_replace('_', ' ', $p->payment_method)); if ($p->payment_method === 'insurance' && $p->description) { $label = $p->description; } return $label; })->map(fn($grp, $name) => [ 'name' => $name, 'amount' => $grp->sum('amount'), 'count' => $grp->count(), 'last' => $grp->max('created_at'), ])->values(); @endphp
This receipt acknowledges one payment transaction on this invoice.
| Patient Name | {{ $receipt->patient->full_name ?? '' }} |
| MRN | {{ $receipt->patient->mrn ?? '' }} |
| Invoice No. | {{ $inv?->invoice_number ?? '' }} |
| Payment Method | {{ str_replace('_', ' ', $receipt->payment_method) }}{{ $receipt->payment?->description ? ' — '.$receipt->payment->description : '' }} |
| Reference | {{ $receipt->payment->reference_number ?? $receipt->payment->mpesa_code ?? '' }} |
SHA Member Details
| SHA Number | {{ $receipt->payment->sha_number }} |
| Member Name | {{ $receipt->payment->sha_member_name }} |
| Relationship | {{ $receipt->payment->sha_relationship }} |
| Auth Reference | {{ $receipt->payment->sha_auth_reference }} |
Amount Received (This Payment)
KES {{ number_format($receipt->amount, 2) }}
Invoice Summary ({{ $inv->invoice_number }})
| Total Billed: | KES {{ number_format($invTotal) }} |
| · {{ $pg['name'] }}{{ $pg['count'] > 1 ? ' ('.$pg['count'].' payments)' : '' }} | + {{ number_format($pg['amount']) }} |
| Total Paid: | KES {{ number_format($invPaid) }} |
| Balance Due: | KES {{ number_format($invBalance) }} @if($invBalance <= 0) FULLY PAID @endif |
{{ $isItemized ? 'Items Covered by This Payment' : 'Services on This Visit' }}
| Description | Amount | @if($isItemized)Status | @endif
|---|---|---|
| {{ $item->description }} | KES {{ number_format($item->total) }} | @if($isItemized){{ $covered ? '✓ PAID' : '' }} | @endif