fix: Properly compute credit card balance for Enable Banking accounts (#663)

* fix: Properly compute credit card balance for Enable Banking accounts

* fix: Use right balance type codes

* fix: Update comment
This commit is contained in:
Alessio Cappa
2026-01-18 15:11:34 +01:00
committed by GitHub
parent f97ff419e8
commit 6ec03e93f4
2 changed files with 10 additions and 4 deletions

View File

@@ -134,9 +134,11 @@ class EnableBankingItem::Importer
balances = balance_data[:balances] || []
return if balances.empty?
# Find the most relevant balance (prefer "closingBooked" or "expected")
balance = balances.find { |b| b[:balance_type] == "closingBooked" } ||
balances.find { |b| b[:balance_type] == "expected" } ||
# Find the most relevant balance (prefer "ITAV" or "CLAV" types)
balance = balances.find { |b| b[:balance_type] == "ITAV" } ||
balances.find { |b| b[:balance_type] == "CLAV" } ||
balances.find { |b| b[:balance_type] == "ITBD" } ||
balances.find { |b| b[:balance_type] == "CLBD" } ||
balances.first
if balance.present?