From 56af8410525b4877e15e8c78bf9825dfd2dc86dd Mon Sep 17 00:00:00 2001 From: Suherdy Yacob Date: Thu, 21 May 2026 16:38:37 +0700 Subject: [PATCH] fix: update loyalty discount calculation to use tax-inclusive price and correct reward line display price logic --- static/src/overrides/models/loyalty.js | 5 ++++- static/src/overrides/models/orderline.js | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/static/src/overrides/models/loyalty.js b/static/src/overrides/models/loyalty.js index a7ed3dc..1ffbc6e 100755 --- a/static/src/overrides/models/loyalty.js +++ b/static/src/overrides/models/loyalty.js @@ -241,7 +241,10 @@ patch(PosOrder.prototype, { taxIds = this.pos.taxes.filter((tax) => taxIds.includes(tax.id)); } - var discount_amount = -(Math.min(this.priceExcl, entry[1]) * discountFactor); + var discount_amount = -(Math.min(this.priceIncl, entry[1]) * discountFactor); + console.log("DEBUG LOYALTY:", { + discountable, maxDiscount, discountFactor, priceIncl: this.priceIncl, entry_1: entry[1], discount_amount + }); // OVERRIDE: Inject JSON variables (will be automatically assigned in Odoo 19 extraFields, we must make sure these properties are forwarded) lst.push({ product_id: discountProduct, diff --git a/static/src/overrides/models/orderline.js b/static/src/overrides/models/orderline.js index b2f0301..c4ffc28 100644 --- a/static/src/overrides/models/orderline.js +++ b/static/src/overrides/models/orderline.js @@ -62,11 +62,15 @@ patch(PosOrderline.prototype, { let totalDisplayPrice = 0; for (const line of groupLines) { - totalDisplayPrice += line.displayPrice; + totalDisplayPrice += line.priceExcl; } return formatCurrency(totalDisplayPrice, this.currency.id); } + + if (this.is_reward_line) { + return formatCurrency(this.priceExcl, this.currency.id); + } return super.currencyDisplayPrice; },