[REV] pos_loyalty: revert gift card specifid point computation
The correct behavior for the gift cards should be that the value of the gift card is equal to the value of the order line. For example : -50$ giftcard -> Apply discount 50% on the order line -> 25$ gift card If we want to apply a discount on a gift card we need to use the global discount The commit we are reverting was forcing the value of the gift card to be the base value of the order line. This reverts commit 83ceeecde76a859749d0659d6c387d95155c8425. OPW-3264945 closes odoo/odoo#120794 X-original-commit: 023e2f2571ab7c814ed3cad45871fc221562fb67 Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com> Signed-off-by: Engels Robin (roen) <roen@odoo.com>
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user