diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 61e2d26c301..20f8059df6f 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -2392,9 +2392,13 @@ export class Orderline extends PosModel { * @returns {Number} the total amount of price included taxes */ get_total_taxes_included_in_price() { - return this.get_taxes() - .filter((tax) => tax.price_include) - .reduce((sum, tax) => sum + this.get_tax_details()[tax.id], 0); + const productTaxes = this._getProductTaxesAfterFiscalPosition(); + const taxDetails = this.get_tax_details(); + return productTaxes + .filter(tax => tax.price_include) + .reduce((sum, tax) => sum + taxDetails[tax.id], + 0 + ); } _map_tax_fiscal_position(tax, order = false) { return this.pos._map_tax_fiscal_position(tax, order); @@ -2421,6 +2425,17 @@ export class Orderline extends PosModel { handle_price_include ); } + /** + * Calculates the taxes for a product, and converts the taxes based on the fiscal position of the order. + * + * @returns {Object} The calculated product taxes after filtering and fiscal position conversion. + */ + _getProductTaxesAfterFiscalPosition() { + const product = this.get_product(); + let taxesIds = this.tax_ids || product.taxes_id; + taxesIds = _.filter(taxesIds, t => t in this.pos.taxes_by_id); + return this.pos.get_taxes_after_fp(taxesIds, this.order.fiscal_position); + } get_all_prices(qty = this.get_quantity()) { var price_unit = this.get_unit_price() * (1.0 - this.get_discount() / 100.0); var taxtotal = 0; @@ -3291,7 +3306,7 @@ export class Order extends PosModel { } _get_tax_group_key(line) { return line - .get_taxes() + ._getProductTaxesAfterFiscalPosition() .map((tax) => tax.id) .join(","); }