Skip to content

Commit c0c0130

Browse files
committed
[FIX] account: Ref rounding of tax_details for better handling of price-included
== Fix bug price-included == Suppose a line of 24.99 with a 20% tax price-included. base: 24.99 / 1.2 = 20.825 tax: 20.825 * 0.2 = 4.165 If we round both, we get 20.83 + 4.17 = 25.0 != 24.99 == Split and simplify round_base_line_tax_details == Easier implementation of this method to be easier to understand and easier to be customized (see PT override). Also, we now use the aggregate methods to aggregate the amounts instead of doing that by hand. opw-4505888 closes odoo#232186 X-original-commit: 5c19c3c Related: odoo/enterprise#97553 Signed-off-by: Antoine Dupuis (andu) <[email protected]> Signed-off-by: Laurent Smet (las) <[email protected]>
1 parent 0bee7e3 commit c0c0130

File tree

21 files changed

+2319
-2139
lines changed

21 files changed

+2319
-2139
lines changed

addons/account/models/account_tax.py

Lines changed: 562 additions & 492 deletions
Large diffs are not rendered by default.

addons/account/static/src/helpers/account_tax.js

Lines changed: 535 additions & 559 deletions
Large diffs are not rendered by default.

addons/account/tests/test_taxes_base_lines_tax_details.py

Lines changed: 54 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,56 @@ def test_dispatch_delta_on_base_lines(self):
1212
tax_21 = self.percent_tax(21.0)
1313
document = self.populate_document(self.init_document(
1414
lines=[
15-
{'quantity': 1, 'price_unit': 10.04, 'discount': 10, 'tax_ids': tax_21},
15+
{'price_unit': 10.04, 'discount': 10, 'tax_ids': tax_21},
1616
] + [
17-
{'quantity': 1, 'price_unit': 1.04, 'discount': 10, 'tax_ids': tax_21},
17+
{'price_unit': 1.04, 'discount': 10, 'tax_ids': tax_21},
1818
] * 10,
1919
))
2020

21+
line_1_expected_values = {
22+
'total_excluded': 9.04,
23+
'total_excluded_currency': 9.04,
24+
'total_included': 10.94,
25+
'total_included_currency': 10.94,
26+
'delta_total_excluded': 0.0,
27+
'delta_total_excluded_currency': 0.0,
28+
'taxes_data': [
29+
{
30+
'tax_id': tax_21.id,
31+
'tax_amount': 1.88,
32+
'tax_amount_currency': 1.88,
33+
'base_amount': 9.02,
34+
'base_amount_currency': 9.02,
35+
}
36+
],
37+
}
38+
line_2_expected_values = {
39+
'total_excluded': 0.94,
40+
'total_excluded_currency': 0.94,
41+
'total_included': 1.14,
42+
'total_included_currency': 1.14,
43+
'delta_total_excluded': 0.0,
44+
'delta_total_excluded_currency': 0.0,
45+
'taxes_data': [
46+
{
47+
'tax_id': tax_21.id,
48+
'tax_amount': 0.2,
49+
'tax_amount_currency': 0.2,
50+
'base_amount': 0.94,
51+
'base_amount_currency': 0.94,
52+
}
53+
],
54+
}
55+
2156
expected_values = {
2257
'base_lines_tax_details': [
2358
{
24-
'total_excluded': 9.04,
25-
'total_excluded_currency': 9.04,
26-
'total_included': 10.94,
27-
'total_included_currency': 10.94,
28-
'delta_total_excluded': -0.01,
29-
'delta_total_excluded_currency': -0.01,
30-
'taxes_data': [
31-
{
32-
'tax_id': tax_21.id,
33-
'tax_amount': 1.88,
34-
'tax_amount_currency': 1.88,
35-
'base_amount': 9.02,
36-
'base_amount_currency': 9.02,
37-
}
38-
],
59+
**line_1_expected_values,
60+
'delta_total_excluded': -0.02,
61+
'delta_total_excluded_currency': -0.02,
3962
},
40-
]
41-
+ 2 * [
4263
{
43-
'total_excluded': 0.94,
44-
'total_excluded_currency': 0.94,
45-
'total_included': 1.14,
46-
'total_included_currency': 1.14,
64+
**line_2_expected_values,
4765
'delta_total_excluded': -0.01,
4866
'delta_total_excluded_currency': -0.01,
4967
'taxes_data': [
@@ -56,45 +74,29 @@ def test_dispatch_delta_on_base_lines(self):
5674
}
5775
],
5876
},
59-
]
60-
+ [
6177
{
62-
'total_excluded': 0.94,
63-
'total_excluded_currency': 0.94,
64-
'total_included': 1.14,
65-
'total_included_currency': 1.14,
78+
**line_2_expected_values,
6679
'delta_total_excluded': -0.01,
6780
'delta_total_excluded_currency': -0.01,
6881
'taxes_data': [
6982
{
7083
'tax_id': tax_21.id,
71-
'tax_amount': 0.2,
72-
'tax_amount_currency': 0.2,
73-
'base_amount': 0.94,
74-
'base_amount_currency': 0.94,
84+
'tax_amount': 0.19,
85+
'tax_amount_currency': 0.19,
86+
'base_amount': 0.9299999999999999,
87+
'base_amount_currency': 0.9299999999999999,
7588
}
7689
],
7790
},
91+
line_2_expected_values,
92+
line_2_expected_values,
93+
line_2_expected_values,
94+
line_2_expected_values,
95+
line_2_expected_values,
96+
line_2_expected_values,
97+
line_2_expected_values,
98+
line_2_expected_values,
7899
]
79-
+ 7 * [
80-
{
81-
'total_excluded': 0.94,
82-
'total_excluded_currency': 0.94,
83-
'total_included': 1.14,
84-
'total_included_currency': 1.14,
85-
'delta_total_excluded': 0.0,
86-
'delta_total_excluded_currency': 0.0,
87-
'taxes_data': [
88-
{
89-
'tax_id': tax_21.id,
90-
'tax_amount': 0.2,
91-
'tax_amount_currency': 0.2,
92-
'base_amount': 0.94,
93-
'base_amount_currency': 0.94,
94-
}
95-
],
96-
},
97-
],
98100
}
99101

100102
self.assert_base_lines_tax_details(document, expected_values)

0 commit comments

Comments
 (0)