From 8d7f5187bb694de6b7208e360b1193f6ed75b51c Mon Sep 17 00:00:00 2001 From: Luc De Meyer Date: Sun, 8 Oct 2023 21:10:21 +0200 Subject: [PATCH] [IMP][16.0]enhance _split_camt to support C52, C53 and C54 --- account_ebics/models/ebics_file.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/account_ebics/models/ebics_file.py b/account_ebics/models/ebics_file.py index f27faa3..2fb45b1 100644 --- a/account_ebics/models/ebics_file.py +++ b/account_ebics/models/ebics_file.py @@ -535,7 +535,14 @@ 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) + camt_variant = ns["ns"].split("camt.")[1][:3] + variant_tags = { + "052": "Rpt", + "053": "Stmt", + "054": "Ntfctn", + } + camt_tag = variant_tags[camt_variant] + stmts = root[0].findall("ns:{}".format(camt_tag), ns) for i, stmt in enumerate(stmts): acc_number = sanitize_account_number( stmt.xpath( @@ -558,7 +565,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("ns:{}".format(camt_tag), ns)): if j != i: el.getparent().remove(el) else: