Skip to content

Commit

Permalink
[IMP] account_reconcile_oca: Include taxes from models
Browse files Browse the repository at this point in the history
Fixes #576
  • Loading branch information
etobella committed Aug 26, 2023
1 parent afed064 commit db499a7
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 3 deletions.
6 changes: 3 additions & 3 deletions account_reconcile_oca/models/account_bank_statement_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
54 changes: 54 additions & 0 deletions account_reconcile_oca/tests/test_bank_account_reconcile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit db499a7

Please sign in to comment.