diff options
| author | Cedric Snauwaert <csn@openerp.com> | 2020-02-04 14:42:16 +0000 |
|---|---|---|
| committer | Cedric Snauwaert <csn@openerp.com> | 2020-03-19 10:30:42 +0000 |
| commit | eee8ecdc0217ece1af28b850d1dcaaa528301682 (patch) | |
| tree | 43f713fdb2c77564319594795155d55d2a9e6dab /addons | |
| parent | 3590efa47849be09e694e7755ec640f41cb14313 (diff) | |
[FIX] account: fix rounding error in is_valid_balance_start check
Field is_valid_balance_check is used to display a warning in case
starting balance of a bank statement is not the same as ending balance
of the previous statement. However the check was done without rounding
resulting in some error in the following casse:
starting_balance = 10.00000001
previous_ending_balance = 10
X-original-commit: 6673d23cfdee97b1e5e6368bc527a9a784578977
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/account/models/account_bank_statement.py | 2 | ||||
| -rw-r--r-- | addons/account/tests/test_account_bank_statement.py | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/addons/account/models/account_bank_statement.py b/addons/account/models/account_bank_statement.py index d74862a500b..dc32b00894b 100644 --- a/addons/account/models/account_bank_statement.py +++ b/addons/account/models/account_bank_statement.py @@ -201,7 +201,7 @@ class AccountBankStatement(models.Model): @api.depends('balance_start', 'previous_statement_id') def _compute_is_valid_balance_start(self): for bnk in self: - bnk.is_valid_balance_start = bnk.balance_start == bnk.previous_statement_id.balance_end_real + bnk.is_valid_balance_start = float_is_zero(bnk.balance_start - bnk.previous_statement_id.balance_end_real, precision_digits=bnk.currency_id.decimal_places) @api.depends('date', 'journal_id') def _get_previous_statement(self): diff --git a/addons/account/tests/test_account_bank_statement.py b/addons/account/tests/test_account_bank_statement.py index 6cd7b9820d7..3ac0030d2cc 100644 --- a/addons/account/tests/test_account_bank_statement.py +++ b/addons/account/tests/test_account_bank_statement.py @@ -191,6 +191,14 @@ class TestBankStatement(AccountTestCommon): self.assertEqual(cash2.balance_start, 200) self.assertEqual(cash2.balance_end_real, 1000) + def test_is_valid_balance_start(self): + bnk1 = self.create_bank_statement('2019-01-01', 100, 100.0000001) + bnk2 = self.create_bank_statement('2019-01-10', 50) + bnk2.write({'balance_start': 100}) + self.assertTrue(bnk2.is_valid_balance_start) + bnk2.write({'balance_start': 100.01}) + self.assertFalse(bnk2.is_valid_balance_start) + def test_unlink_bank_statement(self): bnk1 = self.create_bank_statement('2019-01-02', 100) bnk2 = self.create_bank_statement('2019-01-10', 50) |
