@extends('layouts.app') @section('title', 'View Bill #' . $invoice->BillID) @push('styles') @endpush @section('content')

Bill Details #{{ $invoice->BillID }}

Billing Period: {{ $invoice->BillingPeriod }}

Bill To:

{{ $invoice->customer->CustomerName ?? 'N/A' }}

{{ $invoice->customer->Address1 ?? '' }}

{{ $invoice->customer->Address2 ?? '' }}

{{ $invoice->customer->City ?? '' }}, {{ $invoice->customer->PostalCode ?? '' }}

{{ $invoice->customer->Phone ?? '' }} {{ $invoice->customer->Email ?? '' }}
Bill Details:
Bill #: {{ $invoice->BillID }}
Account #: {{ $invoice->customer->AccountNo ?? 'N/A' }}
Meter #: {{ $invoice->customer->EMeterNo ?? 'N/A' }}
Bill Date: {{ \Carbon\Carbon::parse($invoice->BillDate)->format('M d, Y') }}
Due Date: {{ \Carbon\Carbon::parse($invoice->DueDate)->format('M d, Y') }}
Bill Items
@foreach($invoice->lines as $index => $line) @endforeach @php $calculatedSubtotal = $invoice->lines->sum('LineAmount'); $previousBalance = $invoice->PreviousBalance ?? 0; $totalDue = $calculatedSubtotal + $previousBalance; @endphp
# Description Units Rate Amount
{{ $index + 1 }} {{ $line->ItemName }} {{ number_format($line->Units, 2) }} {{ number_format($line->UnitPrice, 2) }} {{ number_format($line->LineAmount, 2) }}
Subtotal: {{ number_format($calculatedSubtotal, 2) }}
Previous Balance: {{ number_format($previousBalance, 2) }}
Total Due: {{ number_format($totalDue, 2) }}
Payment History
@if($payments && $payments->count() > 0)
@foreach($payments as $payment) @endforeach
Date Receipt # Amount
{{ $payment->PaymentDate ? \Carbon\Carbon::parse($payment->PaymentDate)->format('M d, Y') : 'N/A' }} {{ $payment->ReceiptNo ?? 'N/A' }} KES {{ number_format($payment->TotalPayment, 2) }}
Total Paid: KES {{ number_format($totalPaid, 2) }}
Balance: KES {{ number_format($balance, 2) }} @if($balance <= 0) Paid @elseif($totalPaid > 0) Partial @else Unpaid @endif
@else

No payment history found for this bill.

@endif
Actions
Print Bill
@push('scripts') @endpush @endsection