[FIX] account: wrong calculation for 'not included in price' group taxes
Issue
- Install 'Accounting' app
- Create tax A and tax B for 5%, make sure they are NOT included in price
- Create a tax C as a group that includes Tax A and B
- Go to any bank journal and create a statement line for 100 dlls
- Click Reconcile
- Select Manual Operations
- Select any account
- Add Tax C
- Check on 'Tax Included in Price'
Wrong calculation.
Cause
Not considering forced 'Tax Included in Price'
('force_price_include'),when cumulating tax included
amount.
opw-2280714
closes odoo/odoo#54003
X-original-commit: 523e407e164d96ead0ce836e3dc1a6bb8f258af9
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
Signed-off-by: bon-odoo <nboulif@users.noreply.github.com>
This commit is contained in:
@@ -489,8 +489,10 @@ class AccountTax(models.Model):
|
||||
tax_repartition_lines = (is_refund and tax.refund_repartition_line_ids or tax.invoice_repartition_line_ids).filtered(lambda x: x.repartition_type == 'tax')
|
||||
sum_repartition_factor = sum(tax_repartition_lines.mapped('factor'))
|
||||
|
||||
price_include = self._context.get('force_price_include', tax.price_include)
|
||||
|
||||
#compute the tax_amount
|
||||
if (self._context.get('force_price_include') or tax.price_include) and total_included_checkpoints.get(i):
|
||||
if price_include and total_included_checkpoints.get(i):
|
||||
# We know the total to reach for that tax, so we make a substraction to avoid any rounding issues
|
||||
tax_amount = total_included_checkpoints[i] - (base + cumulated_tax_included_amount)
|
||||
cumulated_tax_included_amount = 0
|
||||
@@ -502,7 +504,7 @@ class AccountTax(models.Model):
|
||||
tax_amount = round(tax_amount, prec)
|
||||
factorized_tax_amount = round(tax_amount * sum_repartition_factor, prec)
|
||||
|
||||
if tax.price_include and not total_included_checkpoints.get(i):
|
||||
if price_include and not total_included_checkpoints.get(i):
|
||||
cumulated_tax_included_amount += factorized_tax_amount
|
||||
|
||||
# If the tax affects the base of subsequent taxes, its tax move lines must
|
||||
@@ -541,7 +543,7 @@ class AccountTax(models.Model):
|
||||
'sequence': tax.sequence,
|
||||
'account_id': tax.cash_basis_transition_account_id.id if tax.tax_exigibility == 'on_payment' else repartition_line.account_id.id,
|
||||
'analytic': tax.analytic,
|
||||
'price_include': tax.price_include or self._context.get('force_price_include'),
|
||||
'price_include': price_include,
|
||||
'tax_exigibility': tax.tax_exigibility,
|
||||
'tax_repartition_line_id': repartition_line.id,
|
||||
'tag_ids': (repartition_line.tag_ids + subsequent_tags).ids,
|
||||
|
||||
@@ -66,6 +66,16 @@ class TestTaxCommon(AccountTestInvoicingCommon):
|
||||
(4, cls.percent_tax.id, 0)
|
||||
]
|
||||
})
|
||||
cls.group_tax_percent = cls.env['account.tax'].create({
|
||||
'name': "Group tax percent",
|
||||
'amount_type': 'group',
|
||||
'amount': 0,
|
||||
'sequence': 6,
|
||||
'children_tax_ids': [
|
||||
(4, cls.percent_tax.id, 0),
|
||||
(4, cls.percent_tax_bis.id, 0)
|
||||
]
|
||||
})
|
||||
cls.group_of_group_tax = cls.env['account.tax'].create({
|
||||
'name': "Group of group tax",
|
||||
'amount_type': 'group',
|
||||
@@ -190,6 +200,21 @@ class TestTax(TestTaxCommon):
|
||||
res
|
||||
)
|
||||
|
||||
def test_tax_group_percent(self):
|
||||
res = self.group_tax_percent.with_context({'force_price_include':True}).compute_all(100.0)
|
||||
self._check_compute_all_results(
|
||||
100, # 'total_included'
|
||||
83.33, # 'total_excluded'
|
||||
[
|
||||
# base , amount | seq | amount | incl | incl_base
|
||||
# ---------------------------------------------------
|
||||
(83.33, 8.33), # | 1 | 10% | |
|
||||
(83.33, 8.34), # | 2 | 10% | |
|
||||
# ---------------------------------------------------
|
||||
],
|
||||
res
|
||||
)
|
||||
|
||||
def test_tax_percent_division(self):
|
||||
self.division_tax.price_include = True
|
||||
self.division_tax.include_base_amount = True
|
||||
|
||||
Reference in New Issue
Block a user