[FIX] account: decrease value from tax in reconcile model
opw-2294930 The tax amount not included in price should be computed in the remaining balance, even if not included in price. closes odoo/odoo#54356 X-original-commit: 6a6aefdfac472421b9cf6de043682a6cdc131d85 Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
This commit is contained in:
@@ -323,7 +323,11 @@ class AccountReconcileModel(models.Model):
|
||||
# only allow to set the force_tax_included field if we have one tax selected
|
||||
if line.force_tax_included:
|
||||
tax = tax[0].with_context(force_price_include=True)
|
||||
lines_vals_list += self._get_taxes_move_lines_dict(tax, writeoff_line)
|
||||
tax_vals_list = self._get_taxes_move_lines_dict(tax, writeoff_line)
|
||||
lines_vals_list += tax_vals_list
|
||||
if not line.force_tax_included:
|
||||
for tax_line in tax_vals_list:
|
||||
residual_balance -= tax_line['balance']
|
||||
|
||||
return lines_vals_list
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ class TestReconciliationMatchingRules(AccountTestInvoicingCommon):
|
||||
cls.invoice_line_3.move_id.name = "RBILL/2019/09/0013" # Without demo data, avoid to match with the first invoice
|
||||
cls.invoice_line_4 = cls._create_invoice_line(1000, cls.partner_2, 'in_invoice')
|
||||
|
||||
current_assets_account = cls.env['account.account'].search([
|
||||
cls.current_assets_account = cls.env['account.account'].search([
|
||||
('user_type_id', '=', cls.env.ref('account.data_account_type_current_assets').id),
|
||||
('company_id', '=', cls.company.id)], limit=1)
|
||||
|
||||
@@ -55,7 +55,7 @@ class TestReconciliationMatchingRules(AccountTestInvoicingCommon):
|
||||
})
|
||||
|
||||
cls.rule_1 = cls.rule_0.copy()
|
||||
cls.rule_1.write({'line_ids': [(0, 0, {'account_id': current_assets_account.id})]})
|
||||
cls.rule_1.write({'line_ids': [(0, 0, {'account_id': cls.current_assets_account.id})]})
|
||||
cls.rule_1.match_partner = True
|
||||
cls.rule_1.match_partner_ids |= cls.partner_1 + cls.partner_2
|
||||
cls.rule_2 = cls.env['account.reconcile.model'].create({
|
||||
@@ -63,7 +63,7 @@ class TestReconciliationMatchingRules(AccountTestInvoicingCommon):
|
||||
'rule_type': 'writeoff_suggestion',
|
||||
'match_partner': True,
|
||||
'match_partner_ids': [],
|
||||
'line_ids': [(0, 0, {'account_id': current_assets_account.id})],
|
||||
'line_ids': [(0, 0, {'account_id': cls.current_assets_account.id})],
|
||||
})
|
||||
|
||||
invoice_number = cls.invoice_line_1.move_id.name
|
||||
@@ -106,6 +106,12 @@ class TestReconciliationMatchingRules(AccountTestInvoicingCommon):
|
||||
'amount': 21,
|
||||
})
|
||||
|
||||
cls.tax12 = cls.env['account.tax'].create({
|
||||
'name': '12%',
|
||||
'type_tax_use': 'purchase',
|
||||
'amount': 12,
|
||||
})
|
||||
|
||||
@classmethod
|
||||
def _create_invoice_line(cls, amount, partner, type, currency=None):
|
||||
''' Create an invoice on the fly.'''
|
||||
@@ -356,8 +362,14 @@ class TestReconciliationMatchingRules(AccountTestInvoicingCommon):
|
||||
'auto_reconcile': True,
|
||||
'rule_type': 'writeoff_suggestion',
|
||||
'line_ids': [(1, self.rule_1.line_ids.id, {
|
||||
'amount': 50,
|
||||
'force_tax_included': True,
|
||||
'tax_ids': [(6, 0, self.tax21.ids)],
|
||||
}), (0, 0, {
|
||||
'amount': 100,
|
||||
'force_tax_included': False,
|
||||
'tax_ids': [(6, 0, self.tax12.ids)],
|
||||
'account_id': self.current_assets_account.id,
|
||||
})]
|
||||
})
|
||||
|
||||
@@ -376,8 +388,11 @@ class TestReconciliationMatchingRules(AccountTestInvoicingCommon):
|
||||
# Check first line has been well reconciled.
|
||||
self.assertRecordValues(self.bank_line_1.line_ids, [
|
||||
{'partner_id': self.partner_1.id, 'debit': 0.0, 'credit': 121.0, 'tax_ids': [], 'tax_line_id': False},
|
||||
{'partner_id': self.partner_1.id, 'debit': 100.0, 'credit': 0.0, 'tax_ids': [self.tax21.id], 'tax_line_id': False},
|
||||
{'partner_id': self.partner_1.id, 'debit': 21.0, 'credit': 0.0, 'tax_ids': [], 'tax_line_id': self.tax21.id},
|
||||
{'partner_id': self.partner_1.id, 'debit': 0.0, 'credit': 7.26, 'tax_ids': [], 'tax_line_id': False},
|
||||
{'partner_id': self.partner_1.id, 'debit': 50.0, 'credit': 0.0, 'tax_ids': [self.tax21.id], 'tax_line_id': False},
|
||||
{'partner_id': self.partner_1.id, 'debit': 10.5, 'credit': 0.0, 'tax_ids': [], 'tax_line_id': self.tax21.id},
|
||||
{'partner_id': self.partner_1.id, 'debit': 60.5, 'credit': 0.0, 'tax_ids': [self.tax12.id], 'tax_line_id': False},
|
||||
{'partner_id': self.partner_1.id, 'debit': 7.26, 'credit': 0.0, 'tax_ids': [], 'tax_line_id': self.tax12.id},
|
||||
])
|
||||
|
||||
def test_reverted_move_matching(self):
|
||||
|
||||
Reference in New Issue
Block a user