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..695d095 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 @@ -83,12 +83,12 @@ class AccountBankStatementImport(models.TransientModel): "The file might not be valid.\n\n %s" % e.message )) + balance = float(ofx.account.statement.balance) vals_bank_statement = { 'name': ofx.account.number, 'transactions': transactions, - 'balance_start': ofx.account.statement.balance, - 'balance_end_real': - float(ofx.account.statement.balance) + total_amt, + 'balance_start': balance - total_amt, + 'balance_end_real': balance, } return ofx.account.statement.currency, ofx.account.number, [ vals_bank_statement] 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 bbcc1bb..13e622e 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 @@ -23,8 +23,8 @@ class TestOfxFile(TransactionCase): bank_statement.import_file() bank_st_record = self.bank_statement_model.search( [('name', '=', '123456')])[0] - self.assertEquals(bank_st_record.balance_start, 2156.56) - self.assertEquals(bank_st_record.balance_end_real, 1796.56) + self.assertEquals(bank_st_record.balance_start, 2516.56) + self.assertEquals(bank_st_record.balance_end_real, 2156.56) line = bank_st_record.line_ids[0] self.assertEquals(line.name, 'Agrolait')