From d6a429cb75bb1e94b6550b26c79dacba58fbb09b Mon Sep 17 00:00:00 2001 From: Stefan Rijnhart Date: Tue, 1 Feb 2022 11:02:54 +0100 Subject: [PATCH] [IMP] account_statement_import_camt: look for currency under Ntry Encountered in a Camt.054 statement: currency listed under /BkToCstmrDbtCdtNtfctn/Ntfctn/Ntry/Amt/@Ccy --- .../models/parser.py | 10 +- .../readme/CONTRIBUTORS.rst | 2 +- .../test_files/golden-camt054.pydata | 13 ++ .../test_files/test-camt054 | 127 ++++++++++++++++++ .../tests/test_import_bank_statement.py | 3 + 5 files changed, 153 insertions(+), 2 deletions(-) create mode 100644 account_statement_import_camt/test_files/golden-camt054.pydata create mode 100644 account_statement_import_camt/test_files/test-camt054 diff --git a/account_statement_import_camt/models/parser.py b/account_statement_import_camt/models/parser.py index 0fdbeb27..ecbd8d86 100644 --- a/account_statement_import_camt/models/parser.py +++ b/account_statement_import_camt/models/parser.py @@ -204,7 +204,15 @@ class CamtParser(models.AbstractModel): ) self.add_value_from_node(ns, node, "./ns:Id", result, "name") self.add_value_from_node( - ns, node, ["./ns:Acct/ns:Ccy", "./ns:Bal/ns:Amt/@Ccy"], result, "currency" + ns, + node, + [ + "./ns:Acct/ns:Ccy", + "./ns:Bal/ns:Amt/@Ccy", + "./ns:Ntry/ns:Amt/@Ccy", + ], + result, + "currency", ) result["balance_start"], result["balance_end_real"] = self.get_balance_amounts( ns, node diff --git a/account_statement_import_camt/readme/CONTRIBUTORS.rst b/account_statement_import_camt/readme/CONTRIBUTORS.rst index 32d01b27..d869e5dd 100644 --- a/account_statement_import_camt/readme/CONTRIBUTORS.rst +++ b/account_statement_import_camt/readme/CONTRIBUTORS.rst @@ -1,5 +1,5 @@ * Holger Brunn -* Stefan Rijnhart +* Stefan Rijnhart * Ronald Portier * Andrea Stirpe * Maxence Groine diff --git a/account_statement_import_camt/test_files/golden-camt054.pydata b/account_statement_import_camt/test_files/golden-camt054.pydata new file mode 100644 index 00000000..6a00cb5a --- /dev/null +++ b/account_statement_import_camt/test_files/golden-camt054.pydata @@ -0,0 +1,13 @@ +('EUR', + 'NL77ABNA0574908765', + [{'balance_end_real': 0.0, + 'balance_start': 0.0, + 'date': '2022-01-26', + 'name': '20220120000000000000000', + 'transactions': [{'account_number': 'NL46ABNA0499998748', + 'amount': 5.0, + 'date': '2022-01-26', + 'narration': 'Additional entry info', + 'partner_name': 'Test Customer', + 'payment_ref': 'MIB InstrId305-312MM20211231v1', + 'ref': '000000000000000000000000003'}]}]) diff --git a/account_statement_import_camt/test_files/test-camt054 b/account_statement_import_camt/test_files/test-camt054 new file mode 100644 index 00000000..0dd09338 --- /dev/null +++ b/account_statement_import_camt/test_files/test-camt054 @@ -0,0 +1,127 @@ + + + + + 20220126375204763458853 + 2022-01-26T23:40:40 + + 1 + true + + SPS/1.7/PROD + + + 20220120000000000000000 + 2022-01-26T23:40:40 + + 2022-01-26T00:00:00 + 2022-01-26T23:59:59 + + + OTHR + + + + NL77ABNA0574908765 + + + Example company + + + + NL0000000000000000000 + 5.00 + CRDT + false + BOOK + +
2022-01-26
+
+ +
2022-01-26
+
+ 98888208N8 + + + PMNT + + RCDT + VCOM + + + + + + 1 + + + + 15180015077602405 + MIB InstrId305-312MM20211231v1 + ENDTOENDID-01 + + 00 + 20220120000000000000001 + + + 5.00 + CRDT + + + PMNT + + RCDT + ATXN + + + + + + Test Customer + + Test street 1 + 1234 AB Test city + + + + + NL46ABNA0499998748 + + + + + + + + NZNCC020368 + + Test Bank + + Test street 5 + 1234 AB Test city + + + + + + + + + + QRR + + + 000000000000000000000000003 + + + + + 2022-01-26T20:00:00 + + + + Additional entry info +
+
+
+
diff --git a/account_statement_import_camt/tests/test_import_bank_statement.py b/account_statement_import_camt/tests/test_import_bank_statement.py index cda12fa9..fe3af6fd 100644 --- a/account_statement_import_camt/tests/test_import_bank_statement.py +++ b/account_statement_import_camt/tests/test_import_bank_statement.py @@ -46,6 +46,9 @@ class TestParser(TransactionCase): def test_parse(self): self._do_parse_test("test-camt053", "golden-camt053.pydata") + def test_parse_camt054(self): + self._do_parse_test("test-camt054", "golden-camt054.pydata") + def test_parse_txdtls(self): self._do_parse_test("test-camt053-txdtls", "golden-camt053-txdtls.pydata")