From 5d5fbb8d93fea834dc51b29a6190b2739ef739e4 Mon Sep 17 00:00:00 2001 From: Thibault Francois Date: Mon, 6 Jun 2016 00:05:28 +0200 Subject: [PATCH] [FIX] wrong unique ID + find the iban when give the bban account number --- beesdoo_coda/wizard/import_coda.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/beesdoo_coda/wizard/import_coda.py b/beesdoo_coda/wizard/import_coda.py index bc9c88a..256dc68 100644 --- a/beesdoo_coda/wizard/import_coda.py +++ b/beesdoo_coda/wizard/import_coda.py @@ -33,7 +33,7 @@ class CodaBankStatementImport(models.TransientModel): 'partner_name': move.counterparty_name, #ok 'ref': move.ref, 'sequence': sequence, #ok - 'unique_import_id' : statement.coda_seq_number + '-' + statement.creation_date + '-' + move.ref + 'unique_import_id' : statement.coda_seq_number + '-' + statement.new_balance_date + '-' + move.ref } return move_data @@ -47,6 +47,14 @@ class CodaBankStatementImport(models.TransientModel): 'transactions' : [] } return statement_data + + def _get_acc_number(self, acc_number): + #Check if we match the exact acc_number or the end of an acc number + journal = self.env['account.journal'].search([('bank_acc_number', '=like', '%' + acc_number)]) + if not journal or len(journal) > 1: #if not found or ambiguious + return acc_number + + return journal.bank_acc_number def _parse_file(self, data_file): parser = Parser() @@ -66,4 +74,4 @@ class CodaBankStatementImport(models.TransientModel): for move in statement.movements: statement_data['transactions'].append(self._get_move_value(move, statement, len(statement_data['transactions']) + 1)) - return currency_code, account_number, stmts_vals + return currency_code, self._get_acc_number(account_number), stmts_vals