@if($sale->type == 'installment') @php $installmentNo = (int) $sale->installment_no; $totalAmount = (float) $sale->total - $sale->received; $installmentAmount = $installmentNo > 0 ? ($totalAmount / $installmentNo) : 0; $startDate = \Carbon\Carbon::parse($sale->installment_date)->startOfDay(); // total paid from ledgers $totalPaid = $saleLedger->sum('amount'); $remainingAmount = $totalAmount - $totalPaid; // We'll consume ledger payments month by month $ledgerIndex = 0; $ledgerList = $saleLedger->values(); @endphp
| Sr | Month | Due Date | Installment Amount | Paid Date | Paid | Pending | Remaining |
|---|---|---|---|---|---|---|---|
| {{ $i+1 }} | {{ $dueDate->format('F Y') }} | {{ $dueDate->format('d M Y') }} | {{ number_format($rowDue, 2) }} | {{ $paidDate ? \Carbon\Carbon::parse($paidDate)->format('d M Y') : '' }} | {{ number_format($paidThisMonth, 2) }} | {{ number_format($pending, 2) }} | {{ number_format($runningRemaining, 2) }} |
| Total | {{ number_format($totalAmount, 2) }} | {{ number_format($totalPaid, 2) }} | {{ number_format($totalAmount - $totalPaid, 2) }} | {{ number_format($totalAmount - $totalPaid, 2) }} | |||