From 1a2b4782c2e7922dd9cd7b71c598df393b8a80b1 Mon Sep 17 00:00:00 2001 From: Emanuel Cino Date: Wed, 7 Oct 2026 14:36:50 +0200 Subject: [PATCH] [FIX] account_ebics: camt.054 without account currency camt.054 notifications (e.g. Raiffeisen) have neither Acct/Ccy nor Bal, which raised an IndexError in _split_camt. Fall back on the currency of the entries and add a notification instead of crashing when no currency is found. Assisted-by: claude-opus-5-5, medium, claude-code --- account_ebics/models/ebics_file.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/account_ebics/models/ebics_file.py b/account_ebics/models/ebics_file.py index 44e341f1..30d9b0d5 100644 --- a/account_ebics/models/ebics_file.py +++ b/account_ebics/models/ebics_file.py @@ -586,9 +586,19 @@ def _split_camt(self, res): message = self.env._("No bank account number found.") res["notifications"].append({"type": "error", "message": message}) continue - currency_code = stmt.xpath( - "ns:Acct/ns:Ccy/text() | ns:Bal/ns:Amt/@Ccy", namespaces=ns - )[0] + # camt.054 notifications usually have neither Acct/Ccy nor Bal, + # hence fall back on the currency of the entries + currency_codes = stmt.xpath( + "ns:Acct/ns:Ccy/text() | ns:Bal/ns:Amt/@Ccy | ns:Ntry/ns:Amt/@Ccy", + namespaces=ns, + ) + if not currency_codes: + message = self.env._( + "No currency found for Account Number %(nr)s.", nr=acc_number + ) + res["notifications"].append({"type": "error", "message": message}) + continue + currency_code = currency_codes[0] # some banks (e.g. COMMERZBANK) add the currency as the last 3 digits # of the bank account number hence we need to remove this since otherwise # the journal matching logic fails