Show what each scheduled payment is made of in the loan chart tooltip
Closes #3958.
Fork pre-flight: jaysbeekay/sure#305, same branch, same commit (200bf682b). Its CI, review and test history is there.
Before: hovering the loan balance chart shows the scheduled balance for a date, but not how that month's payment divides between principal and interest.
After: on a scheduled payment, the tooltip adds a line under the scheduled balance, for example "Principal: $497.75 · Interest: $2,500.00" for the first payment on a $500,000, 6%, 30-year mortgage. The split is shown at the currency's own precision, as the Schedule tab shows it. The balance rows stay in whole units. The opening point (the amount borrowed) and the projected and recorded lines show no split.
How: Loan::PayoffChart#scheduled_series now carries principal and interest from the schedule's own Payment rows, the same rows it already reads for the balance. The labels reuse loans.tabs.schedule.principal and .interest, the Schedule table's column names. The payload also carries currency_precision (Money::Currency.new(currency).default_precision || 2), because Intl's default can differ from the app's. The controller renders the row only when a point has both fields. No new query, model or component.
Screenshot
Taken at 8effde2 from the system test's fixture loan ($500,000 at 6% over 24 months), on its first scheduled payment.
| Light | Dark |
|---|---|
![]() | ![]() |
Blast radius
payload[:scheduled] is read only by loan_payoff_chart_controller.js (series points and keyboard stops). #series is shared with the projection and is left unchanged, so the projection carries no split, and a test pins that. currency_precision is a new key, read only by the split formatter.
Tests
The tests were written first. Each new model test that checks for the split or the precision failed before the change, for the expected reason (nil). The negative test is the guard.
each scheduled payment point carries the payment's principal and interest: matches the schedule rows and adds up to the payment.the split on a long loan is interest-heavy at the start and principal-heavy at the endthe opening point, the projection and the recorded balance carry no splitthe payload labels the split with the schedule table's own wordsthe payload carries the loan currency's precision for the split(USD 2, JPY 0)- System:
the tooltip splits a scheduled payment into principal and interest. It checks there is no split at origination, the first payment's figures to the cent, and the balance still in whole units.
Each of these deliberate breakages was caught:
| Breakage | Caught by |
|---|---|
| Tooltip never renders the split row | system test |
toPoint drops principal | system test |
| Opening point carries a split | negative model test |
| Projection carries a split | negative model test |
| Principal and interest swapped | 2 model tests |
| Split uses the whole-unit balance formatter | system test |
| Split formatter drops the minimum fraction digits | system test |
| Precision hard-coded to 2 | precision model test |
Validation
test/models/loan/payoff_chart_test.rb: 28 runs, 0 failures.test/system/loan_payoff_chart_test.rb: 7 runs, 0 failures.- Full suite: no failures beyond five provider tests (
Provider::OpenaiTest,Provider::RegistryTest,Settings::HostingsControllerTest) that fail the same way onmainlocally. - RuboCop and Brakeman are clean, and
npm run lintis clean. - No migration, no new dependency, strings through
t().
Rebased onto main (6 Oct)
Rebased onto main at ea38fa6a3; the commits carry the same changes under new SHAs. SHAs elsewhere in this description refer to the commits as they were before.
69ae6b0bb→d59130c68Show what each scheduled payment is made of in the loan chart tooltip8effde2b2→200bf682bShow the loan chart's principal/interest split to the cent
bin/rails test on 200bf682b: 10,582 runs, 45,112 assertions, 0 failures, 0 errors, 33 skips. Loan and account system tests: 17 runs, 0 failures. bin/rubocop on the changed files: no offenses.
Summary by CodeRabbit
- New Features
- Payoff chart tooltips now show the principal and interest portions of scheduled payments alongside the ending balance.
- Payment amounts use the loan currency’s configured precision, defaulting to two decimal places; ending balances retain their existing formatting.
- The opening loan amount and other points without a principal-and-interest split continue to display without one. Principal and interest labels are localized.

