Enable Banking: support STET deferred-debit cards (OTHR purchases and negative ITAV balance) #6132
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 #6132"
general
weight: 0.35
jjmata
Fixes #6131
Summary
Support for French STET/BPCE deferred-debit credit cards (cartes à débit différé) via Enable Banking:
1. Fetch
OTHRrows onCreditCardaccounts when pending sync is on (Importer#fetch_and_store_transactions). A400/422means "not supported": it is recorded as aninfoprovider_sync_errordebug log entry and leaves the pending set complete, since thePDNGrows were fetched. The rows go through the existing pending pipeline and settle through theirentry_referenceonce booked.2. Cover a whole statement cycle. A purchase stays
OTHRuntil the monthly statement closes (up to 31 days), soEnableBankingEntry::Processor::DEFERRED_DEBIT_CYCLE_DAYS(45) sets:- the
OTHRrequest window, whatever the BOOK window: wider than a few-day incremental sync, and never as far back as an old sync start date, which could make the ASPSP reject thedate_fromwithout SCA (never before the user's sync start date either), with the post-fetch date filter applying the same bound toOTHRrows;- when such a purchase counts as stale: pending
OTHRentries are markedextra.enable_banking.deferred_debitandEnableBankingAccount::Processor#clean_up_pending_transactionsexcludes them after 45 days instead of 8. They are also left out of the amount-only duplicate reconciliation: a cycle doesn't follow the calendar month, so a purchase made just before a statement close can share its amount with an older purchase that close books, and they settle by their ownentry_referenceanyway. Other pending entries keep both rules (Entry.auto_exclude_stale_pendingandEntry.reconcile_pending_duplicatesgain an optionalentries:scope; default unchanged). For the same reason,Account::ProviderImportAdapter#find_pending_transactiondoesn't let a new booking of the same amount claim them: such a claim would also make the purchase's own BOOK row, which carries the same id, be skipped as already claimed.3. Date unbooked
OTHRrows bytransaction_dateinstead of the cycle's shared futurevalue_date, through one helper (EnableBankingEntry::Processor.raw_date_value) now used bytransaction_date,compute_external_id,Importer#build_transaction_content_key,#newest_stored_transaction_dateand#row_date. Without it, identical purchases made on different days of a cycle collapse indeduplicate_api_transactions.4. Keep identical same-day
OTHRpurchases apart:distinct_booked_reference?acceptsOTHRrows, whoseentry_referenceis stable until booking.5. Let a negative
CLAV/ITAVreplace a stalePRCD/OPBD/CLBDon a credit card read as debt (Importer#fresher_balance). The sign comes fromsigned_balance_amount, so both"-120.50"and"120.50"+DBITcount. Non-negative ones stay excluded, including from the same-day tiebreak, keeping the #5886 / mBank PL guard.Behaviour changes outside OTHR
transaction_date,newest_stored_transaction_dateand the post-fetch date filter now skip an empty-stringbooking_date/value_date(.presence, as the dedup key andcompute_external_idalready did) instead of raising onDate.parse("")or leaving the row unfiltered.Tests
importer_balance_test.rb: negativeITAV(signed amount andDBIT) replaces a stalePRCD;ITAV = 0.00does not; a same-day positiveITAVstays out of the tiebreak. The existing "keeps a stale closing booked balance on a credit card over a newer available balance" test (positiveITAV) still covers the mBank guard.importer_pdng_test.rb:OTHRrows stored as pending and not collapsed (same day and across the cycle); dropped once booked with the sameentry_reference;422onOTHRtolerated without marking the pending set incomplete, with aninfodebug log entry; a whole cycle requested and kept on an incremental sync; only one cycle requested when a first fetch reaches further back; noOTHRrequest on a depository account; blankbooking_datein the date filter.enable_banking_entry/processor_test.rb:OTHRrow dated bytransaction_date;BOOK/PDNGunchanged; pendingOTHRmarkeddeferred_debit,PDNGnot; a purchase settles in place when its statement books it under the sameentry_reference; a booking of the same amount doesn't claim it.enable_banking_account/processor_test.rb: a deferred-debit purchase stays pending within the cycle and is excluded after it; it is not reconciled against an earlier cycle's booking of the same amount, while an ordinary pending still is.importer_pending_balance_test.rb: default emptyOTHRpage in the shared stub for the existing credit-card cases.Validation
Run locally in the repo's devcontainer (Postgres 18, Redis):
bin/rails test test/models/enable_banking_item test/models/enable_banking_entry test/models/enable_banking_account test/models/enable_banking_account_test.rb test/models/entry_test.rb test/models/simplefin_item test/models/account/provider_import_adapter_test.rb: 784 runs, 0 failures, 0 errorsbin/rails test: 20314 runs, 0 failures, 0 errors, 9 skipsbin/rubocopon the changed files: no offensesbin/brakeman --no-pager: no warningsNo ERB, JavaScript or UI changes, so ERB lint, Biome and system tests don't apply.
Open questions
See #6131: pending-inclusive
ITAVon a liability, and the date jump at statement close.<!-- This is an auto-generated description by cubic. -->
---
Summary by cubic
Fixes #6131 by adding Enable Banking support for French STET/BPCE deferred-debit credit cards, making their purchases visible as pending entries and letting a negative available balance update the account.
OTHRtransactions on credit card accounts during pending sync over a whole statement cycle (45 days), independent of the BOOK window and never before the user's sync start date, and tolerates400/422responses without marking the pending set incomplete.OTHRrows bytransaction_daterather than the cycle's shared futurevalue_date, and keeps identical same-day purchases distinct viaentry_reference.OTHRentries asdeferred_debitso they stay pending for a full cycle instead of 8 days; they are also left out of amount-only reconciliation and the pending claim heuristic, since a statement close can book an earlier cycle's purchase of the same amount and otherwise hide them.CLAV/ITAVreplace a stalePRCD/OPBD/CLBDbalance on a credit card read as debt, fromsigned_balance_amount; non-negative available balances stay excluded to preserve the mBank PL guard.transaction_date,newest_stored_transaction_date, and the post-fetch date filter now skip empty-stringbooking_date/value_dateinstead of raising onDate.parse("").<sup>Written for commit 49e83dcc7a6a660c9ffff0e840e87d95c6460faf. Summary will update on new commits.</sup>
<a href="https://cubic.dev/pr/we-promise/sure/pull/6132?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>
<!-- 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
Credit-card imports now include eligible deferred-debit purchases as pending transactions, so card spending can appear before it is fully booked.
Deferred-debit purchases remain pending for up to 45 days.
Bug Fixes
Pending card transactions use a more appropriate date when booking details are unavailable.
Credit-card balances update more reliably: negative available balances can replace stale balances, while non-negative available credit does not incorrectly replace debt.
Matching booked transactions replace corresponding pending purchases to avoid duplicates.
Deferred-debit purchases are excluded from duplicate reconciliation with other pending transactions.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->