From 64f26f3a6b98bc82f7c0e2fa24e209ffd1839162 Mon Sep 17 00:00:00 2001 From: Andrea Stirpe Date: Wed, 8 Aug 2018 08:14:07 +0200 Subject: [PATCH] [11.0][FIX] account_bank_statement_import_camt: payment amounts (#168) --- .../__manifest__.py | 2 +- .../models/parser.py | 6 +++ .../test_files/golden-camt053.pydata | 9 +++- .../test_files/test-camt053 | 50 ++++++++++++++++++- .../tests/test_import_bank_statement.py | 18 +++++++ 5 files changed, 82 insertions(+), 3 deletions(-) diff --git a/account_bank_statement_import_camt_oca/__manifest__.py b/account_bank_statement_import_camt_oca/__manifest__.py index 64b4978..573acf3 100644 --- a/account_bank_statement_import_camt_oca/__manifest__.py +++ b/account_bank_statement_import_camt_oca/__manifest__.py @@ -2,7 +2,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { 'name': 'CAMT Format Bank Statements Import', - 'version': '11.0.1.0.1', + 'version': '11.0.1.0.2', 'license': 'AGPL-3', 'author': 'Odoo Community Association (OCA), Therp BV', 'website': 'https://github.com/OCA/bank-statement-import', diff --git a/account_bank_statement_import_camt_oca/models/parser.py b/account_bank_statement_import_camt_oca/models/parser.py index 1176c79..aa9ef1e 100644 --- a/account_bank_statement_import_camt_oca/models/parser.py +++ b/account_bank_statement_import_camt_oca/models/parser.py @@ -19,9 +19,15 @@ class CamtParser(models.AbstractModel): sign = 1 amount = 0.0 sign_node = node.xpath('ns:CdtDbtInd', namespaces={'ns': ns}) + if not sign_node: + sign_node = node.xpath( + '../../ns:CdtDbtInd', namespaces={'ns': ns}) if sign_node and sign_node[0].text == 'DBIT': sign = -1 amount_node = node.xpath('ns:Amt', namespaces={'ns': ns}) + if not amount_node: + amount_node = node.xpath( + './ns:AmtDtls/ns:TxAmt/ns:Amt', namespaces={'ns': ns}) if amount_node: amount = sign * float(amount_node[0].text) return amount diff --git a/account_bank_statement_import_camt_oca/test_files/golden-camt053.pydata b/account_bank_statement_import_camt_oca/test_files/golden-camt053.pydata index ba7cb95..ee76845 100644 --- a/account_bank_statement_import_camt_oca/test_files/golden-camt053.pydata +++ b/account_bank_statement_import_camt_oca/test_files/golden-camt053.pydata @@ -12,12 +12,19 @@ 'partner_name': 'INSURANCE COMPANY TESTX', 'ref': '435005714488-ABNO33052620'}, {'account_number': 'NL46ABNA0499998748', - 'amount': -594.05, + 'amount': -564.05, 'date': '2014-01-05', 'name': 'Direct debit S14 0410 AC07 Rek.nummer blokkade TESTBANK/NL/20141229/01206408', 'note': 'Direct Debit S14 0410', 'partner_name': 'Test Customer', 'ref': 'TESTBANK/NL/20141229/01206408'}, + {'account_number': 'NL46ABNA0499998748', + 'amount': -100.0, + 'date': '2014-01-05', + 'name': 'Direct debit S14 0410 AC07 Rek.nummer blokkade TESTBANK/NL/20141229/01206408', + 'note': 'Direct Debit S14 0410', + 'partner_name': 'Test Customer', + 'ref': 'TESTBANK/NL/20141229/01206407'}, {'account_number': 'NL69ABNA0522123643', 'amount': 1405.31, 'date': '2014-01-05', diff --git a/account_bank_statement_import_camt_oca/test_files/test-camt053 b/account_bank_statement_import_camt_oca/test_files/test-camt053 index 4a2a047..1f15c84 100644 --- a/account_bank_statement_import_camt_oca/test_files/test-camt053 +++ b/account_bank_statement_import_camt_oca/test_files/test-camt053 @@ -111,7 +111,7 @@ - 594.05 + 664.05 DBIT true BOOK @@ -134,6 +134,13 @@ + + 2014/125 + 2018/125-20141229-NORM + 2 + 664.05 + DBIT + TESTBANK/NL/20141229/01206408 @@ -175,6 +182,47 @@ Direct debit S14 0410 AC07 Rek.nummer blokkade TESTBANK/NL/20141229/01206408 + + + TESTBANK/NL/20141229/01206407 + TESTBANK/NL/20141229/01206407 + NL22ZZZ524885430000-C0125.2 + + + + 100.00 + + + + + Test Customer + + NL + + + + + NL46ABNA0499998748 + + + + + + + ABNANL2A + + + + + Direct Debit S14 0410 + + + + AC06 + + + Direct debit S14 0410 AC07 Rek.nummer blokkade TESTBANK/NL/20141229/01206408 + diff --git a/account_bank_statement_import_camt_oca/tests/test_import_bank_statement.py b/account_bank_statement_import_camt_oca/tests/test_import_bank_statement.py index 5235f35..95ef967 100644 --- a/account_bank_statement_import_camt_oca/tests/test_import_bank_statement.py +++ b/account_bank_statement_import_camt_oca/tests/test_import_bank_statement.py @@ -72,6 +72,24 @@ class TestImport(TransactionCase): 'date': '2014-01-05', 'ref': '435005714488-ABNO33052620', }, + { + 'remote_account': 'NL46ABNA0499998748', + 'transferred_amount': -564.05, + 'value_date': '2014-01-05', + 'ref': 'TESTBANK/NL/20141229/01206408', + }, + { + 'remote_account': 'NL46ABNA0499998748', + 'transferred_amount': -100.0, + 'value_date': '2014-01-05', + 'ref': 'TESTBANK/NL/20141229/01206407', + }, + { + 'remote_account': 'NL69ABNA0522123643', + 'transferred_amount': 1405.31, + 'value_date': '2014-01-05', + 'ref': '115', + }, ] def setUp(self):