diff --git a/addons/pos_loyalty/static/src/js/Loyalty.js b/addons/pos_loyalty/static/src/js/Loyalty.js index bfc5eacede2..4831ab2d8ce 100644 --- a/addons/pos_loyalty/static/src/js/Loyalty.js +++ b/addons/pos_loyalty/static/src/js/Loyalty.js @@ -431,16 +431,11 @@ patch(Order.prototype, "pos_loyalty.Order", { }, wait_for_push_order() { return ( - Object.keys(this.couponPointChanges || {}).length > 0 || - this._has_gift_card_product() || + !_.isEmpty(this.couponPointChanges) || this._get_reward_lines().length || this._super(...arguments) ); }, - _has_gift_card_product() { - const orderLines = this.get_orderlines(); - return orderLines.some((line) => line.eWalletGiftCardProgram); - }, /** * Add additional information for our ticket, such as new coupons and loyalty point gains. * @@ -984,12 +979,9 @@ patch(Order.prototype, "pos_loyalty.Order", { ) { continue; } - let price_to_use = line.get_price_with_tax(); - if (program.program_type === "gift_card") { - price_to_use = line.price; - } const pointsPerUnit = roundPrecision( - (rule.reward_point_amount * price_to_use) / line.get_quantity(), + (rule.reward_point_amount * line.get_price_with_tax()) / + line.get_quantity(), 0.01 ); if (pointsPerUnit > 0) { diff --git a/addons/pos_loyalty/static/src/tours/GiftCardProgramTours.js b/addons/pos_loyalty/static/src/tours/GiftCardProgramTours.js index 2efea68ee5a..65297ade573 100644 --- a/addons/pos_loyalty/static/src/tours/GiftCardProgramTours.js +++ b/addons/pos_loyalty/static/src/tours/GiftCardProgramTours.js @@ -49,14 +49,3 @@ PosLoyalty.check.orderTotalIs("35.00"); PosLoyalty.exec.finalizeOrder("Cash", "35"); registry.category("web_tour.tours").add("GiftCardProgramScanUseTour", { test: true, url: "/pos/web", steps: getSteps() }); //#endregion - -//#region GiftCardProgramCreateSetTour1 -startSteps(); -ProductScreen.do.confirmOpeningPopup(); -ProductScreen.do.clickHomeCategory(); -ProductScreen.do.clickDisplayedProduct('Gift Card'); -ProductScreen.do.pressNumpad('Disc 5 0'); -PosLoyalty.check.orderTotalIs('25.00'); -PosLoyalty.exec.finalizeOrder('Cash', '25'); -registry.category('web_tour.tours').add('GiftCardWithDiscountTour', { test: true, url: '/pos/web', steps: getSteps() }); -//#endregion diff --git a/addons/pos_loyalty/tests/test_frontend.py b/addons/pos_loyalty/tests/test_frontend.py index f047e337b54..eef51614b1d 100644 --- a/addons/pos_loyalty/tests/test_frontend.py +++ b/addons/pos_loyalty/tests/test_frontend.py @@ -815,26 +815,3 @@ class TestUi(TestPointOfSaleHttpCommon): "PosLoyaltyFreeProductTour2", login="accountman", ) - - def test_gift_card_value_with_discount(self): - """When selling a gift card with a discount, the value of the gift card - should be the amount before the discount.""" - LoyaltyProgram = self.env['loyalty.program'] - # Deactivate all other programs to avoid interference - (LoyaltyProgram.search([])).write({'pos_ok': False}) - # But activate the gift_card_product_50 and ewallet_product_50 because they're shared among new programs. - self.env.ref('loyalty.gift_card_product_50').write({'active': True}) - self.env.ref('loyalty.ewallet_product_50').write({'active': True}) - # Create programs - programs = self.create_programs([ - ('gift_card_1', 'gift_card'), - ]) - # Run the tour to topup ewallets. - self.start_tour( - "/pos/web?config_id=%d" % self.main_pos_config.id, - "GiftCardWithDiscountTour", - login="accountman", - ) - # Check the created gift cards. - self.assertEqual(len(programs['gift_card_1'].coupon_ids), 1) - self.assertEqual(programs['gift_card_1'].coupon_ids.points, 50)