From a8f409576533c532caba3a0a388ecda5d917d33f Mon Sep 17 00:00:00 2001 From: Suherdy Yacob Date: Tue, 26 May 2026 09:23:33 +0700 Subject: [PATCH] fix: add optional chaining to reward program property access to prevent potential runtime errors --- static/src/app/pos_order_patch.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/static/src/app/pos_order_patch.js b/static/src/app/pos_order_patch.js index 2992912..5bfb8cb 100644 --- a/static/src/app/pos_order_patch.js +++ b/static/src/app/pos_order_patch.js @@ -48,7 +48,7 @@ patch(PosOrder.prototype, { const isDiscount = reward && reward.reward_type === "discount"; const rewardProgram = reward && reward.program_id; // Skip lines for automatic discounts. - if (isDiscount && rewardProgram.trigger === "auto") { + if (isDiscount && rewardProgram?.trigger === "auto") { continue; } @@ -121,8 +121,8 @@ patch(PosOrder.prototype, { if (line.is_reward_line) { const reward = line.reward_id; if ( - program.id === reward.program_id.id || - ["gift_card", "ewallet"].includes(reward.program_id.program_type) + program.id === reward.program_id?.id || + ["gift_card", "ewallet"].includes(reward.program_id?.program_type) ) { continue; }