From 181429a88753f3e1503424e8c142dd15b501aeb6 Mon Sep 17 00:00:00 2001 From: Suherdy Yacob Date: Tue, 26 May 2026 11:16:20 +0700 Subject: [PATCH] fix: remove invalid reward lines during order updates in loyalty programs --- .../src/app/pos_loyalty_safe_coupon_patch.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/static/src/app/pos_loyalty_safe_coupon_patch.js b/static/src/app/pos_loyalty_safe_coupon_patch.js index fc28fee..209125f 100644 --- a/static/src/app/pos_loyalty_safe_coupon_patch.js +++ b/static/src/app/pos_loyalty_safe_coupon_patch.js @@ -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); } });