diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 7b32d759987..457a7acbaff 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -1572,6 +1572,19 @@ class Orderline extends PosModel { var rounding = this.pos.currency.rounding; return round_pr(this.get_unit_price() * this.get_quantity() * (1 - this.get_discount()/100), rounding); } + get_taxes_after_fp(taxes_ids){ + var self = this; + var taxes = this.pos.taxes; + var product_taxes = []; + _(taxes_ids).each(function(el){ + var tax = _.detect(taxes, function(t){ + return t.id === el; + }); + product_taxes.push.apply(product_taxes, self._map_tax_fiscal_position(tax, self.order)); + }); + product_taxes = _.uniq(product_taxes, function(tax) { return tax.id; }); + return product_taxes; + } get_display_price_one(){ var rounding = this.pos.currency.rounding; var price_unit = this.get_unit_price(); @@ -1580,15 +1593,7 @@ class Orderline extends PosModel { } else { var product = this.get_product(); var taxes_ids = this.tax_ids || product.taxes_id; - var taxes = this.pos.taxes; - var product_taxes = []; - - _(taxes_ids).each(function(el){ - product_taxes.push(_.detect(taxes, function(t){ - return t.id === el; - })); - }); - + var product_taxes = this.get_taxes_after_fp(taxes_ids); var all_taxes = this.compute_all(product_taxes, price_unit, 1, this.pos.currency.rounding); return round_pr(all_taxes.total_included * (1 - this.get_discount()/100), rounding); @@ -1851,25 +1856,14 @@ class Orderline extends PosModel { } } get_all_prices(qty = this.get_quantity()){ - var self = this; - 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 = this.tax_ids || product.taxes_id; taxes_ids = _.filter(taxes_ids, t => t in this.pos.taxes_by_id); - var taxes = this.pos.taxes; var taxdetail = {}; - var product_taxes = []; - - _(taxes_ids).each(function(el){ - var tax = _.detect(taxes, function(t){ - return t.id === el; - }); - product_taxes.push.apply(product_taxes, self._map_tax_fiscal_position(tax, self.order)); - }); - product_taxes = _.uniq(product_taxes, function(tax) { return tax.id; }); + var product_taxes = this.get_taxes_after_fp(taxes_ids); var all_taxes = this.compute_all(product_taxes, price_unit, qty, this.pos.currency.rounding); var all_taxes_before_discount = this.compute_all(product_taxes, this.get_unit_price(), qty, this.pos.currency.rounding);