You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
1.3 KiB
28 lines
1.3 KiB
/** @odoo-module **/
|
|
|
|
import { PaymentScreen } from "@point_of_sale/app/screens/payment_screen/payment_screen";
|
|
import { patch } from "@web/core/utils/patch";
|
|
|
|
patch(PaymentScreen.prototype, {
|
|
async afterOrderValidation(suggestToSync = true) {
|
|
//---remaining points calculated after claiming the reward is shown in the redemption history
|
|
const res = super.afterOrderValidation(...arguments);
|
|
if(this.pos.get_order().pointsCost != undefined){
|
|
const order = this.pos.get_order()
|
|
const coupon = order.selectedCoupon
|
|
let pointsOfPartner = 0
|
|
if (order.partner && Array.isArray(order.partner.loyalty_cards)) {
|
|
const loyaltyCard = order.partner.loyalty_cards[coupon];
|
|
if (loyaltyCard && loyaltyCard.points !== undefined) {
|
|
pointsOfPartner += loyaltyCard.points;
|
|
}
|
|
}
|
|
const pointsWon = order.couponPointChanges?.[coupon]?.points || 0;
|
|
const pointsSpent = order.pointsCost
|
|
const balance = pointsOfPartner + pointsWon - pointsSpent
|
|
const token = order.access_token
|
|
const remaining_points = this.env.services.orm.call('pos.order.line','remaining_points',[[balance],[token]])
|
|
}
|
|
return res
|
|
},
|
|
});
|
|
|