diff options
| author | Laurent Smet <las@odoo.com> | 2021-04-13 06:41:01 +0000 |
|---|---|---|
| committer | Laurent Smet <las@odoo.com> | 2021-04-13 14:42:15 +0000 |
| commit | c8c68a07199124091e8d49946a63fb8c705c2417 (patch) | |
| tree | 876c3ca5396f878473c9888b4e1e23b3433019fe /addons/point_of_sale/static/src | |
| parent | 5b56dbfd8eb3284d670280f2e86a35ab10776e92 (diff) | |
[FIX] account,point_of_sale: Allow mixing 'affect base' price-included/price-excluded taxes
Before this commit, such configuration wasn't allowed.
However, in some countries, this is mandatory, when dealing with eco-tax for example:
Suppose t1, t2 being taxes where:
- t1 is include_base_amount, price_excluded, fixed tax of 10 (eco-tax)
- t2 is include_base_amount, price_included, percent of 21%
The computation on 1210 should be:
price_excluded: 1210 / 1.21 = 1000
price_included: (1000 + 10) * 1.21 = 1222.1
closes odoo/odoo#69184
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
Diffstat (limited to 'addons/point_of_sale/static/src')
| -rw-r--r-- | addons/point_of_sale/static/src/js/models.js | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 4423904b722..3c9aa1ed5c8 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -2153,21 +2153,7 @@ exports.Orderline = Backbone.Model.extend({ taxes = collect_taxes(taxes); - // 2) Avoid dealing with taxes mixing price_include=False && include_base_amount=True - // with price_include=True - - var base_excluded_flag = false; // price_include=False && include_base_amount=True - var included_flag = false; // price_include=True - _(taxes).each(function(tax){ - if(tax.price_include) - included_flag = true; - else if(tax.include_base_amount) - base_excluded_flag = true; - if(base_excluded_flag && included_flag) - throw new Error('Unable to mix any taxes being price included with taxes affecting the base amount but not included in price.'); - }); - - // 3) Deal with the rounding methods + // 2) Deal with the rounding methods var round_tax = this.pos.company.tax_calculation_rounding_method != 'round_globally'; @@ -2175,7 +2161,7 @@ exports.Orderline = Backbone.Model.extend({ if(!round_tax) currency_rounding = currency_rounding * 0.00001; - // 4) Iterate the taxes in the reversed sequence order to retrieve the initial base of the computation. + // 3) Iterate the taxes in the reversed sequence order to retrieve the initial base of the computation. var recompute_base = function(base_amount, fixed_amount, percent_amount, division_amount){ return (base_amount - fixed_amount) / (1.0 + percent_amount / 100.0) * (100 - division_amount) / 100; } @@ -2230,15 +2216,17 @@ exports.Orderline = Backbone.Model.extend({ var total_excluded = round_pr(recompute_base(base, incl_fixed_amount, incl_percent_amount, incl_division_amount), initial_currency_rounding); var total_included = total_excluded; - // 5) Iterate the taxes in the sequence order to fill missing base/amount values. + // 4) Iterate the taxes in the sequence order to fill missing base/amount values. base = total_excluded; + var skip_checkpoint = false; + var taxes_vals = []; i = 0; var cumulated_tax_included_amount = 0; _(taxes.reverse()).each(function(tax){ - if(tax.price_include && total_included_checkpoints[i] !== undefined){ + if(!skip_checkpoint && tax.price_include && total_included_checkpoints[i] !== undefined){ var tax_amount = total_included_checkpoints[i] - (base + cumulated_tax_included_amount); cumulated_tax_included_amount = 0; }else @@ -2256,8 +2244,11 @@ exports.Orderline = Backbone.Model.extend({ 'base': sign * round_pr(base, currency_rounding), }); - if(tax.include_base_amount) + if(tax.include_base_amount){ base += tax_amount; + if(!tax.price_include) + skip_checkpoint = true; + } total_included += tax_amount; i += 1; |
