@php $counter = 1; @endphp @foreach($payments as $payment)

PAYMENT RECEIPT

Receipt #{{ $counter }} of {{ $payments->count() }}

School: {{ $school->name }}
Invoice Number: {{ $invoice->invoice_number }}
Payment Date: {{ \Carbon\Carbon::parse($payment->payment_date)->format('d M Y') }}
Payment Method: {{ ucfirst(str_replace('_', ' ', $payment->payment_method)) }}
@if($payment->transaction_id)
Transaction ID: {{ $payment->transaction_id }}
@endif
Received By: {{ $payment->receivedBy ? $payment->receivedBy->name : 'Admin' }}
Amount Paid
₹{{ number_format($payment->amount_paid, 2) }}
Payment Summary
Total Invoice Amount: ₹{{ number_format($invoice->total_amount, 2) }}
Total Paid So Far: ₹{{ number_format($payments->take($counter)->sum('amount_paid'), 2) }}
Balance Remaining: ₹{{ number_format(max(0, $invoice->total_amount - $payments->take($counter)->sum('amount_paid')), 2) }}
Page {{ $counter }} of {{ $payments->count() }}
@php $counter++; @endphp @endforeach

PAYMENT SUMMARY

Complete Payment History

@foreach($payments as $index => $p) @endforeach @if($total_paid < $invoice_total) @else @endif
# Date Method Amount
{{ $index + 1 }} {{ \Carbon\Carbon::parse($p->payment_date)->format('d M Y') }} {{ ucfirst(str_replace('_', ' ', $p->payment_method)) }} ₹{{ number_format($p->amount_paid, 2) }}
TOTAL PAID: ₹{{ number_format($total_paid, 2) }}
BALANCE DUE: ₹{{ number_format($invoice_total - $total_paid, 2) }}
FULLY PAID