-
Notifications
You must be signed in to change notification settings - Fork 88
feat(loans): native amortization schedule for fixed-rate loans (#1804) #1887
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
c00a8f8
c5e1463
8c60092
0783cbc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,8 +42,60 @@ | |
| <%= summary_card title: t(".type") do %> | ||
| <%= account.loan.rate_type&.titleize || t(".unknown") %> | ||
| <% end %> | ||
|
|
||
| <%= summary_card title: t(".total_interest") do %> | ||
| <% if account.loan.total_interest.present? %> | ||
| <%= format_money(account.loan.total_interest) %> | ||
| <% else %> | ||
| <%= t(".unknown") %> | ||
| <% end %> | ||
| <% end %> | ||
|
|
||
| <%= summary_card title: t(".payoff_date") do %> | ||
| <% if account.loan.payoff_date.present? %> | ||
| <%= I18n.l(account.loan.payoff_date, format: :long) %> | ||
| <% else %> | ||
| <%= t(".unknown") %> | ||
| <% end %> | ||
| <% end %> | ||
| </div> | ||
|
|
||
| <% schedule = account.loan.amortization_schedule %> | ||
| <% if schedule.any? %> | ||
| <details class="mt-6 rounded-lg border border-primary bg-container"> | ||
| <summary class="cursor-pointer select-none px-4 py-3 text-sm font-medium text-primary"> | ||
| <%= t(".amortization_schedule") %> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This view introduces a custom Useful? React with 👍 / 👎. |
||
| </summary> | ||
|
|
||
| <div class="overflow-x-auto border-t border-primary"> | ||
| <table class="min-w-full text-sm"> | ||
| <thead class="bg-surface"> | ||
| <tr class="text-left text-secondary"> | ||
| <th scope="col" class="px-4 py-2 font-medium"><%= t(".schedule.period") %></th> | ||
| <th scope="col" class="px-4 py-2 font-medium"><%= t(".schedule.payment_date") %></th> | ||
| <th scope="col" class="px-4 py-2 font-medium text-right"><%= t(".schedule.payment") %></th> | ||
| <th scope="col" class="px-4 py-2 font-medium text-right"><%= t(".schedule.principal") %></th> | ||
| <th scope="col" class="px-4 py-2 font-medium text-right"><%= t(".schedule.interest") %></th> | ||
| <th scope="col" class="px-4 py-2 font-medium text-right"><%= t(".schedule.ending_balance") %></th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| <% schedule.each do |row| %> | ||
| <tr class="border-t border-primary text-primary"> | ||
| <td class="px-4 py-2"><%= row[:period] %></td> | ||
| <td class="px-4 py-2"><%= I18n.l(row[:payment_date], format: :short) %></td> | ||
| <td class="px-4 py-2 text-right"><%= format_money(row[:payment]) %></td> | ||
| <td class="px-4 py-2 text-right"><%= format_money(row[:principal]) %></td> | ||
| <td class="px-4 py-2 text-right"><%= format_money(row[:interest]) %></td> | ||
| <td class="px-4 py-2 text-right"><%= format_money(row[:ending_balance]) %></td> | ||
| </tr> | ||
| <% end %> | ||
| </tbody> | ||
| </table> | ||
| </div> | ||
| </details> | ||
| <% end %> | ||
|
|
||
| <div class="flex justify-center py-8"> | ||
| <%= render DS::Link.new( | ||
| text: t(".edit_loan_details"), | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When rounding causes the balance to hit zero before the final term, the loop keeps emitting remaining periods with
$0payment/interest/principal instead of ending the schedule. Becausepayoff_dateis taken from the last row, this can push the reported payoff later than the actual payoff month (e.g., small principals with long terms, such asbalance=1000,interest_rate=9.4,term_months=360, reach zero at period 359 but still add period 360 as all zeros).Useful? React with 👍 / 👎.