Prefer the available balance for Enable Banking cards treated as available credit #4277
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.39) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 255 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 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.332
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #4277"
general
weight: 0.35
jjmata
Fixes #4267.
With Balance is available credit turned on, the Enable Banking importer still chose the balance with
BALANCE_TYPE_PRIORITY, which puts booked types first. Some cards report the credit limit as the booked balance and the available credit as the available balance: for the mBank (PL) card in the issue,ITBD= 11 500 (the limit) andITAV= 4 531.68. The importer stored 11 500, and with an 11 500 limit the card showed 0 debt. Because the current-balance anchor was wrong, the history was shifted too.The toggle already says the bank's figure is the available credit, so for those accounts
select_current_balancenow usesAVAILABLE_CREDIT_BALANCE_TYPE_PRIORITY:CLAV,ITAV,XPCDfirst, then the booked types as a fallback for banks that only send a booked balance. Every other account keeps booked-first, so the overdraft concern in the existing comment still holds there. The debt is thenlimit − ITAV= 6 968.32, as the issue expects.Validation:
test/models/enable_banking_item/importer_balance_test.rb:- with the toggle on and
ITBD+ITAV,ITAVis stored (onmain,ITBDis stored: 11500);- with the toggle on and only a booked balance, that one is still used.
- The existing "prefers booked balance before available balance" test covers the default.
test/models+test/controllers/enable_banking_items_controller_test.rb: 7762 runs, 0 failures, 0 errors (5 skips). Rubocop is clean.🤖 Generated with Claude Code
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
Summary by CodeRabbit
- Credit card accounts configured to use available credit now prefer available balance information when calculating the current balance, falling back to the booked balance when no available amount is reported.
- Other account types continue to prioritize the booked balance, even when configured to use available credit.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->