[FIX] account: tax total computation fix
Fixes an issue with the tax total computation that would happen
if the tax of type group has the same tax_group_id as one of the
children taxes.
This would lead to a tax total computation where the other child
of the tax will be summed into the child sharing the same tax
group.
As it is no longer possible to set a tax group id on a tax of
type group, we do not need to take it into account when computing
the tax total anymore.
To reproduce before the fix:
- Make a bill with the Australian tax au_tax_purchase_10_service_tpar_no_abn.
- Save.
- You will notice that the amount in the tax total widget for the tax
"GST 10%" is wrong as it takes into account the amount of the other
tax.
After the fix, the amount will not be wrongly grouped anymore. And the
tax total will correctly represent what is in the line_ids.
Task id # 3252271
closes odoo/odoo#117093
X-original-commit: aa736d7d0189784e6ff81b7acfcd0ac0e1cbe6b7
Signed-off-by: Laurent Smet <las@odoo.com>
Signed-off-by: Nicolas Viseur (vin) <vin@odoo.com>
This commit is contained in:
@@ -1197,7 +1197,7 @@ class AccountTax(models.Model):
|
||||
matched_tax_lines = [
|
||||
x
|
||||
for x in tax_lines
|
||||
if (x['group_tax'] or x['tax_repartition_line'].tax_id).tax_group_id == tax_detail['tax_group']
|
||||
if x['tax_repartition_line'].tax_id.tax_group_id == tax_detail['tax_group']
|
||||
]
|
||||
if matched_tax_lines:
|
||||
tax_group_vals['tax_amount'] = sum(x['tax_amount'] for x in matched_tax_lines)
|
||||
|
||||
@@ -617,3 +617,62 @@ class TestTaxTotals(AccountTestInvoicingCommon):
|
||||
}],
|
||||
'subtotals_order': ["Tax exemption", "Tax application", "Reapply amount"],
|
||||
})
|
||||
|
||||
def test_invoice_grouped_taxes_with_tax_group(self):
|
||||
""" A tax of type group with a tax_group_id being the same as one of the children tax shouldn't affect the
|
||||
result of the _prepare_tax_totals.
|
||||
"""
|
||||
tax_10_withheld = self.env['account.tax'].create({
|
||||
'name': "tax_10_withheld",
|
||||
'amount_type': 'group',
|
||||
'tax_group_id': self.tax_group1.id,
|
||||
'children_tax_ids': [
|
||||
Command.create({
|
||||
'name': "tax_withheld",
|
||||
'amount_type': 'percent',
|
||||
'amount': -47,
|
||||
'tax_group_id': self.tax_group_sub1.id,
|
||||
'sequence': 1,
|
||||
}),
|
||||
Command.create({
|
||||
'name': "tax_10",
|
||||
'amount_type': 'percent',
|
||||
'amount': 10,
|
||||
'tax_group_id': self.tax_group1.id,
|
||||
'sequence': 2,
|
||||
}),
|
||||
]
|
||||
})
|
||||
self.tax_group_sub1.preceding_subtotal = "Tax withholding"
|
||||
|
||||
document = self._create_document_for_tax_totals_test([
|
||||
(100, tax_10_withheld),
|
||||
])
|
||||
|
||||
self.assertTaxTotals(document, {
|
||||
'amount_total': 63,
|
||||
'amount_untaxed': 100,
|
||||
'display_tax_base': True,
|
||||
'groups_by_subtotal': {
|
||||
'Untaxed Amount': [{
|
||||
'tax_group_name': self.tax_group1.name,
|
||||
'tax_group_amount': 10,
|
||||
'tax_group_base_amount': 100,
|
||||
'tax_group_id': self.tax_group1.id,
|
||||
}],
|
||||
"Tax withholding": [{
|
||||
'tax_group_name': self.tax_group_sub1.name,
|
||||
'tax_group_amount': -47,
|
||||
'tax_group_base_amount': 100,
|
||||
'tax_group_id': self.tax_group_sub1.id,
|
||||
}],
|
||||
},
|
||||
'subtotals': [{
|
||||
'name': "Untaxed Amount",
|
||||
'amount': 100,
|
||||
}, {
|
||||
'name': "Tax withholding",
|
||||
'amount': 110,
|
||||
}],
|
||||
'subtotals_order': ["Untaxed Amount", "Tax withholding"],
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user