Record what the fork's loan engine produces before #184 begins
Summary
Phase 0 of #184's triage plan (comment 5917157550): record what the fork's loan engine produces today, before any of the reconciliation onto upstream's engine begins. Each later phase runs against these files. A figure it moves fails the test and names the first path that changed, so every movement is either zero or named and explained in that phase's PR.
This PR adds tests and fixtures only. No application code changes.
What is recorded
test/models/loan/golden_master_test.rb builds nine loans at 300,000, 6% and 360 months unless stated otherwise, with an opening valuation of 300,000 and a current balance of 285,000. Time is frozen at 2027-01-15, because the fork's projection reads Date.current internally.
| Scenario | What it exercises |
|---|---|
fixed | the baseline |
variable_change_on_payment_date | a rate change effective on a payment date. The fork answers "not applicable" for its projection, and that is recorded as today's behaviour |
variable_change_mid_period | two changes inside periods (6 → 7.5 → 5.25) |
offset | a 50,000 offset account. The minimum payment falls to 1,466.37 |
actual_actual | the other day-count convention |
leap_february_start | a 29 February start |
month_end_start | a 31 January start |
matured | a 12-month loan now past maturity: no projection, no minimum payment |
initial_balance_differs_from_first_valuation | initial_balance 320,000 against a 300,000 opening valuation. The fork sizes from the valuation, so this matches fixed. Upstream's original_balance prefers initial_balance, so this is the figure phase 2 is expected to move |
For each loan, one JSON file under test/fixtures/files/loan_golden_master/ holds:
- every schedule row, with its monthly payment, total interest and payoff date;
- the projection: whether it applies, its payment, payoff date, total interest, whether it converges, and every row;
current_minimum_payment(as_of:);- the payment
RetirementPlan#seed_loansreads.
About 1.5 MB in total, kept readable so a phase's diff shows exactly which rows moved.
To regenerate, only when a phase is meant to move a figure: LOAN_GOLDEN_MASTER_WRITE=1 bin/rails test test/models/loan/golden_master_test.rb. Every changed line then has to be explained in that PR.
Validation
- The harness passes on the recorded files: 9 runs, 18 assertions.
- Changing one recorded figure by a cent fails it, and names the path:
fixed moved; first difference at $.schedule.rows[100].interest_payment ("1332.36" -> "1332.35"). - An engine change fails it: rounding the level payment down instead of to the nearest cent fails 4 of the 9 scenarios, each naming the first figure that moved. For example:
offset moved; first difference at $.current_minimum_payment ("1466.37 USD" -> "1466.36 USD"). In the other five, the rounding happens to land on the same cent. - The fork's loan and retirement-plan tests, harness included: 268 runs, 2,714 assertions, 0 failures.
bin/rubocopon the new test: no offenses.
Refs #184.