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

@@ -38,8 +38,12 @@ class EnableBankingAccount::Processor
account = enable_banking_account.current_account
balance = enable_banking_account.current_balance || 0
# For credit cards, compute balance based on credit limit
if account.accountable_type == "CreditCard"
available_credit = account.accountable.available_credit || 0
balance = available_credit - balance
# For liability accounts, ensure positive balances
if account.accountable_type == "CreditCard" || account.accountable_type == "Loan"
elsif account.accountable_type == "Loan"
balance = -balance
end