From cc2f9025843c3cd9d98b8f7925a079f803226115 Mon Sep 17 00:00:00 2001 From: BT-cjimeno Date: Thu, 14 Sep 2023 00:29:32 +0200 Subject: [PATCH] [HOTFIX] to process camt052 files --- account_ebics/models/ebics_file.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/account_ebics/models/ebics_file.py b/account_ebics/models/ebics_file.py index eae82b5..58331a4 100644 --- a/account_ebics/models/ebics_file.py +++ b/account_ebics/models/ebics_file.py @@ -442,7 +442,7 @@ class EbicsFile(models.Model): ) ) res = {"statement_ids": [], "notifications": []} - st_datas = self._split_camt(res) + st_datas = self._split_camt(res, file_format) if author == "oca": self._process_bank_statement_oca(res, st_datas) else: @@ -529,7 +529,7 @@ class EbicsFile(models.Model): EBICS data file and its related bank statements. """ - def _split_camt(self, res): + def _split_camt(self, res, file_format): """ Split CAMT file received via EBICS per statement. Statements without transactions are removed. @@ -541,7 +541,10 @@ class EbicsFile(models.Model): message = _("Invalid XML file.") res["notifications"].append({"type": "error", "message": message}) ns = {k or "ns": v for k, v in root.nsmap.items()} - stmts = root[0].findall("ns:Stmt", ns) + tag_to_find = "ns:Stmt" + if file_format == 'camt052': + tag_to_find = "ns:Rpt" + stmts = root[0].findall(tag_to_find, ns) for i, stmt in enumerate(stmts): acc_number = sanitize_account_number( stmt.xpath( @@ -559,7 +562,7 @@ class EbicsFile(models.Model): root_new = deepcopy(root) entries = False - for j, el in enumerate(root_new[0].findall("ns:Stmt", ns)): + for j, el in enumerate(root_new[0].findall(tag_to_find, ns)): if j != i: el.getparent().remove(el) else: