@foreach ($transactions as $transaction)

{{ $transaction->company_name ?? '' }}

@if( $transaction->registration_number)
Registration Number: {{ $transaction->registration_number ?? '' }}
@endif

{{ $transaction->company_address_line1 ?? '' }}

Receipt

{{-- @if (\Carbon\Carbon::parse($transaction->start_date)->format('M') == \Carbon\Carbon::parse($transaction->end_date)->format('M')) @else @endif --}} @php $paidUpTo = null; $endDate = $transaction->latest_invoice_end_date ? \Carbon\Carbon::parse($transaction->latest_invoice_end_date) : null; $invoiceAmount = $transaction->latest_invoice_amount; $remainingAmount = $transaction->latest_invoice_remaining_amount ?? 0; if ($endDate && $invoiceAmount && $remainingAmount !== null) { if ($invoiceAmount == $remainingAmount) { // Condition 1: Full amount unpaid → paid up to actual end date $paidUpTo = $endDate; } else { // Condition 2: Partial amount paid, calculate months paid $billing_cycle = $transaction->billing_cycle == 'quarterly' ? 3 : 1; // Default to monthly if not set $monthlyRate = $invoiceAmount/$billing_cycle; // Example rate; change as per your logic $paidMonths = intval(($invoiceAmount - $remainingAmount) / $monthlyRate); if($transaction->billing_cycle == 'quarterly'){ $paidUpTo = $endDate->copy()->subMonths(3 - $paidMonths); // Assuming a 3-month quarter }else{ $paidUpTo = ''; // For monthly billing } } } @endphp
Receipt No. {{$transaction->hard_copy_receipt_number}}
Date {{\Carbon\Carbon::parse($transaction->transaction_date)->format(config('app_settings.date_format.value'))}}
Amount ({{config('app_settings.currency_symbol.value')}}) {{ \App\Models\Util::ConvertPrice($transaction->paid_amount) }} ({{ ucwords(strtolower(convertNumberToWords($transaction->paid_amount))) }} Only)
Received from @if ($transaction->owner_first_name) {{ ucwords(strtolower($transaction->owner_first_name)). ' '. ucwords(strtolower($transaction?->owner_last_name)) }}, @elseif ($transaction->property_owner_first_name) {{ ucwords(strtolower($transaction->property_owner_first_name)) . ' '. ucwords(strtolower($transaction?->property_owner_last_name)) }}, @else @endif {{ $transaction?->block_name }} - {{ $transaction?->house_number }}
Payment Method {{$transaction->payment_method}}
For Period(s) @if($transaction->amount == $transaction->invoice_amount) {{ \Carbon\Carbon::parse($transaction->end_date)->format('M, Y') }} @endif
For Period(s) @if($transaction->amount == $transaction->invoice_amount) {{ \Carbon\Carbon::parse($transaction->start_date)->format('M, Y') }} - {{ \Carbon\Carbon::parse($transaction->end_date)->format('M, Y') }} @endif
Paid up to {{ $paidUpTo ? $paidUpTo->format('M, Y') : '' }}
Invoice(s) Number: {{ $transaction->invoice_numbers }}

For: {{ $transaction->company_name ?? '' }}

{{-- --}}
@endforeach