@extends('layouts.app') @section('title', __('billing::messages.invoices.title')) @php /* | The status enums name a Bootstrap contextual colour, because that is what | they were written against and the print views still read them. Mapped | here rather than renamed underneath everything that already uses them. */ $pill = static fn (string $tone): string => match ($tone) { 'success' => 'px-pill--green', 'warning' => 'px-pill--amber', 'danger' => 'px-pill--red', 'info' => 'px-pill--blue', 'primary' => 'px-pill--violet', default => 'px-pill--grey', }; @endphp @section('content') {{-- ── Page head ──────────────────────────────────────────────────────── --}}

{{ __('billing::messages.invoices.title') }}

{{ __('billing::messages.invoices.subtitle') }}

{{-- The list a clinic opens every morning, as a button rather than a checkbox somebody has to find at the bottom of the filter panel. --}} {{ __('billing::messages.invoices.outstanding_only') }} {{-- The other direction. A bill paid and then credited leaves the clinic owing the difference back; its status reads "paid" and it appears on no other list, so without this the money is owed and nobody can find it. --}} {{ __('billing::messages.invoices.refunds_due') }}
{{-- ── Filter panel ───────────────────────────────────────────────────── --}} {{-- Outside the swapped region: that region is replaced wholesale on every filter change, which would destroy the field being typed into. --}}
{{-- Kept even though the list filters live: without a script this button is the only way to apply them. --}}
boolean('outstanding'))>
{{ __('common.reset') }}
@forelse ($invoices as $invoice) @php($patient = $participants['patients'][$invoice->patient_id] ?? null) @empty @endforelse
{{ __('billing::messages.invoices.reference') }} {{ __('billing::messages.invoices.patient') }} {{ __('billing::messages.invoices.issued_on') }} {{ __('billing::messages.invoices.total') }} {{ __('billing::messages.invoices.balance') }} {{ __('common.status') }} {{ __('common.actions') }}
{{ $invoice->reference ?? '—' }} {{ trans_choice('billing::messages.invoices.lines_count', $invoice->items_count, ['count' => $invoice->items_count]) }}
{{ $patient?->name ?? '—' }} {{ $patient?->mrn }}
{{ $invoice->issued_on?->format('Y-m-d') ?? '—' }} {{-- Overdue is the one date fact worth colouring: it is the difference between a bill and a debt. --}} @if ($invoice->isOverdue()) {{ __('billing::messages.invoices.due_on') }}: {{ $invoice->due_on->format('Y-m-d') }} @endif {{ $invoice->total->toMajor() }} {{-- Two different facts, and only one of them used to be visible. Positive is money owed to the clinic; negative is money the clinic owes back, which rendered as a plain figure that read like nothing. --}} @if ($invoice->balance->isNegative()) {{ $invoice->balance->absolute()->toMajor() }} {{ __('billing::messages.invoices.owed_back') }} @else $invoice->balance->isPositive()])> {{ $invoice->balance->toMajor() }} @endif
{{ $invoice->status->label() }} @if (! $invoice->status->isVoid()) {{ $invoice->payment_status->label() }} @endif
{{-- Settle the whole bill in one press. The counter's common case: the patient is at the window with the full amount. A part payment, a card reference or a different method is the Take payment panel on the invoice itself, which asks for all of it — this only does the thing that happens forty times a day. The key is minted per row and per page load, so a double press finds the first payment instead of taking a second. --}} @if ($invoice->status->acceptsPayment() && $invoice->balance->isPositive() && $quickMethod !== null) @can('create', \App\Modules\Billing\Models\Payment::class) {{-- The question is asked where the button is, not at the top of the browser window. A native confirm() opens against the top of the screen, far from the row that raised it — on a listing of thirty invoices it is genuinely unclear which one is about to be settled. The button becomes the question instead. --}}
@csrf
@endcan @endif

{{ __('billing::messages.invoices.empty') }}

{{ __('billing::messages.invoices.empty_text') }}

@if ($invoices->hasPages())
{{ $invoices->links() }}
@endif
@endsection