Browse Source

8.0 camt statement (#83)

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

* [ENH] Add tests for improved camt statement id uniqueness.
pull/96/head
Ronald Portier 8 years ago
committed by Stefan Rijnhart (Opener)
parent
commit
3d2dc86056
  1. 8
      account_bank_statement_import_camt/camt.py
  2. 4
      account_bank_statement_import_camt/tests/test_import_bank_statement.py

8
account_bank_statement_import_camt/camt.py

@ -200,8 +200,12 @@ class CamtParser(object):
transaction = statement.create_transaction() transaction = statement.create_transaction()
self.parse_transaction(ns, entry_node, transaction) self.parse_transaction(ns, entry_node, transaction)
if statement['transactions']: 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 return statement
def check_version(self, ns, root): def check_version(self, ns, root):

4
account_bank_statement_import_camt/tests/test_import_bank_statement.py

@ -37,7 +37,7 @@ class TestImport(TestStatementFile):
] ]
self._test_statement_import( self._test_statement_import(
'account_bank_statement_import_camt', 'test-camt053.xml', 'account_bank_statement_import_camt', 'test-camt053.xml',
'1234Test/1',
'2014-01-05-1234Test/1',
local_account='NL77ABNA0574908765', local_account='NL77ABNA0574908765',
start_balance=15568.27, end_balance=15121.12, start_balance=15568.27, end_balance=15121.12,
transactions=transactions transactions=transactions
@ -47,6 +47,6 @@ class TestImport(TestStatementFile):
"""Test import of multiple statements from zip file.""" """Test import of multiple statements from zip file."""
self._test_statement_import( self._test_statement_import(
'account_bank_statement_import_camt', 'test-camt053.zip', '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', local_account='NL77ABNA0574908765',
) )
Loading…
Cancel
Save