[11.0][FIX] Fix CAMT import without NTRY (#163)

This commit is contained in:
oleksandrpaziuk
2018-07-12 17:05:52 +03:00
committed by Thomas Binsfeld
parent bff7f545b4
commit c7263e9b95
5 changed files with 65 additions and 5 deletions

View File

@@ -2,7 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{ {
'name': 'CAMT Format Bank Statements Import', 'name': 'CAMT Format Bank Statements Import',
'version': '11.0.1.0.0', 'version': '11.0.1.0.1',
'license': 'AGPL-3', 'license': 'AGPL-3',
'author': 'Odoo Community Association (OCA), Therp BV', 'author': 'Odoo Community Association (OCA), Therp BV',
'website': 'https://github.com/OCA/bank-statement-import', 'website': 'https://github.com/OCA/bank-statement-import',

View File

@@ -181,10 +181,12 @@ class CamtParser(models.AbstractModel):
for entry_node in entry_nodes: for entry_node in entry_nodes:
transactions.extend(self.parse_entry(ns, entry_node)) transactions.extend(self.parse_entry(ns, entry_node))
result['transactions'] = transactions result['transactions'] = transactions
result['date'] = sorted(transactions, result['date'] = None
key=lambda x: x['date'], if transactions:
reverse=True result['date'] = sorted(transactions,
)[0]['date'] key=lambda x: x['date'],
reverse=True
)[0]['date']
return result return result
def check_version(self, ns, root): def check_version(self, ns, root):

View File

@@ -0,0 +1 @@
(None, None, [])

View File

@@ -0,0 +1,52 @@
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.053.001.04">
<BkToCstmrStmt>
<GrpHdr>
<MsgId>TESTBANK/NL/1420561226673</MsgId>
<CreDtTm>2014-01-06T16:20:26.673Z</CreDtTm>
</GrpHdr>
<Stmt>
<Id>1234Test/1</Id>
<LglSeqNb>2</LglSeqNb>
<CreDtTm>2014-01-06T16:20:26.673Z</CreDtTm>
<FrToDt>
<FrDtTm>2014-01-05T00:00:00.000Z</FrDtTm>
<ToDtTm>2014-01-05T23:59:59.999Z</ToDtTm>
</FrToDt>
<Acct>
<Id>
<IBAN>NL77ABNA0574908765</IBAN>
</Id>
<Nm>Example company</Nm>
<Svcr>
<FinInstnId>
<BIC>ABNANL2A</BIC>
</FinInstnId>
</Svcr>
</Acct>
<Bal>
<Tp>
<CdOrPrtry>
<Cd>OPBD</Cd>
</CdOrPrtry>
</Tp>
<Amt Ccy="CHF">1520.76</Amt>
<CdtDbtInd>CRDT</CdtDbtInd>
<Dt>
<Dt>2014-01-05</Dt>
</Dt>
</Bal>
<Bal>
<Tp>
<CdOrPrtry>
<Cd>CLBD</Cd>
</CdOrPrtry>
</Tp>
<Amt Ccy="CHF">1520.76</Amt>
<CdtDbtInd>CRDT</CdtDbtInd>
<Dt>
<Dt>2014-01-05</Dt>
</Dt>
</Bal>
</Stmt>
</BkToCstmrStmt>
</Document>

View File

@@ -57,6 +57,11 @@ class TestParser(TransactionCase):
'test-camt053-txdtls', 'test-camt053-txdtls',
'golden-camt053-txdtls.pydata') 'golden-camt053-txdtls.pydata')
def test_parse_no_ntry(self):
self._do_parse_test(
'test-camt053-no-ntry',
'golden-camt053-no-ntry.pydata')
class TestImport(TransactionCase): class TestImport(TransactionCase):
"""Run test to import camt import.""" """Run test to import camt import."""