← Back to Pull requests

Prefer the available balance for Enable Banking cards treated as available credit #4277

Closed
unknown closed this pull request without merging on Oct 17, 2026 18:13 UTC
View on GitHub
unknown unknown commented on Oct 17, 2026 00:28 UTC
Author

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) and ITAV = 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_balance now uses AVAILABLE_CREDIT_BALANCE_TYPE_PRIORITY: CLAV, ITAV, XPCD first, 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 then limit − ITAV = 6 968.32, as the issue expects.

Validation:

  • New tests in test/models/enable_banking_item/importer_balance_test.rb:

  • - with the toggle on and ITBD + ITAV, ITAV is stored (on main, ITBD is 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

  • Bug Fixes

  • - 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 -->

    Diff: 255 lines (+191 / -64) across 3 files Reviewer: jjmata Review duration: 1064m
    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
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 39.1% (MEDIUM) · Higher = larger blast radius
    39.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 16.9% · Safe to merge
    16.9%