From f5aebc17001b2ceb064281b73f4e87624a941797 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 9 Mar 2016 22:17:58 +0100 Subject: [PATCH 1/3] OFX: Stronger unique_import_id (to lower the risk of having 2 identical unique_import_id in the same file) Use bank account number as bank statement label, instead of bank number (important when you have several bank accounts at the same bank) --- .../account_bank_statement_import_ofx.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/account_bank_statement_import_ofx/account_bank_statement_import_ofx.py b/account_bank_statement_import_ofx/account_bank_statement_import_ofx.py index cdf363b..2bf7312 100644 --- a/account_bank_statement_import_ofx/account_bank_statement_import_ofx.py +++ b/account_bank_statement_import_ofx/account_bank_statement_import_ofx.py @@ -58,7 +58,8 @@ class AccountBankStatementImport(models.TransientModel): transaction.memo and ': ' + transaction.memo or ''), 'ref': transaction.id, 'amount': transaction.amount, - 'unique_import_id': transaction.id, + 'unique_import_id': '%s-%s-%s' % ( + transaction.id, transaction.payee, transaction.memo), 'bank_account_id': bank_account_id, 'partner_id': partner_id, } @@ -83,7 +84,7 @@ class AccountBankStatementImport(models.TransientModel): )) vals_bank_statement = { - 'name': ofx.account.routing_number, + 'name': ofx.account.number, 'transactions': transactions, 'balance_start': ofx.account.statement.balance, 'balance_end_real': From 8ac21acea3510f2c86211589b9da6d22532f1009 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 9 Mar 2016 23:23:06 +0100 Subject: [PATCH 2/3] OFX: Display both bank number and account number in bank statement name Adapt automated test --- .../account_bank_statement_import_ofx.py | 2 +- .../tests/test_import_bank_statement.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/account_bank_statement_import_ofx/account_bank_statement_import_ofx.py b/account_bank_statement_import_ofx/account_bank_statement_import_ofx.py index 2bf7312..cbe5dda 100644 --- a/account_bank_statement_import_ofx/account_bank_statement_import_ofx.py +++ b/account_bank_statement_import_ofx/account_bank_statement_import_ofx.py @@ -84,7 +84,7 @@ class AccountBankStatementImport(models.TransientModel): )) vals_bank_statement = { - 'name': ofx.account.number, + 'name': '%s-%s' % (ofx.account.routing_number, ofx.account.number), 'transactions': transactions, 'balance_start': ofx.account.statement.balance, 'balance_end_real': diff --git a/account_bank_statement_import_ofx/tests/test_import_bank_statement.py b/account_bank_statement_import_ofx/tests/test_import_bank_statement.py index b35afa1..a5d94c5 100644 --- a/account_bank_statement_import_ofx/tests/test_import_bank_statement.py +++ b/account_bank_statement_import_ofx/tests/test_import_bank_statement.py @@ -22,7 +22,7 @@ class TestOfxFile(TransactionCase): dict(data_file=ofx_file)) bank_statement.import_file() bank_st_record = self.bank_statement_model.search( - [('name', '=', '000000123')])[0] + [('name', '=', '000000123-123456')])[0] self.assertEquals(bank_st_record.balance_start, 2156.56) self.assertEquals(bank_st_record.balance_end_real, 1796.56) From e11bd54e227a7c523c906f66745062bc09729a8c Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 9 May 2016 21:33:06 +0200 Subject: [PATCH 3/3] Shorter bank statement name, as requested by Pedro --- .../account_bank_statement_import_ofx.py | 2 +- .../tests/test_import_bank_statement.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/account_bank_statement_import_ofx/account_bank_statement_import_ofx.py b/account_bank_statement_import_ofx/account_bank_statement_import_ofx.py index cbe5dda..2bf7312 100644 --- a/account_bank_statement_import_ofx/account_bank_statement_import_ofx.py +++ b/account_bank_statement_import_ofx/account_bank_statement_import_ofx.py @@ -84,7 +84,7 @@ class AccountBankStatementImport(models.TransientModel): )) vals_bank_statement = { - 'name': '%s-%s' % (ofx.account.routing_number, ofx.account.number), + 'name': ofx.account.number, 'transactions': transactions, 'balance_start': ofx.account.statement.balance, 'balance_end_real': diff --git a/account_bank_statement_import_ofx/tests/test_import_bank_statement.py b/account_bank_statement_import_ofx/tests/test_import_bank_statement.py index a5d94c5..bbcc1bb 100644 --- a/account_bank_statement_import_ofx/tests/test_import_bank_statement.py +++ b/account_bank_statement_import_ofx/tests/test_import_bank_statement.py @@ -22,7 +22,7 @@ class TestOfxFile(TransactionCase): dict(data_file=ofx_file)) bank_statement.import_file() bank_st_record = self.bank_statement_model.search( - [('name', '=', '000000123-123456')])[0] + [('name', '=', '123456')])[0] self.assertEquals(bank_st_record.balance_start, 2156.56) self.assertEquals(bank_st_record.balance_end_real, 1796.56)