fix: add null checks for reward object in pos_order_patch to prevent runtime errors

This commit is contained in:
Suherdy Yacob 2026-05-29 16:37:20 +07:00
parent 25ef115aa4
commit 3b8a2d8f4b

View File

@ -18,7 +18,7 @@ patch(PosOrder.prototype, {
for (const rule of program.rule_ids) { for (const rule of program.rule_ids) {
for (const line of rewardLines) { for (const line of rewardLines) {
const reward = line.reward_id; const reward = line.reward_id;
if (this._validForPointsCorrection(reward, line, rule)) { if (reward && this._validForPointsCorrection(reward, line, rule)) {
if (rule.reward_point_mode === "money") { if (rule.reward_point_mode === "money") {
const priceToUse = rule.money_reward_point_mode === "before_tax" const priceToUse = rule.money_reward_point_mode === "before_tax"
? line.prices.total_excluded ? line.prices.total_excluded
@ -124,6 +124,7 @@ patch(PosOrder.prototype, {
if (line.is_reward_line) { if (line.is_reward_line) {
const reward = line.reward_id; const reward = line.reward_id;
if ( if (
!reward ||
program.id === reward.program_id?.id || program.id === reward.program_id?.id ||
["gift_card", "ewallet"].includes(reward.program_id?.program_type) ["gift_card", "ewallet"].includes(reward.program_id?.program_type)
) { ) {