From 657f5c3ef05c9a3a5b035e3c72540bf69d529792 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Fri, 2 Feb 2024 20:58:47 +0100 Subject: [PATCH] [FIX] account_statement_import_online_gocardless: Payment reference extraction Since one week ago, banks like Sabadell is sending the information in the JSON list `remittanceInformationUnstructuredArray` instead of `remittanceInformationUnstructured`. Thus, we need to parse both for finding the proper element. For the rest that are using the previous one, there's no change. TT47491 --- .../models/online_bank_statement_provider.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/account_statement_import_online_gocardless/models/online_bank_statement_provider.py b/account_statement_import_online_gocardless/models/online_bank_statement_provider.py index bc63ac4f..6a9dc6f3 100644 --- a/account_statement_import_online_gocardless/models/online_bank_statement_provider.py +++ b/account_statement_import_online_gocardless/models/online_bank_statement_provider.py @@ -306,14 +306,18 @@ class OnlineBankStatementProvider(models.Model): ).get("iban", False) if account_number == own_acc_number: account_number = False # Discard own bank account number + if "remittanceInformationUnstructured" in tr: + payment_ref = tr["remittanceInformationUnstructured"] + elif "remittanceInformationUnstructuredArray" in tr: + payment_ref = " ".join(tr["remittanceInformationUnstructuredArray"]) + else: + payment_ref = partner_name res.append( { "sequence": sequence, "date": current_date, "ref": partner_name or "/", - "payment_ref": tr.get( - "remittanceInformationUnstructured", partner_name - ), + "payment_ref": payment_ref, "unique_import_id": ( tr.get("entryReference") or tr.get("transactionId")