From 209ac9195b9dfe499d8315eaeb1ac5477579255e Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 20 Feb 2018 10:05:40 +0100 Subject: [PATCH 1/2] camt: remove dead code Fix warning account.bank.statement.line.create() includes unknown fields: data, execution_date, transfer_type, value_date --- .../models/parser.py | 25 ------------------- 1 file changed, 25 deletions(-) diff --git a/account_bank_statement_import_camt/models/parser.py b/account_bank_statement_import_camt/models/parser.py index c6b75e3..c98e715 100644 --- a/account_bank_statement_import_camt/models/parser.py +++ b/account_bank_statement_import_camt/models/parser.py @@ -83,14 +83,6 @@ class CamtParser(models.AbstractModel): if party_node: self.add_value_from_node( ns, party_node[0], './ns:Nm', transaction, 'partner_name') - self.add_value_from_node( - ns, party_node[0], './ns:PstlAdr/ns:Ctry', transaction, - 'partner_country' - ) - address_node = party_node[0].xpath( - './ns:PstlAdr/ns:AdrLine', namespaces={'ns': ns}) - if address_node: - transaction['partner_address'] = [address_node[0].text] # Get remote_account from iban or from domestic account: account_node = node.xpath( './ns:RltdPties/ns:%sAcct/ns:Id' % party_type, @@ -101,32 +93,17 @@ class CamtParser(models.AbstractModel): './ns:IBAN', namespaces={'ns': ns}) if iban_node: transaction['account_number'] = iban_node[0].text - bic_node = node.xpath( - './ns:RltdAgts/ns:%sAgt/ns:FinInstnId/ns:BIC' % party_type, - namespaces={'ns': ns} - ) - if bic_node: - transaction['account_bic'] = bic_node[0].text else: self.add_value_from_node( ns, account_node[0], './ns:Othr/ns:Id', transaction, 'account_number' ) - transaction['data'] = etree.tostring(node) def parse_entry(self, ns, node): """Parse an Ntry node and yield transactions""" transaction = {'name': '/', 'amount': 0} # fallback defaults - self.add_value_from_node( - ns, node, './ns:BkTxCd/ns:Prtry/ns:Cd', transaction, - 'transfer_type' - ) self.add_value_from_node( ns, node, './ns:BookgDt/ns:Dt', transaction, 'date') - self.add_value_from_node( - ns, node, './ns:BookgDt/ns:Dt', transaction, 'execution_date') - self.add_value_from_node( - ns, node, './ns:ValDt/ns:Dt', transaction, 'value_date') amount = self.parse_amount(ns, node) if amount != 0.0: transaction['amount'] = amount @@ -196,8 +173,6 @@ class CamtParser(models.AbstractModel): ) self.add_value_from_node( ns, node, './ns:Id', result, 'name') - self.add_value_from_node( - ns, node, './ns:Dt', result, 'date') self.add_value_from_node( ns, node, './ns:Acct/ns:Ccy', result, 'currency') result['balance_start'], result['balance_end_real'] = ( From 8bf315a8a0e96a04d9f75f08ebaf6f010781a50d Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 20 Feb 2018 17:54:55 +0100 Subject: [PATCH 2/2] Remove dead fields from unittests --- .../test_files/golden-camt053-txdtls.pydata | 12 ++------ .../test_files/golden-camt053.pydata | 30 ++++--------------- 2 files changed, 8 insertions(+), 34 deletions(-) diff --git a/account_bank_statement_import_camt/test_files/golden-camt053-txdtls.pydata b/account_bank_statement_import_camt/test_files/golden-camt053-txdtls.pydata index f641bfb..7d1755f 100644 --- a/account_bank_statement_import_camt/test_files/golden-camt053-txdtls.pydata +++ b/account_bank_statement_import_camt/test_files/golden-camt053-txdtls.pydata @@ -6,21 +6,13 @@ 'name': '20170323123456789012345', 'transactions': [{'account_number': 'CH2222000000123456789', 'amount': 2187.0, - 'data': '\n \n 123456CHCAFEBABE\n \n 01\n 123456CHCAFEBABE\n \n \n 2187.00\n CRDT\n \n \n PMNT\n \n RCDT\n AUTT\n \n \n \n \n \n Banque Cantonale Vaudoise\n \n Place Saint-François\n 14\n 1003\n Lausanne\n CH1\n \n \n \n \n CH2222000000123456789\n \n \n \n \n \n \n POFICHBEXXX\n POSTFINANCE AG\n \n MINGERSTRASSE 20\n 3030 BERNE\n \n \n \n \n \n \n \n \n \n ISR Reference\n \n \n 302388292000011111111111111\n \n ?REJECT?0\n \n \n \n 2017-03-22T20:00:00\n \n \n ', 'date': '2017-03-22', - 'execution_date': '2017-03-22', 'name': u'CR\xc9DIT GROUP\xc9 BVR TRAITEMENT DU 22.03.2017 NUM\xc9RO CLIENT 01-70884-3 PAQUET ID: 123456CHCAFEBABE', - 'partner_country': 'CH1', 'partner_name': 'Banque Cantonale Vaudoise', - 'ref': '302388292000011111111111111', - 'value_date': '2017-03-23'}, + 'ref': '302388292000011111111111111'}, {'account_number': 'CH3333000000123456789', 'amount': 1296.0, - 'data': '\n \n 123456CHCAFEBABE\n \n 01\n 123456CHCAFEBABE\n \n \n 1296.00\n CRDT\n \n \n PMNT\n \n RCDT\n AUTT\n \n \n \n \n \n Banque Cantonale Vaudoise\n \n Place Saint-François\n 14\n 1003\n Lausanne\n CH2\n \n \n \n \n CH3333000000123456789\n \n \n \n \n \n \n POFICHBEYYY\n POSTFINANCE AG\n \n MINGERSTRASSE 20\n 3030 BERNE\n \n \n \n \n \n \n \n \n \n ISR Reference\n \n \n 302388292000022222222222222\n \n ?REJECT?0\n \n \n \n 2017-03-22T20:00:00\n \n \n ', 'date': '2017-03-22', - 'execution_date': '2017-03-22', 'name': u'CR\xc9DIT GROUP\xc9 BVR TRAITEMENT DU 22.03.2017 NUM\xc9RO CLIENT 01-70884-3 PAQUET ID: 123456CHCAFEBABE', - 'partner_country': 'CH2', 'partner_name': 'Banque Cantonale Vaudoise', - 'ref': '302388292000022222222222222', - 'value_date': '2017-03-23'}]}]) + 'ref': '302388292000022222222222222'}]}]) diff --git a/account_bank_statement_import_camt/test_files/golden-camt053.pydata b/account_bank_statement_import_camt/test_files/golden-camt053.pydata index da29c8d..ba7cb95 100644 --- a/account_bank_statement_import_camt/test_files/golden-camt053.pydata +++ b/account_bank_statement_import_camt/test_files/golden-camt053.pydata @@ -4,42 +4,24 @@ 'balance_start': 15568.27, 'date': '2014-01-05', 'name': '1234Test/1', - 'transactions': [{'account_bic': 'ABNANL2A', - 'account_number': 'NL46ABNA0499998748', + 'transactions': [{'account_number': 'NL46ABNA0499998748', 'amount': -754.25, - 'data': '\n \n INNDNL2U20141231000142300002844\n 435005714488-ABNO33052620\n 1880000341866\n \n \n \n 754.25\n \n \n \n \n INSURANCE COMPANY TESTX\n \n TEST STREET 20\n 1234 AB TESTCITY\n NL\n \n \n \n \n NL46ABNA0499998748\n \n \n \n \n \n \n ABNANL2A\n \n \n \n \n Insurance policy 857239PERIOD 01.01.2014 - 31.12.2014\n \n MKB Insurance 859239PERIOD 01.01.2014 - 31.12.2014\n \n ', 'date': '2014-01-05', - 'execution_date': '2014-01-05', 'name': 'MKB Insurance 859239PERIOD 01.01.2014 - 31.12.2014', 'note': 'Insurance policy 857239PERIOD 01.01.2014 - 31.12.2014', - 'partner_country': 'NL', 'partner_name': 'INSURANCE COMPANY TESTX', - 'ref': '435005714488-ABNO33052620', - 'transfer_type': 'EI', - 'value_date': '2014-01-05'}, - {'account_bic': 'ABNANL2A', - 'account_number': 'NL46ABNA0499998748', + 'ref': '435005714488-ABNO33052620'}, + {'account_number': 'NL46ABNA0499998748', 'amount': -594.05, - 'data': '\n \n TESTBANK/NL/20141229/01206408\n TESTBANK/NL/20141229/01206408\n NL22ZZZ524885430000-C0125.1\n \n \n \n 564.05\n \n \n \n \n Test Customer\n \n NL\n \n \n \n \n NL46ABNA0499998748\n \n \n \n \n \n \n ABNANL2A\n \n \n \n \n Direct Debit S14 0410\n \n \n \n AC06\n \n \n Direct debit S14 0410 AC07 Rek.nummer blokkade TESTBANK/NL/20141229/01206408\n \n ', 'date': '2014-01-05', - 'execution_date': '2014-01-05', 'name': 'Direct debit S14 0410 AC07 Rek.nummer blokkade TESTBANK/NL/20141229/01206408', 'note': 'Direct Debit S14 0410', - 'partner_country': 'NL', 'partner_name': 'Test Customer', - 'ref': 'TESTBANK/NL/20141229/01206408', - 'transfer_type': 'EIST', - 'value_date': '2014-01-05'}, - {'account_bic': 'ABNANL2A', - 'account_number': 'NL69ABNA0522123643', + 'ref': 'TESTBANK/NL/20141229/01206408'}, + {'account_number': 'NL69ABNA0522123643', 'amount': 1405.31, - 'data': '\n \n INNDNL2U20140105000217200000708\n 115\n \n \n \n 1405.31\n \n \n \n \n 3rd party Media\n \n SOMESTREET 570-A\n 1276 ML HOUSCITY\n NL\n \n \n \n \n NL69ABNA0522123643\n \n \n \n \n \n \n ABNANL2A\n \n \n \n #RD PARTY MEDIA CUSNO 90782 4210773\n \n ', 'date': '2014-01-05', - 'execution_date': '2014-01-05', 'name': '#RD PARTY MEDIA CUSNO 90782 4210773', 'note': 'INNDNL2U20140105000217200000708', - 'partner_country': 'NL', 'partner_name': '3rd party Media', - 'ref': '115', - 'transfer_type': 'ET', - 'value_date': '2014-01-05'}]}]) + 'ref': '115'}]}])