@extends('layouts.app') @section('title', 'Billing Details - ' . $billing->billing_number) @section('content')

{{ $billing->billing_number }} @if($billing->is_legacy) Old System @endif

Billing Date: {{ $billing->billing_date->format('M d, Y') }} | Due Date: {{ $billing->due_date->format('M d, Y') }}

@if(session('success')) @endif @if($errors->any()) @endif @if($billing->status === 'voided')
This billing was voided
Voided {{ $billing->voided_at?->format('M d, Y g:i A') }} @if($billing->voidedByUser) by {{ $billing->voidedByUser->name }} @endif @if($billing->voidAuthorizedByUser) — authorized by {{ $billing->voidAuthorizedByUser->name }} (owner) @endif @if($billing->void_reason)
Reason: {{ $billing->void_reason }}@endif
All payments against it were reversed and are excluded from collections and reports.
{{-- The consumption behind a voided bill is still unbilled, so offer the way back: raise a fresh bill from the same reading. --}} @if($billing->meterReading?->isBillable())
@csrf The reading stays approved; this raises a replacement bill.
@endif
@endif
Client Information

{{ $billing->client->name }}
Account: {{ $billing->client->account_number }}
Meter: {{ $billing->client->meter_number ?? 'N/A' }}
{{ $billing->client->address ?? '' }}

Billing Status

Status: {{ ucfirst(str_replace('_', ' ', $billing->status)) }}
Amount Due: ₱{{ number_format($billing->total_amount_due, 2) }}
Amount Paid: ₱{{ number_format($billing->amount_paid, 2) }}
Balance: @if ($billing->balance > 0) ₱{{ number_format($billing->balance, 2) }} @else ₱0.00 @endif
Due Date: {{ $billing->due_date->format('M d, Y') }}
@if($billing->disconnection_date) Disconnection Date: {{ $billing->disconnection_date->format('M d, Y') }} @endif

Billing Details
@if($billing->is_legacy)

Carried over from the old system — no meter reading is attached to this billing.

@else

Previous Reading: {{ number_format($billing->previous_reading, 2) }} cu.m
Current Reading: {{ number_format($billing->current_reading, 2) }} cu.m
Units Consumed: {{ number_format($billing->units_consumed, 2) }} cu.m

@endif
Subtotal ₱{{ number_format($billing->subtotal, 2) }}
Tax ₱{{ number_format($billing->tax, 2) }}
Other Charges ₱{{ number_format($billing->other_charges, 2) }}
Penalties ₱{{ number_format($billing->penalties, 2) }}
Total Amount Due ₱{{ number_format($billing->total_amount_due, 2) }}
@unless ($billing->status === 'voided') Edit @endunless @if ($billing->status === 'draft')
@csrf
@endif @if ($billing->balance > 0) Add Payment @endif {{-- Void reverses collected payments; Cancel calls off a bill that never took any money. Exactly one of the two ever applies. --}} @can('void', $billing) @if ($billing->isVoidable()) @endif @endcan @can('cancel', $billing) @if ($billing->isCancellable())
@csrf
@endif @endcan
@if ($charges->count() > 0)
Charges Added
Fees and notices added to this billing. These are amounts owed, not money received — they are already included in the Total Amount Due above.
@foreach ($charges as $charge) @endforeach
Reference # Type Amount Date Added Status
{{ $charge->reference_number }} {{ ucfirst(str_replace('_', ' ', $charge->type)) }} ₱{{ number_format($charge->amount, 2) }} {{ ($charge->charged_at ?? $charge->created_at)->format('M d, Y') }} {{ ucfirst($charge->status) }}
@endif @if ($payments->count() > 0)
Payment History
Money received against this billing.
@foreach ($payments as $payment) @endforeach
Reference # Amount Method Date Status
{{ $payment->reference_number }} ₱{{ number_format($payment->amount, 2) }} {{ ucfirst(str_replace('_', ' ', $payment->payment_method)) }} {{ $payment->payment_date->format('M d, Y') }} {{ ucfirst($payment->status) }}
@endif
Back to Billings
@can('void-billings') @include('components.void-billing-modal', ['hasVoidAuthorizer' => $hasVoidAuthorizer]) @endcan @endsection