@php use App\Services\LoanInstallmentCalculator; use App\Support\FundLoanSettings; use App\Support\LoanCalculationMethod; use App\Support\LoanServiceCharge; $paidCount = $loan->installments->where('status', 'paid')->count(); $totalInst = $loan->installments->count(); $today = \Carbon\Carbon::today(); $method = FundLoanSettings::loanCalculationMethod($fundSettings ?? null); $yearlyRate = FundLoanSettings::loanYearlyRate($fundSettings ?? null); $isAmortization = LoanCalculationMethod::isAmortization($method); $scheduleByNo = []; $scheduledPayment = 0.0; $totalScheduledInterest = 0.0; if ($isAmortization && (int) ($loan->loan_period_months ?? 0) > 0 && (float) ($loan->principal ?? 0) > 0) { foreach (app(LoanInstallmentCalculator::class)->buildSchedule( (float) $loan->principal, (int) $loan->loan_period_months, $method, $yearlyRate ) as $row) { $scheduleByNo[$row['installment_no']] = $row; $totalScheduledInterest += (float) $row['interest']; } $scheduledPayment = (float) ($scheduleByNo[1]['payment'] ?? 0); } $installmentsByNo = $loan->installments->keyBy('installment_no'); $readOnly = $readOnly ?? false; $showEmployeeRow = $showEmployeeRow ?? true; $repayRoute = $repayRoute ?? null; @endphp
{{ __('Interest applies when paid on/after the 16th of the due month; waived if paid by the 15th (only principal posted).') }}
| # | {{ __('Due') }} | {{ __('Payment') }} | {{ __('Principal') }} | {{ __('Interest') }} | {{ __('Cumulative Interest') }} | {{ __('Balance') }} | {{ __('Status') }} | {{ __('Paid on') }} | @unless($readOnly){{ __('Action') }} | @endunless
|---|---|---|---|---|---|---|---|---|---|
| {{ $no }} | {{ $dueLabel }} | {{ number_format((float) $scheduleRow['payment'], 2) }} | {{ number_format((float) $scheduleRow['principal'], 2) }} | {{ number_format((float) $scheduleRow['interest'], 2) }} | {{ number_format($cumulativeInterest, 2) }} | {{ number_format((float) $scheduleRow['ending_balance'], 2) }} | @if($inst) {{ $instStatus }} @else — @endif | {{ $inst?->paid_at?->format('Y-m-d') ?? '—' }} | @unless($readOnly)@if($repayRoute && $inst && $inst->status === 'pending' && (float) $loan->outstanding > 0) @else — @endif | @endunless
{{ __('Service charge applies when paid on/after the 16th of the due month; waived if paid by the 15th.') }}
| # | {{ __('Due') }} | {{ __('Principal') }} | {{ __('S/Charge') }} | {{ __('Total') }} | {{ __('Status') }} | {{ __('Paid on') }} | @unless($readOnly){{ __('Action') }} | @endunless
|---|---|---|---|---|---|---|---|
| {{ $inst->installment_no }} | {{ $dueLabel }} | {{ number_format((float) $inst->amount, 2) }} | {{ number_format($svcAmt, 2) }} | {{ number_format($totalDue, 2) }} | {{ $instStatus }} | {{ $inst->paid_at?->format('Y-m-d') ?? '—' }} | @unless($readOnly)@if($repayRoute && $inst->status === 'pending' && (float) $loan->outstanding > 0) @else — @endif | @endunless
{{ __('No installment schedule on this loan. Post a manual amount below.') }}
@else{{ __('No installment schedule on this loan yet.') }}
@endif