@extends('layouts.app') @section('title','Open Balance Report') @section('content')

Accounts Receivable

Live figure (not date-bound)

Money owed to the hospital right now — patient-owed plus insurance claims still pending settlement.

{{-- ═══ CANONICAL A/R CARDS ═══════════════════════════════════════════════ These three cards are the canonical A/R figures Dashboard also shows. "Total A/R" = "Patient-Owed" + "Insurance-Owed". --}}

Total A/R

KES {{ number_format($totalAr) }}

Patient-Owed

KES {{ number_format($arPatient) }}

Insurance Pending

KES {{ number_format($arInsurer) }}

{{-- ═══ SECONDARY: GROSS OPEN BALANCE (RECONCILIATION ONLY) ═════════════ This used to be the headline number. Kept here as a separate, smaller line because some legacy workflows reference it. The note explains why the canonical A/R above is the operational figure. --}} @if($grossOpenBalance != $totalAr)
Gross Open Balance: KES {{ number_format($grossOpenBalance) }}
Difference: KES {{ number_format($grossOpenBalance - $totalAr) }}

The gross figure includes written-off invoices, cancelled-visit balances, and insurance invoices that have been pseudo-paid at the cashier. These are not actually collectable. The canonical A/R figure above is what finance should track.

@endif {{-- ═══ INVOICE LISTING — patient-owed only ═════════════════════════════ Insurance/corporate invoices are NOT listed here because they're accounted for in the insurance_claims table (and in the "Insurance Pending" card above). For per-claim aging, see the Claims Aging report. --}}
Showing {{ $invoices->count() }} patient-owed invoices that contribute to A/R. Insurance claims are tracked separately in Claims Aging.
@forelse($invoices as $inv) @empty @endforelse
Patient MRN Visit Payer Billed Paid Balance
{{ $inv->patient->full_name ?? '' }} {{ $inv->patient->mrn ?? '' }} {{ $inv->visit->visit_number ?? '' }} {{ $inv->payment_mode ?: '—' }} {{ number_format($inv->total_amount) }} {{ number_format($inv->amount_paid) }} {{ number_format($inv->balance) }}
No patient-owed open balances right now.
@endsection