From 18df6c5a4fbf3f1c8a26c4884f6b60cea880d3c9 Mon Sep 17 00:00:00 2001 From: Luc De Meyer Date: Mon, 13 Feb 2023 18:41:28 +0100 Subject: [PATCH 1/2] account_statement_import_camt - fix counterparty data --- account_statement_import_camt/models/parser.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/account_statement_import_camt/models/parser.py b/account_statement_import_camt/models/parser.py index ac700289..15b52673 100644 --- a/account_statement_import_camt/models/parser.py +++ b/account_statement_import_camt/models/parser.py @@ -193,12 +193,13 @@ class CamtParser(models.AbstractModel): ) if party_node: name_node = node.xpath( - "./ns:RltdPties/ns:%s/ns:Nm" % party_type, namespaces={"ns": ns} + "./ns:RltdPties/ns:{pt}/ns:Nm | ./ns:RltdPties/ns:{pt}/ns:Pty/ns:Nm".format( + pt=party_type + ), + namespaces={"ns": ns}, ) if name_node: - self.add_value_from_node( - ns, party_node[0], "./ns:Nm", transaction, "partner_name" - ) + transaction["partner_name"] = name_node[0].text else: self.add_value_from_node( ns, @@ -248,7 +249,7 @@ class CamtParser(models.AbstractModel): "%s (RltdPties/Nm)" % _("Partner Name"): transaction.get("partner_name", ""), "%s (RltdPties/Acct)" - % _("Partner Account Number"): transaction.get("partner_name", ""), + % _("Partner Account Number"): transaction.get("account_number", ""), "%s (BookgDt)" % _("Transaction Date"): transaction.get("date", ""), _("Reference"): transaction.get("ref", ""), _("Communication"): transaction.get("name", ""), From 2e2641e56e6230f79ccffaf271c6e42b6763fe6f Mon Sep 17 00:00:00 2001 From: Luc De Meyer Date: Mon, 13 Feb 2023 22:57:37 +0100 Subject: [PATCH 2/2] fix camt unit tests --- .../test_files/golden-camt053-txdtls.pydata | 4 ++-- .../test_files/golden-camt053.pydata | 8 ++++---- .../test_files/golden-camt054.pydata | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/account_statement_import_camt/test_files/golden-camt053-txdtls.pydata b/account_statement_import_camt/test_files/golden-camt053-txdtls.pydata index a993ba3a..ed46eb92 100644 --- a/account_statement_import_camt/test_files/golden-camt053-txdtls.pydata +++ b/account_statement_import_camt/test_files/golden-camt053-txdtls.pydata @@ -8,7 +8,7 @@ 'amount': 2187.0, 'date': '2017-03-22', 'narration': 'Partner Name (RltdPties/Nm): Banque Cantonale Vaudoise\n' - 'Partner Account Number (RltdPties/Acct): Banque Cantonale Vaudoise\n' + 'Partner Account Number (RltdPties/Acct): CH2222000000123456789\n' 'Transaction Date (BookgDt): 2017-03-22\n' 'Reference: 302388292000011111111111111\n' 'Communication: \n' @@ -27,7 +27,7 @@ 'amount': 1296.0, 'date': '2017-03-22', 'narration': 'Partner Name (RltdPties/Nm): Banque Cantonale Vaudoise\n' - 'Partner Account Number (RltdPties/Acct): Banque Cantonale Vaudoise\n' + 'Partner Account Number (RltdPties/Acct): CH3333000000123456789\n' 'Transaction Date (BookgDt): 2017-03-22\n' 'Reference: 302388292000022222222222222\n' 'Communication: \n' diff --git a/account_statement_import_camt/test_files/golden-camt053.pydata b/account_statement_import_camt/test_files/golden-camt053.pydata index 73172a6c..4124b70f 100644 --- a/account_statement_import_camt/test_files/golden-camt053.pydata +++ b/account_statement_import_camt/test_files/golden-camt053.pydata @@ -8,7 +8,7 @@ 'amount': -754.25, 'date': '2014-01-05', 'narration': 'Partner Name (RltdPties/Nm): INSURANCE COMPANY TESTX\n' - 'Partner Account Number (RltdPties/Acct): INSURANCE COMPANY TESTX\n' + 'Partner Account Number (RltdPties/Acct): NL46ABNA0499998748\n' 'Transaction Date (BookgDt): 2014-01-05\n' 'Reference: 435005714488-ABNO33052620\n' 'Communication: \n' @@ -26,7 +26,7 @@ 'amount': -564.05, 'date': '2014-01-05', 'narration': 'Partner Name (RltdPties/Nm): Test Customer\n' - 'Partner Account Number (RltdPties/Acct): Test Customer\n' + 'Partner Account Number (RltdPties/Acct): NL46ABNA0499998748\n' 'Transaction Date (BookgDt): 2014-01-05\n' 'Reference: TESTBANK/NL/20141229/01206408\n' 'Communication: \n' @@ -48,7 +48,7 @@ 'amount': -100.0, 'date': '2014-01-05', 'narration': 'Partner Name (RltdPties/Nm): Test Customer\n' - 'Partner Account Number (RltdPties/Acct): Test Customer\n' + 'Partner Account Number (RltdPties/Acct): NL46ABNA0499998748\n' 'Transaction Date (BookgDt): 2014-01-05\n' 'Reference: TESTBANK/NL/20141229/01206407\n' 'Communication: \n' @@ -70,7 +70,7 @@ 'amount': 1405.31, 'date': '2014-01-05', 'narration': 'Partner Name (RltdPties/Nm): 3rd party Media\n' - 'Partner Account Number (RltdPties/Acct): 3rd party Media\n' + 'Partner Account Number (RltdPties/Acct): NL69ABNA0522123643\n' 'Transaction Date (BookgDt): 2014-01-05\n' 'Reference: 115\n' 'Communication: \n' diff --git a/account_statement_import_camt/test_files/golden-camt054.pydata b/account_statement_import_camt/test_files/golden-camt054.pydata index ac60bdb1..79e01712 100644 --- a/account_statement_import_camt/test_files/golden-camt054.pydata +++ b/account_statement_import_camt/test_files/golden-camt054.pydata @@ -8,7 +8,7 @@ 'amount': 5.0, 'date': '2022-01-26', 'narration': 'Partner Name (RltdPties/Nm): Test Customer\n' - 'Partner Account Number (RltdPties/Acct): Test Customer\n' + 'Partner Account Number (RltdPties/Acct): NL46ABNA0499998748\n' 'Transaction Date (BookgDt): 2022-01-26\n' 'Reference: 000000000000000000000000003\n' 'Communication: \n'