diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 6bff153e8a1..ec0eede134a 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -1337,13 +1337,14 @@ exports.Orderline = Backbone.Model.extend({ }, compute_all: function(taxes, price_unit, quantity, currency_rounding) { var self = this; - var total_excluded = round_pr(price_unit * quantity, currency_rounding); - var total_included = total_excluded; - var base = total_excluded; var list_taxes = []; + var currency_rounding_bak = currency_rounding; if (this.pos.company.tax_calculation_rounding_method == "round_globally"){ currency_rounding = currency_rounding * 0.00001; } + var total_excluded = round_pr(price_unit * quantity, currency_rounding); + var total_included = total_excluded; + var base = total_excluded; _(taxes).each(function(tax) { tax = self._map_tax_fiscal_position(tax); if (tax.amount_type === 'group'){ @@ -1377,11 +1378,14 @@ exports.Orderline = Backbone.Model.extend({ } } }); - return {taxes: list_taxes, total_excluded: total_excluded, total_included: total_included}; + return { + taxes: list_taxes, + total_excluded: round_pr(total_excluded, currency_rounding_bak), + total_included: round_pr(total_included, currency_rounding_bak) + }; }, get_all_prices: function(){ var price_unit = this.get_unit_price() * (1.0 - (this.get_discount() / 100.0)); - var taxtotal = 0; var product = this.get_product(); var taxes_ids = product.taxes_id; @@ -1397,14 +1401,13 @@ exports.Orderline = Backbone.Model.extend({ var all_taxes = this.compute_all(product_taxes, price_unit, this.get_quantity(), this.pos.currency.rounding); _(all_taxes.taxes).each(function(tax) { - taxtotal += tax.amount; taxdetail[tax.id] = tax.amount; }); return { "priceWithTax": all_taxes.total_included, "priceWithoutTax": all_taxes.total_excluded, - "tax": taxtotal, + "tax": all_taxes.total_included - all_taxes.total_excluded, "taxDetails": taxdetail, }; },