@foreach($groupedBills as $courtId => $billsByCourt) @php $firstBill = $billsByCourt->first(); @endphp

{{ $company->CompanyName ?? 'Company Name' }}

Billing Period: {{ $billingPeriod ? \Carbon\Carbon::createFromFormat('Ym', $billingPeriod)->format('F Y') : '' }}

Court: {{ $firstBill->court ?? 'N/A' }} ({{ $courtId }})

@foreach($billsByCourt as $bill) @endforeach
Shop No Account No Customer Name Meter No Prev Reading Curr Reading Consumption Amount
{{ $bill->shop_no }} {{ $bill->account_no }} {{ $bill->customer_name }} {{ $bill->meter_no }} {{ number_format($bill->previous_reading, 0) }} {{ number_format($bill->current_reading, 0) }} {{ number_format($bill->consumption_billed, 0) }} {{ number_format($bill->total_bill, 2) }}
Total for {{ $firstBill->court ?? 'N/A' }} ({{ $courtId }}): {{ number_format($billsByCourt->sum('consumption_billed'), 0) }} {{ number_format($billsByCourt->sum('total_bill'), 2) }}
@if($loop->last)
Total Amount: {{ number_format($bills->sum('total_bill'), 2) }}
Total Consumption: {{ number_format($bills->sum('consumption_billed'), 0) }}
Prepared by: ________________________
Date: {{ now()->format('d/m/Y') }}
@endif
@endforeach