@php use App\Services\LoanInstallmentCalculator; use App\Support\FundLoanSettings; use App\Support\LoanCalculationMethod; $fundSettings = $fundSettings ?? null; $method = FundLoanSettings::loanCalculationMethod($fundSettings); $rate = FundLoanSettings::loanAnnualInterestRate($fundSettings); $period = (int) ($loan->loan_period_months ?? 0); $principal = (float) ($loan->principal ?? 0); $schedule = []; $totalInterest = 0.0; if ($period > 0 && $principal > 0) { $schedule = app(LoanInstallmentCalculator::class)->buildSchedule($principal, $period, $method, $rate); $totalInterest = array_sum(array_column($schedule, 'interest')); } @endphp @if(count($schedule) > 0)
@if(LoanCalculationMethod::isAmortization($method)) {{ __('Scheduled payment') }}: {{ number_format($schedule[0]['payment'] ?? 0, 2) }} · {{ __('Total interest') }}: {{ number_format($totalInterest, 2) }} · {{ __('Annual rate') }}: {{ number_format($rate, 3) }}% @else {{ __('Equal principal per month') }}: {{ number_format($schedule[0]['payment'] ?? 0, 2) }} @endif
@foreach($schedule as $row) @endforeach
# {{ __('Payment') }} {{ __('Principal') }} {{ __('Interest') }} {{ __('Ending balance') }}
{{ $row['installment_no'] }} {{ number_format($row['payment'], 2) }} {{ number_format($row['principal'], 2) }} {{ number_format($row['interest'], 2) }} {{ number_format($row['ending_balance'], 2) }}
@endif