@php $student = $fee->student; $academy = $student->academy ?? \App\Models\Academy::find($fee->academy_id); $parent = $student->primaryParent ?? null; $currency = $academy->currency ?? 'Rs.'; $rno = isset($receipt) ? $receipt->receipt_number : $fee->receipt_number ?? 'N/A'; $rDate = isset($receipt) ? $receipt->paid_date : $fee->paid_date; $rAmount = isset($receipt) ? (float) $receipt->amount : (float) $fee->paid_amount; $rMethod = isset($receipt) ? $receipt->payment_method : $fee->payment_method ?? null; $rNotes = isset($receipt) ? $receipt->notes : $fee->notes; $prevPaid = isset($receipt) ? max(0, (float) $fee->paid_amount - (float) $receipt->amount) : 0; $balance = max(0, (float) $fee->amount - (float) $fee->paid_amount); // Arrears breakdown $arrears = (float) ($fee->arrears ?? 0); $baseFee = (float) $fee->amount - $arrears; $prevPeriod = $arrears > 0 ? \Carbon\Carbon::createFromDate($fee->year, $fee->month, 1)->subMonth()->format('F Y') : null; // Allocate this receipt's payment: arrears first, then current month $arrearsPaidPrev = min($prevPaid, $arrears); $remainingArrears = max(0, $arrears - $arrearsPaidPrev); $thisArrearsPaid = min($rAmount, $remainingArrears); $thisCurrentPaid = max(0, $rAmount - $thisArrearsPaid); $brandColor = $academy->brand_color ?? '{{ $brandColor }}'; $academyLogoPath = $academy->logo ? storage_path('app/public/' . $academy->logo) : null; $academyLogo64 = ($academyLogoPath && file_exists($academyLogoPath)) ? 'data:image/' . pathinfo($academyLogoPath, PATHINFO_EXTENSION) . ';base64,' . base64_encode(file_get_contents($academyLogoPath)) : null; $exePath = public_path('exesync-wordmark-black.png'); $exe64 = file_exists($exePath) ? 'data:image/png;base64,' . base64_encode(file_get_contents($exePath)) : null; $dateStr = $rDate ? \Carbon\Carbon::parse($rDate)->format('d M Y') : now()->format('d M Y'); $period = \Carbon\Carbon::createFromDate($fee->year, $fee->month, 1)->format('F Y'); // QR code for member portal $qrBase64 = null; if ($student->portal_token) { try { $portalUrl = rtrim(env('FRONTEND_URL', 'https://ironcore.com'), '/') . '/portal/' . $student->portal_token; $qrSvg = \SimpleSoftwareIO\QrCode\Facades\QrCode::format('svg')->size(90)->margin(1)->generate($portalUrl); $qrBase64 = 'data:image/svg+xml;base64,' . base64_encode($qrSvg); } catch (\Exception $e) { $qrBase64 = null; } } @endphp
| Description | Amount ({{ $currency }}) |
|---|---|
| Arrears from {{ $prevPeriod }} | {{ number_format($arrears, 0) }} |
| Monthly Tuition Fee — {{ $period }} | {{ number_format($baseFee, 0) }} |
| Total Due | {{ number_format($fee->amount, 0) }} |
| Monthly Tuition Fee — {{ $period }} | {{ number_format($fee->amount, 0) }} |
| Previously Paid | - {{ number_format($prevPaid, 0) }} |
| Applied to Arrears @if ($rMethod) ({{ ucfirst($rMethod) }}) @endif | - {{ number_format($thisArrearsPaid, 0) }} |
| Applied to {{ $period }} | - {{ number_format($thisCurrentPaid, 0) }} |
| This Payment @if ($rMethod) ({{ ucfirst($rMethod) }}) @endif | - {{ number_format($rAmount, 0) }} |