From 385fb2bb979a278f68c8d6920a4697ce515d163f Mon Sep 17 00:00:00 2001 From: "Andrea Grazioso (agr-odoo)" Date: Wed, 4 May 2022 14:44:35 +0000 Subject: [PATCH] [FIX] point_of_sale: missing tax mapping in receipt Activate units of measure Create taxes: - [TAXE] not included in price (i.e. 15%) - [TAXI] included in price (i.e 15%) Have a fiscal position mapping [TAXE] to [TAXI] Have a product [PROD]: - Price 10$ - Tax [TAXE] - Unit: g - Purchase Unit: kg In point of sale settings: - Add the fiscal position as default - Display tax included prices Start a pos session, add [PROD] to order, confirm and print receipt The price on order screen and receipt will be wrong, it will take into account the price excluded tax on top of the correct price (final price 11.50, should be 10.30) opw-2688375 closes odoo/odoo#93321 X-original-commit: ff61382c3865a159bb92f873bf82b8ab48426730 Signed-off-by: Grazioso Andrea (agr) --- addons/point_of_sale/static/src/js/models.js | 36 ++++++++------------ 1 file changed, 15 insertions(+), 21 deletions(-) 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);