@extends('admin.admin_dashboard') @section('customcss') @endsection @section('admin')
{{-- ১ম অংশ: Invoice No --}}
Invoice No: {{ $payment->invoice_no }}
{{-- ২য় অংশ: Receipt Information --}}
Receipt Information
{{-- safe defaults with null-coalesce --}} @if ($totalWaver!=0 || $totalWaver!=null) @else @endif {{-- controller supplies $totalPaid (not $totalPaidThisTxn) --}} {{-- previous adjustments (if controller passed it) --}}
Invoice No Student Name Received By Date Total Discount Adjusted Paid Previous Due Collection Due
{{ $payment->invoice_no }} {{ $payment->student->student_name_english }} {{ $payment->user?->name ?? 'N/A' }} {{ \Carbon\Carbon::parse($payment->payment_date)->format('d-m-Y') }}{{ number_format($totalFee ?? 0) }}{{ number_format($totalWaver ?? 0) }}{{ number_format($totalAdjusted ?? 0) }}{{ number_format($totalPaid ?? 0) }} @if ($previousPaidAdjustments!=0 || $previousPaidAdjustments!=null) {{ number_format($previousPaidAdjustments ?? 0) }} @else @endif @if ($totalDueAfter!=0 || $totalDueAfter!=null) {{ number_format($totalDueAfter ?? 0) }} @else @endif
{{-- ৩য় অংশ: Receipt Detail Information --}}
Receipt Detail Information
@foreach($items as $item) @php // ensure fields exist (controller should provide effective_payable & paid_this_txn) $feeAmount = $item->fee_amount ?? ($item->fee->amount ?? 0); $waver = $item->waver ?? ($item->fee->waver_amount ?? 0); $paidThis = $item->paid_this_txn ?? 0; $effectivePayable = $item->effective_payable ?? max(0, $feeAmount - $waver); // total paid up to and including this invoice for this fee (same logic as printReceipt) $totalPaidBefore = \App\Models\PaymentItem::where('fee_id', $item->fee->id) ->where('payment_id', '<=', $payment->id) ->sum('payment_amount_orginal'); // due after considering all payments up-to-current-invoice $dueAfter = max(0, $effectivePayable - $totalPaidBefore); @endphp @if ($item->item_due == null || $item->item_due == 0 ) @endif @endforeach @if ($isCollectDue !=0) @endif {{-- safe defaults with null-coalesce --}} @if ($totalWaver!=0 || $totalWaver!=null) @else @endif
Fee Remarks Fee Type Fee Amount Discount Paid This Invoice Due After This Payment
{{ $item->fee->note ?? '-' }} {{ $item->fee->fee_type ?? '-' }} {{ number_format($feeAmount) }} {{ number_format($waver) }} {{ number_format($paidThis) }} {{ number_format($dueAfter) }}
Due Collection
(This Item has been generated on the previous dues against Receipt: {{ $previousCombined }})
{{$previousPaidAdjustments ?? ''}} {{ $totalDueAfter ?? '' }}
Total{{ number_format($totalFee ?? 0) }}{{ number_format($totalWaver ?? 0) }}0{{ number_format($totalPaid ?? 0) }} @if ($totalDueAfter!=0 || $totalDueAfter!=null) {{ number_format($totalDueAfter ?? 0) }} @else 0 @endif
@endsection