Loans: record when the fixed period ends and project the balance then #5131
All Vouch review confidence checks passed
Residual risk 0.28 = Change Risk (0.52) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #5131"
general
weight: 0.35
nielseulink
Step 3.2 of #4955. Builds on #5130; until that one is merged, only 05bf5dc52 and ea71a04d6 belong to this pull request.
Problem
A mortgage's terms are fixed for a period: a Dutch fixed-rate period, a Canadian renewal term. What the borrower wants to know is how much they will still owe when that period ends. Sure has no place for that date, and a payment the lender has already announced for a later date cannot be recorded until the day it takes effect.
What changes
get_accountsreports it asfixed_until.Known limits
Migration
Adds
loan_term_changes.term_end_dateand replaces the check constraintchk_loan_term_changes_has_amountwithchk_loan_term_changes_records_something(an amount or an end date), pluschk_loan_term_changes_term_ends_after_start. No backfill. Rolling back deletes rows that record only an end date, because the old constraint cannot hold them.Validation
bin/rails test, withmain(627fbfa39) merged through #5130: 19,439 runs, 0 failures.test/system/loan_term_changes_test.rbcovers the form field, the card and the marker.<!-- This is an auto-generated description by cubic. -->
---
Summary by cubic
Loans can now record changes the lender makes or announces — extra repayments, confirmed balances, new payments, and how long the current terms stay fixed. The recorded changes shape the amortization schedule, and a loan with any of them quotes the repayment in force, as on a variable loan; the balance chart also labels the schedule "Current schedule" once terms change.
get_accountscarry the date asfixed_until; imported term changes are validated against the schedule, and in a chunked import they wait for the next form save.Migration
Adds
loan_term_changes.term_end_dateand replaces the check constraint with one that accepts an amount or an end date. Rolling back deletes rows that record only an end date.<sup>Written for commit 3237dcbfeba8c508d9ecdce21f42edd34eae00c6. Summary will update on new commits.</sup>
<a href="https://cubic.dev/pr/we-promise/sure/pull/5131?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->
Summary by CodeRabbit
New Features
Record dated loan changes, including extra repayments, confirmed balances, updated payments, and fixed-term end dates.
See how recorded changes affect projected payments, balances, interest, and payoff dates. Fixed-term end dates and projected balances appear on the loan overview and payoff chart.
Loan data exports and imports preserve recorded term changes.
Improvements
Invalid changes are flagged when they conflict with the loan’s dates, schedule, or interest requirements.
* Loan schedules show balance adjustments, and total cost is displayed as unknown when the loan is projected to retain a balance after its final payment.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Screenshots
The balance chart marks the end of the fixed period, and the Overview tab shows the projected balance on that day.
!Chart marker and the Balance at End of Fixed Period card
The loan form: a row dated on the origination date with only a fixed-until date records the period the loan opened with.
!The Fixed until field on a term change row