Accrue card statement interest daily instead of APR/12 #5986
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 #5986"
general
weight: 0.35
jaysbeekay
Part of #5444
Fork pre-flight: jaysbeekay/sure#1006 (same commits)
Bottom of the credit-card stack, based on
main.Verified on the stack's top commit 6f85ab855 (
up/card-next-statement, with currentmainmerged in at the bottom and each slice merged up the chain): full unit suite19760 runs, 0 failures, 8 errors, 9 skips(the 8 areReleaseNotesWorkflowTest, nonodein the test container); the card system testcredit_card_limit_chart_test8 runs, 0 failures.Summary
The card Overview's "Estimated interest" was the remaining statement balance times APR/12. It is now the interest the open cycle has accrued so far, from the account's daily balance records, at the card's daily periodic rate. Cards get an interest basis (actual/365 by default, or actual/360) on the existing edit form.
Day rules, as settled in the issue's revised Triage Plan:
statement_paid_by_due_date?;statement_settled?is untouched); a payment after the due date does not restore grace;statement_settled?.A balance update (valuation) that lowers the balance counts from its own day, not the day after: it states what is owed on that date and has no inflow on its balance record. A test pins it (1,000 then 500 from 21 Sep: 12.33 at 18%; the next-day rule would give 12.58).
What changed
CreditCard#cycle_interest_money(last_close:, as_of:): the accrual, capped at the cycle's close.statement_summaryuses it forestimated_interest;estimated_monthly_interest_money(APR/12) is removed.monthly_rateand its "Monthly rate" row are unchanged.credit_cards.day_count_convention(string, defaultactual_365, check constraint), validated againstCreditCard::DAY_COUNT_BASES; select on the card form; permitted inCreditCardsController; kept through export/import (Family::DataImporter::CREDIT_CARD_DETAIL_ATTRIBUTES).CreditCardsHelper#credit_card_interest_if_unpaid: the line says what missing the due date costs: "$2.37 if not paid in full by Dec 14, 2026" (the closed statement's due date), "$2.37, not paid in full by Dec 14, 2026" once that date has passed, and "$2.37 if the statement is not paid in full" for a card without a due day; a zero figure, where grace applies, is shown bare. The three keys are translated in en, de, es, fr, id, nb, nl and zh-CN (the locales that translate the label);per_monthis removed from them.cycle_gracereturns grace, residual, accruing or unknown, and bothcycle_interest_moneyand the summary use it.StatementSummary#residual_interestfeeds the helper, which shows "$5.92, residual interest from an earlier statement not paid in full" (new keyinterest_residualin en and the 8 locales that translate its neighbours).balance_records_behind?runs before the grace check.Loan::AmortizationMathis not touched: itsaccrual_factorhas no actual/360 branch (falls through to actual/actual), and open upstream PR we-promise/sure#5212 edits that file. The daily rate is APR / 365 or 360, which is all the card needs.Tests (red on upstream main, green on this branch)
test/models/credit_card_test.rbactual_365,actual_360valid,thirty_360rejectedtest/controllers/credit_cards_controller_test.rb: form renders the basis select (witharia-describedbyhint) and savesactual_360;thirty_360is a 422 and the stored basis is unchanged.test/controllers/accounts_controller_test.rb: Overview shows "$2.37 if not paid in full by Oct 26, 2026" (was "$12.00/month"); after a late payment it shows "$7.10, not paid in full by Oct 26, 2026", the closed statement's due date, though the tab's own due date has moved to 26 Nov.test/helpers/credit_cards_helper_test.rb(new): each wording, a zero figure shown bare, unknown.test/i18n_test.rb#test_card_interest_lines_exist_beside_the_interest_label(new): every locale that translatesestimated_interest_labelcarries the three forms with English's placeholders; failed before withen: credit_cards.tabs.overview.interest_if_not_paid_by is missing.test/models/credit_card_test.rb: a balance update that lowers the balance counts from its own day → 12.33.test/models/family/data_importer_test.rb: the basis round-trips through full export/import.Added after the approval (0a05b499a), each red first:
interest_residualMutations (each applied alone, targeted files re-run; every one caught)
| # | Mutation | Caught by |
|---|---|---|
| M1 | payment counts on its posting day | worked example, actual/360, day late, day in credit |
| M2a | recorded day in credit nets | day in credit |
| M2b | carried day in credit nets | day in credit |
| M3 | purchases from the next day (start-of-day balance) | purchase from its date, day late |
| M4 | grace ignores the due date | day late, day in credit |
| M5 | no grace at all | paid on due date, no-balance statement |
| M6 | actual/360 divides by 365 | actual/360 |
| M7 | no cap at the cycle close | stops at its close |
| M8 | summary keeps APR/12 | 5 summary/Overview tests |
| M9 | basis not validated | default/list test, 422 test |
| M10 | basis not permitted | form save, 422 test |
| M11 | basis dropped on import | round trip |
| M12 | foreign entries not refused | foreign-currency test |
| M13 | rounds to 2 places regardless of currency | KWD test |
| M14 | zero figure gets the wording | helper: zero shown bare |
| M15 | due day itself treated as passed | helper: due today |
| M16 | undated form removed | helper: no due date |
| M17 | Overview dated by
summary.due_date| late-payment Overview test || M18 | a de key dropped | i18n interest lines |
| M19 | lowering balance update counts from the next day | balance update test |
| M20 | unknown not handled | helper: unknown |
| M21 | the earlier statement not checked (
paidalone) | carried-statement test || M22 | the earlier statement read at the last close instead | carried, summary-flag and Overview tests |
| M23 | an unreadable earlier statement counts as carried | unreadable-earlier test |
| M24 | residual whenever not in grace | summary-flag test (accruing case), 2 Overview tests |
| M25 | residual flag or its helper/view wiring dropped | summary-flag, helper and Overview tests |
| M26 | stale check removed, or limited to the cycle | the three stale tests |
| M27 | same-day due pushed to next month | due-on-close-day test |
Verification
19462 runs, 117098 assertions, 0 failures, 8 errors, 9 skips— the 8 errors areReleaseNotesWorkflowTest(nonodein the container), environment noise.19498 runs, 117206 assertions, 0 failures, 8 errors, 9 skips(the same 8). Targeted card, helper, controller and I18n tests: 309 runs, 0 failures.config/locales/views/credit_cards/pt-BR.ymlwithout the three interest lines, so the new I18n test failed on the merge (pt-BR: credit_cards.tabs.overview.interest_if_not_paid_by is missing, and likewiseinterest_not_paid_byandinterest_if_not_paid). 71d3ff766 adds the three pt-BR lines with English's placeholders, and dropsper_monthfrom pt-BR as from every other locale (nothing reads it). Full unit suite on 71d3ff766:19487 runs, 117189 assertions, 0 failures, 8 errors, 9 skips(the same 8ReleaseNotesWorkflowTesterrors), andaccounts_test.rbplusaccount_activity_test.rbgive 26 runs, 0 failures. Upstream changed nothing on the card pages between e0d9c9c16 and 12cd4e1a5, so the screenshots below still show this branch's behaviour.bin/rubocop(10 changed Ruby files): no offenses.erb_lint(2 ERB files): no errors.bin/brakeman: 0 warnings. No JS changed.db:migratefrom upstream main's schema adds the column andchk_credit_cards_day_count_convention;db:rollbackremoves both (verified in a container).db/schema.rbkeeps the file's alphabetical column order and constraint formatting.Migration notes
credit_cards.day_count_convention(string,NOT NULL, default'actual_365') and check constraintchk_credit_cards_day_count_convention(actual_365,actual_360). Existing rows take the default; nothing to backfill or run after deploy.db:rollbackdrops the constraint and the column.Screenshots
Before = upstream main e0d9c9c16, after = this branch; same data (18% APR, $700 carried, partly paid, due today). The Overview's "$10.50/month" becomes "$7.61 if not paid in full by Nov 26, 2026"; the form gains Interest basis. Overview "after" images retaken on ba3f335d4.
| View | Before | After |
|---|---|---|
| Overview — estimated interest, light, desktop | !before | !after |
| Overview — estimated interest, light, phone | !before | !after |
| Overview — estimated interest, dark, desktop | !before | !after |
| Overview — estimated interest, dark, phone | !before | !after |
| Edit form — interest basis, light, desktop | !before | !after |
| Edit form — interest basis, light, phone | !before | !after |
| Edit form — interest basis, dark, desktop | !before | !after |
| Edit form — interest basis, dark, phone | !before | !after |
Blast radius
CreditCard#statement_summary→estimated_interest: read only bycredit_cards/tabs/_overview.html.erb(grepestimated_interestin app/). The other summary members are unchanged.statement_settled?/next_payment_due_date: unchanged; grace uses its own predicate.Loan::AmortizationMathand every loan schedule: untouched.Family::DataImporter::CREDIT_CARD_DETAIL_ATTRIBUTES: one attribute added; older exports without it keep the column default (existing "without their details" test still green).Overlap with we-promise/sure#5271 (annual fees, open)
git merge-treeof this branch with #5271's's head (49db1a05) auto-mergescredit_card.rb, the controller,_form.html.erb,_overview.html.erb,en.ymland the tests. Two textual conflicts, both rebase-only:db/schema.rb: the version line and thecredit_cardsblock (both add columns and a check constraint) — regenerate.Family::DataImporter::CREDIT_CARD_DETAIL_ATTRIBUTES: both append to the same one-line list — keep both attributes.Neither change needs the other's code.
Decisions (2026-11-26)
statement_settled?does.up/card-daily-rate).<!-- This is an auto-generated description by cubic. -->
---
Summary by cubic
Accrues credit card statement interest daily from balance records instead of applying APR/12 to the remaining balance, so the Overview's "Estimated interest" now reflects the actual cycle and payment timing. Cards gain a
day_count_conventionfield (actual/365 or actual/360) set on the edit form and preserved through export/import. The Overview label explains what the figure would cost if the statement is not paid in full by its due date, and grace (zero interest) applies only when the previous statement and the one before it were each paid in full by their due dates; residual interest after a carried statement is labeled as such. The wording is inclusive of the due date itself — a payment on that day counts — consistently across all translated locales. Interest is unknown when balance records are behind the entries.Migration
credit_cards.day_count_convention(string, defaultactual_365) with a check constraint; existing rows take the default, reversible viadb:rollback.<sup>Written for commit 971b70c99938e42aa40711a43e3c0c72484e6658. Summary will update on new commits.</sup>
<a href="https://cubic.dev/pr/we-promise/sure/pull/5986?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> <a href="https://www.cubic.dev/action/auto-fix/pr/we-promise/sure/5986?returnTo=https%3A%2F%2Fgithub.com%2Fwe-promise%2Fsure%2Fpull%2F5986&source=description" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img alt="Turn on auto-fix" src="https://www.cubic.dev/buttons/turn-on-auto-fix-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
Choose Actual/365 or Actual/360 as the basis for calculating credit-card interest. The selection is saved with the card and retained when card details are imported.
Improvements
Credit-card interest estimates now reflect daily balances and statement-cycle activity rather than a monthly estimate.
The overview shows estimated interest with context about payment due dates, overdue statements, and residual interest from earlier statements.
Interest estimates are shown as unknown when the available information is insufficient to calculate them.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->