From f17f353cbd5f33f115408b18af5354e11c3b01c1 Mon Sep 17 00:00:00 2001 From: Suherdy Yacob Date: Tue, 26 May 2026 09:23:49 +0700 Subject: [PATCH] fix: add optional chaining to reward.program_id access to prevent errors in loyalty logic --- static/src/overrides/models/loyalty.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/static/src/overrides/models/loyalty.js b/static/src/overrides/models/loyalty.js index 1e9f0b2..da48f66 100755 --- a/static/src/overrides/models/loyalty.js +++ b/static/src/overrides/models/loyalty.js @@ -24,7 +24,7 @@ patch(PosOrder.prototype, { continue; } - const taxKey = ['ewallet', 'gift_card'].includes(reward.program_id.program_type) + const taxKey = ['ewallet', 'gift_card'].includes(reward.program_id?.program_type) ? line.tax_ids.map((t) => t.id) : line.tax_ids.filter((t) => t.amount_type !== 'fixed').map((t) => t.id); @@ -181,7 +181,7 @@ patch(PosOrder.prototype, { let maxDiscount = reward.discount_max_amount || Infinity; if (reward.discount_mode === "per_point") { // Rewards cannot be partially offered to customers - const points = ["ewallet", "gift_card"].includes(reward.program_id.program_type) + const points = ["ewallet", "gift_card"].includes(reward.program_id?.program_type) ? this._getRealCouponPoints(coupon_id) : Math.floor(this._getRealCouponPoints(coupon_id) / reward.required_points) * reward.required_points; @@ -203,7 +203,7 @@ patch(PosOrder.prototype, { // These are considered payments and do not require to be either taxed or split by tax const discountProduct = reward.discount_line_product_id; - if (["ewallet", "gift_card"].includes(reward.program_id.program_type)) { + if (["ewallet", "gift_card"].includes(reward.program_id?.program_type)) { const price = discountProduct.getTaxDetails({ overridedValues: { tax_ids: discountProduct.taxes_id,