Work a card's minimum payment out from its statement balance #1024
All Vouch review confidence checks passed
Residual risk 0.42 = Change Risk (0.75) × (1 − Review Confidence (0.44)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.75 · 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
Sensitive Paths
sensitive_paths
0.075
Real PR Conversation Timeline
1 comments
"Review active on #1024"
general
weight: 0.35
jaysbeekay
Fixes jaysbeekay/sure#896
Upstream issue: we-promise/sure#5443
Upstream PR: not opened yet; same branch, same commit.
Stack: base
up/card-statement-cycle(jaysbeekay/sure#1023) ← jaysbeekay/sure#1022 ← jaysbeekay/sure#1021 ← jaysbeekay/sure#1020 ← jaysbeekay/sure#1006.Summary
A card's minimum payment can now be a rule: Minimum payment % and Minimum payment floor. The minimum on a statement is that share of its balance, truncated to the cent (as Bankwest prints it: all eight statements listed in jaysbeekay/sure#896 match), raised to the floor and never more than the balance. Without a percentage, the fixed
minimum_paymentworks exactly as before. On a Plaid-linked card, the minimum the bank reported for the current statement wins over the percentage and is shown as "Bank's minimum". The Overview's statement card shows the minimum, and the above-minimum warning, the shortfall check and the assistant'slast_statement_minimumall quote the same figure.minimum_paymentkeeps its stored meaning.What changed
CreditCard#minimum_payment_for(balance, as_of:): nil for a zero or credit balance; the fixed minimum without a percentage; otherwisemin(balance, max(floor || 0, truncate(balance × % / 100))), nil when that is 0 (the owner's decision: 0% with no floor is no minimum).provider_reported_minimum?(as_of:)holds. All of these must be true:- Plaid wrote the stored minimum, so its
plaidprovenance value equals it;- the minimum is unchanged since;
- the card is still Plaid-linked (legacy
plaid_accountor anAccountProvider);- Plaid's
last_statement_issue_dateis no earlier than the last close minus 4 days, or the card has no cycle.The bank's figure is capped at the statement balance, and a 0 is no minimum. When the statement balance is unknown, the bank's figure is shown as reported. A missing or unreadable issue date falls back to the percentage. The check is memoised per
as_ofand cleared onreload.StatementSummary#minimum.minimum_payment_shortfall?(as_of:, balance:)compares the balance withminimum_payment_for, and is false when the balance is unknown.minimum_payment_shortfall?takes the statement'sremaining:and is false when it is zero, and the Overview passessummary.remaining. A partly paid statement (some, but not all, of it paid since the close;StatementSummary#partly_paid?) instead names what is left: "$242.12 of this statement is still unpaid and is charged interest at this APR." (new keyunpaid_after_payment, in en and the 8 locales that translateabove_minimum, machine-translated). Owner decision 2026-11-29. Test "credit card overview has no minimum warning once the statement is paid" failed first withExpected /above the $44.84 minimum/ to not match.summary.minimum.PlaidAccount::Liabilities::CreditProcessor: the minimum goes throughenrich_attribute(:minimum_payment, …, source: "plaid", ignore_locks: true)instead of a plainupdate!. As before, Plaid's figure replaces a hand-typed one, and a nil from Plaid leaves the stored value alone. Theplaidprovenance row is recorded even when the value has not changed, so existing Plaid cards count. The card is restored and its errors cleared before the write, so a refused statement-cycle update neither blocks the minimum nor is logged as a refused minimum. A refused minimum is logged ("Plaid card minimum payment refused by the model").-
minimum_payment_floor≥ 0;-
minimum_payment≥ 0 and below 108. That is the decimal(10,2) column's range; a larger Plaid figure raised a numeric overflow and stopped the card's liability processing.Family::DataImporterdrops a negative floor or an out-of-range minimum instead of rolling back the whole import.GetAccounts#credit_card_terms:minimum_paymentis the stored figure, as before. The computed minimum on the last statement is a new key,last_statement_minimum, on percentage cards only (absent when nil), besideminimum_payment_percent/minimum_payment_floor. The description says what each key means, including Plaid's figure and the cap.Tests (red on #1023: 9 errors
unknown attribute 'minimum_payment_percent'/undefined method 'minimum_payment_for', 1 failure no form input)test/models/credit_card_test.rbsummary.minimum
$44.84 with a fixed $100 also set (no "$100.00 minimum"); fixed minimum → no minimum line, warning still "$25.00"; foreign-currency statement → "Unknown".accounts_controller_test.rb: statement card and warning both sayget_accounts_test.rb:last_statement_minimum44.84** with percent and floor reported, andminimum_paymentthe stored figure.Added after the Gatekeeper review (each failed first as noted):
credit_card_test.rb- "the minimum floor is not negative" (before: −0.01 valid) and "an existing card with a negative floor still saves other changes"
- "a minimum payment is not negative and fits its column", and "an existing card with a negative minimum payment still saves other changes"
- "on a Plaid-synced card the minimum Plaid reported wins over the percentage" (before: 44.84, expected 120)
- "a minimum typed by hand on a Plaid-linked card does not override the percentage" (before: 120)
- "Plaid's minimum is capped at the statement balance and a zero minimum is none" (before: 120, expected 50)
- "Plaid's minimum stands uncapped when the statement balance is unknown" (before: nil)
- "a minimum Plaid reported for an earlier statement gives way to the percentage" (issue dates 10 Oct, 5 Nov, 6 Nov at the edge)
- "a Plaid minimum without a readable statement date gives way to the percentage"
- "the statement summary and the shortfall judge Plaid's minimum on their own date"
- "the Plaid minimum check is worked out once per load"
- guards: "a card no longer linked to Plaid uses the percentage", "a Plaid-synced card with no reported minimum uses the percentage", "a card synced from a provider that reports no minimum keeps the percentage"
credit_processor_test.rb- "records the minimum it writes as Plaid's" (before: no
plaidrow)- "marks a minimum the card already holds as Plaid's" (before: nil)
- "a refused cycle update does not stop a new minimum" (before: the minimum stayed 90 and a refusal was logged)
- "a minimum beyond the column's range is logged as refused and the sync continues" (before:
PG::NumericValueOutOfRange)- "a minimum the card refuses is logged", "a refused cycle update is not logged as a refused minimum" and "replaces a minimum typed by hand and keeps it when Plaid sends none"
get_accounts_test.rb- "keeps a card's stored minimum when its percentage minimum cannot be worked out" (before: 0.0, expected 100)
- "reports no last statement minimum for a card without a percentage"
accounts_controller_test.rb- "credit card overview labels the minimum Plaid reported as the bank's" (before: translation missing)
- "credit card overview shows the bank's minimum when the statement is unknown" (before: "Minimum Unknown")
data_importer_test.rb: "imports a credit card without a minimum floor it would refuse" and "…without a minimum payment it would refuse" (before:RecordInvalid)credit_cards_controller_test.rb: the form hint is the one translated string, exactlycredit_cards_controller_test.rb: form renders and saves both.data_importer_test.rb: round trip.Mutations (each alone)
| # | Mutation | Caught by |
|---|---|---|
| M1 | round instead of truncate | eight-statement test |
| M2 | no floor | 3 tests |
| M3 | not capped at the balance | 15 → 15 |
| M4 | 0% no floor gives 0 | 0% test |
| M5 | credit balance gets a minimum | zero/credit test |
| M6 | shortfall keeps the fixed minimum | shortfall test |
| M7 | warning quotes the fixed minimum | Overview 44.84 |
| M8 | minimum line for fixed minimums | fixed-minimum Overview |
| M9 | no "Unknown" | unknown Overview |
| M10 | GetAccounts reports the fixed field | GetAccounts |
| M11 | percent up to 101 | 0–100 test |
| M12 | floor not permitted | form test |
| M13 | dropped from importer | round trip |
| M14 | summary.minimum is the fixed field | summary test |
| M15 | floor validation dropped, or run on every save | floor tests |
| M16 | minimum-payment range dropped, or run on every save | column-range and stored-row tests, processor overflow test |
| M17 | bank's minimum not capped, or a 0 kept | capped test |
| M18 | provenance value match,
plaidsource, or link check dropped | typed-by-hand, no-longer-linked tests || M19 | statement-date check or its 4-day tolerance dropped | earlier-statement test |
| M20 | a missing date counts as current, or the
Date::Errorrescue dropped | undated test || M21 |
as_ofnot passed by the summary or the shortfall | own-date test || M22 | memo removed, ignores
as_of, or survivesreload| once-per-load, earlier-statement, Plaid-wins tests || M23 | unknown-balance bank return removed, or the shortfall's nil guard | uncapped and Overview unknown tests |
| M24 | provenance write for an unchanged value removed | marks-already-held test |
| M25 |
restore_attributesorerrors.cleardropped before the write | refused-cycle tests || M26 |
ignore_locksdropped, or the nil guard | replaces-typed and keeps-when-none tests || M27 | Overview label always plain, or always "Bank's minimum" | the two Overview label tests |
| M28 | importer floor/minimum clamp removed, or applied to any value | importer tests, round trip |
Verification
19609 runs, 0 failures, 8 errors, 9 skips(8ReleaseNotesWorkflowTesterrors, nonode). 1d272d821 only adds jaysbeekay/sure#1023's one-line residual-flag fix; targeted card, Plaid, importer and assistant files:620 runs, 0 failures, 0 errors.accounts_test+credit_card_limit_chart_test: 15 runs, 0 failures.bin/rubocop: no offenses.erb_lint(2 files): no errors.bin/brakeman: 0 warnings.Screenshots
Same seeded card as #1023 (statement $1,813.38, fixed minimum $25), after: 2% with a $20 floor. The statement card shows Minimum $36.26 and the warning quotes it instead of $25.00. Before = #1023.
| View | Before | After |
|---|---|---|
| Overview — light, desktop | !before | !after |
| Overview — light, phone | !before | !after |
| Overview — dark, desktop | !before | !after |
| Overview — dark, phone | !before | !after |
| Edit form — light, desktop | !before | !after |
| Edit form — light, phone | !before | !after |
| Edit form — dark, desktop | !before | !after |
| Edit form — dark, phone | !before | !after |
After the Gatekeeper review fixes (fb3d8cd41):
| View | Light, desktop | Dark, desktop | Light, phone | Dark, phone |
|---|---|---|---|---|
| Form |  |  |  |  |
| Percent |  |  |  |  |
| Bank |  |  |  |  |
| Bank, balance unknown |  |  |  |  |
| Stale |  |  |  |  |
Migration notes
20261128120300_add_minimum_payment_rule_to_credit_cards:minimum_payment_percentdecimal(5,2) with a 0–100 check constraint,minimum_payment_floordecimal(10,2); both nullable, existing rows NULL (fixed minimum as before).Blast radius
minimum_payment_moneycallers: the warning (nowsummary.minimum) and nothing else in app code; it stays for the fixed case.minimum_payment_shortfall?callers: the Overview only.StatementSummaryis built only instatement_summary; the new member is appended, so no positional construction breaks.GetAccountsadds a statement read per card only when a percentage is set, plus a few queries for the Plaid check on those cards.terms.minimum_paymentkeeps its stored meaning; the computed figure is the newlast_statement_minimum.PlaidAccount::Liabilities::CreditProcessoris the only writer ofminimum_paymentfrom a provider; its sync behaviour is unchanged apart from the provenance row, the overflow refusal and the log.minimum_paymentin ~20 locales; the new keys fall back to English (the I18n test suite passes).