fix: remove invalid reward lines during order updates in loyalty programs

This commit is contained in:
Suherdy Yacob 2026-05-26 11:16:20 +07:00
parent 4d51105ce0
commit 181429a887

View File

@ -19,6 +19,15 @@ patch(PosOrder.prototype, {
line.coupon_id = undefined;
}
}
},
_updateRewardLines() {
if (this.lines) {
const invalidRewardLines = this.lines.filter((line) => line.is_reward_line && !line.reward_id);
for (const line of invalidRewardLines) {
line.delete();
}
}
return super._updateRewardLines(...arguments);
}
});
@ -71,5 +80,15 @@ patch(PosStore.prototype, {
line.coupon_id = undefined;
}
}
},
async orderUpdateLoyaltyPrograms() {
const order = this.getOrder();
if (order && order.lines) {
const invalidRewardLines = order.lines.filter((line) => line.is_reward_line && !line.reward_id);
for (const line of invalidRewardLines) {
line.delete();
}
}
return await super.orderUpdateLoyaltyPrograms(...arguments);
}
});