8.0 camt statement (#83)

* [FIX] CAMT Statement id may not be unique over time

* [ENH] Add tests for improved camt statement id uniqueness.
This commit is contained in:
Ronald Portier
2017-02-28 11:29:21 +01:00
committed by Stefan Rijnhart (Opener)
parent 55f522fdb5
commit 3d2dc86056
2 changed files with 8 additions and 4 deletions

View File

@@ -200,8 +200,12 @@ class CamtParser(object):
transaction = statement.create_transaction()
self.parse_transaction(ns, entry_node, transaction)
if statement['transactions']:
statement.date = datetime.strptime(
statement['transactions'][0].execution_date, "%Y-%m-%d")
execution_date = statement['transactions'][0].execution_date
statement.date = datetime.strptime(execution_date, "%Y-%m-%d")
# Prepend date of first transaction to improve id uniquenes
if execution_date not in statement.statement_id:
statement.statement_id = "%s-%s" % (
execution_date, statement.statement_id)
return statement
def check_version(self, ns, root):

View File

@@ -37,7 +37,7 @@ class TestImport(TestStatementFile):
]
self._test_statement_import(
'account_bank_statement_import_camt', 'test-camt053.xml',
'1234Test/1',
'2014-01-05-1234Test/1',
local_account='NL77ABNA0574908765',
start_balance=15568.27, end_balance=15121.12,
transactions=transactions
@@ -47,6 +47,6 @@ class TestImport(TestStatementFile):
"""Test import of multiple statements from zip file."""
self._test_statement_import(
'account_bank_statement_import_camt', 'test-camt053.zip',
'1234Test/2', # Only name of first statement
'2014-02-05-1234Test/2', # Only name of first statement
local_account='NL77ABNA0574908765',
)