diff --git a/account_reconcile_oca/models/account_bank_statement_line.py b/account_reconcile_oca/models/account_bank_statement_line.py index 64c2cf2ce0..be18815b93 100644 --- a/account_reconcile_oca/models/account_bank_statement_line.py +++ b/account_reconcile_oca/models/account_bank_statement_line.py @@ -345,11 +345,11 @@ def _reconcile_data_by_model(self, data, reconcile_model, reconcile_auxiliary_id continue new_data.append(line_data) liquidity_amount += line_data["amount"] - for line in reconcile_model._apply_lines_for_bank_widget( - -liquidity_amount, self._retrieve_partner(), self + for line in reconcile_model._get_write_off_move_lines_dict( + -liquidity_amount, self._retrieve_partner() ): new_line = line.copy() - amount = line.get("amount_currency") + amount = line.get("balance") if self.foreign_currency_id: amount = self.foreign_currency_id.compute( amount, self.journal_id.currency_id or self.company_currency_id diff --git a/account_reconcile_oca/tests/test_bank_account_reconcile.py b/account_reconcile_oca/tests/test_bank_account_reconcile.py index 1ab30dedc4..efd79cab5a 100644 --- a/account_reconcile_oca/tests/test_bank_account_reconcile.py +++ b/account_reconcile_oca/tests/test_bank_account_reconcile.py @@ -38,6 +38,13 @@ def setUpClass(cls, chart_template_ref=None): "line_ids": [(0, 0, {"account_id": cls.current_assets_account.id})], } ) + cls.tax_10 = cls.env["account.tax"].create( + { + "name": "tax_10", + "amount_type": "percent", + "amount": 10.0, + } + ) # We need to make some fields visible in order to make the tests work cls.env["ir.ui.view"].create( { @@ -288,12 +295,59 @@ def test_reconcile_model(self): f.manual_model_id = self.rule self.assertTrue(f.can_reconcile) bank_stmt_line.reconcile_bank_line() + self.assertEqual(2, len(bank_stmt_line.move_id.line_ids)) self.assertTrue( bank_stmt_line.move_id.line_ids.filtered( lambda r: r.account_id == self.current_assets_account ) ) + def test_reconcile_model_tax_included(self): + """ + We want to test what happens when we select an reconcile model to fill a + bank statement. + """ + self.rule.line_ids.write( + {"tax_ids": [(4, self.tax_10.id)], "force_tax_included": True} + ) + bank_stmt = self.acc_bank_stmt_model.create( + { + "company_id": self.env.ref("base.main_company").id, + "journal_id": self.bank_journal_euro.id, + "date": time.strftime("%Y-07-15"), + "name": "test", + } + ) + bank_stmt_line = self.acc_bank_stmt_line_model.create( + { + "name": "testLine", + "journal_id": self.bank_journal_euro.id, + "statement_id": bank_stmt.id, + "amount": 100, + "date": time.strftime("%Y-07-15"), + } + ) + with Form( + bank_stmt_line, + view="account_reconcile_oca.bank_statement_line_form_reconcile_view", + ) as f: + self.assertFalse(f.can_reconcile) + f.manual_model_id = self.rule + self.assertTrue(f.can_reconcile) + bank_stmt_line.reconcile_bank_line() + self.assertEqual(3, len(bank_stmt_line.move_id.line_ids)) + self.assertTrue( + bank_stmt_line.move_id.line_ids.filtered( + lambda r: r.account_id == self.current_assets_account + and r.tax_ids == self.tax_10 + ) + ) + self.assertTrue( + bank_stmt_line.move_id.line_ids.filtered( + lambda r: r.tax_line_id == self.tax_10 + ) + ) + def test_reconcile_invoice_model(self): """ We want to test what happens when we select a reconcile model to fill a