From 99c729ab6b86dcc3faaa8e0c4506de1ff06cdb6e Mon Sep 17 00:00:00 2001 From: Risvana Cybro Date: Sat, 13 Sep 2025 16:10:09 +0530 Subject: [PATCH] Sep 13: [FIX] Bug fixed 'advanced_loyalty_management' --- advanced_loyalty_management/__manifest__.py | 2 +- .../doc/RELEASE_NOTES.md | 19 ++---- .../models/pos_refund.py | 1 - .../static/src/js/pos_loyalty_card.js | 59 +++++++++---------- .../static/src/js/pos_loyalty_deduction.js | 1 + .../src/js/pos_loyalty_deduction_receipt.js | 1 + .../static/src/js/pos_payment_screen.js | 9 +-- .../static/src/js/pos_reward_button.js | 1 - .../static/src/js/pos_reward_redeem_popup.js | 11 +--- .../static/src/js/pos_ticketscreen.js | 1 + .../static/src/xml/pos_loyalty_receipt.xml | 40 +++++++------ 11 files changed, 63 insertions(+), 82 deletions(-) diff --git a/advanced_loyalty_management/__manifest__.py b/advanced_loyalty_management/__manifest__.py index fe2944885..d3d8ae367 100644 --- a/advanced_loyalty_management/__manifest__.py +++ b/advanced_loyalty_management/__manifest__.py @@ -21,7 +21,7 @@ ############################################################################# { 'name': 'Advanced Loyalty Management', - 'version': '17.0.1.0.2', + 'version': '17.0.1.0.3', 'category': 'Point of Sale', 'summary': 'Advanced loyalty Management', 'description': """When an order is refunded, any loyalty points gained from diff --git a/advanced_loyalty_management/doc/RELEASE_NOTES.md b/advanced_loyalty_management/doc/RELEASE_NOTES.md index 63250c6cc..582ae87bb 100644 --- a/advanced_loyalty_management/doc/RELEASE_NOTES.md +++ b/advanced_loyalty_management/doc/RELEASE_NOTES.md @@ -5,18 +5,7 @@ #### ADD - Initial Commit for Advanced Loyalty Management - -#### 25.11.2024 -#### Version 17.0.1.0.1 -#### ADD -- BUG FIX - -#### 08.01.2025 -#### Version 17.0.1.0.2 -#### ADD -- BUG FIX - -#### 03.06.2025 -#### Version 17.0.1.0.2 -#### BUG FIX -- Super was called in the function override. \ No newline at end of file +#### 10.09.2025 +#### Version 17.0.1.0.3 +##### BUG FIX +- Fixed an issue that occurred on the receipt screen that appeared after the order refund. diff --git a/advanced_loyalty_management/models/pos_refund.py b/advanced_loyalty_management/models/pos_refund.py index 08635c3d0..63eb3237a 100644 --- a/advanced_loyalty_management/models/pos_refund.py +++ b/advanced_loyalty_management/models/pos_refund.py @@ -30,7 +30,6 @@ class PosOrder(models.Model): def _compute_order_name(self): """Compute the loyalty points when order is refunded""" - res = super()._compute_order_name() partner_id = self.partner_id li = [line.mapped('price_subtotal_incl') for line diff --git a/advanced_loyalty_management/static/src/js/pos_loyalty_card.js b/advanced_loyalty_management/static/src/js/pos_loyalty_card.js index 4e4473e40..16a253878 100644 --- a/advanced_loyalty_management/static/src/js/pos_loyalty_card.js +++ b/advanced_loyalty_management/static/src/js/pos_loyalty_card.js @@ -1,5 +1,5 @@ /** @odoo-module **/ -import { _t } from "@web/core/l10n/translation"; + import { patch } from "@web/core/utils/patch"; import { Order } from "@point_of_sale/app/store/models"; import { roundPrecision as round_pr } from "@web/core/utils/numbers"; @@ -39,11 +39,7 @@ patch(Order.prototype,{ const discountProduct = reward.discount_line_product_id; const rewardCode = _newRandomRewardCode(); const points = this._getRealCouponPoints(args["coupon_id"]) - const cost = reward.clear_wallet ? this._getRealCouponPoints(args["coupon_id"]) :reward.pointsToRedeem - if (!discount || discount <= 0) { - console.error("Invalid redemption discount:", { reward }); - return []; - } + const cost = reward.clear_wallet ? points :reward.pointsToRedeem return[ { product: discountProduct, @@ -137,7 +133,6 @@ patch(Order.prototype,{ }, export_as_JSON() { - const json = super.export_as_JSON(...arguments); //when change is converted the amount returned is changed var orderLines, paymentLines; orderLines = []; @@ -151,31 +146,31 @@ patch(Order.prototype,{ return paymentLines.push([0, 0, itemAsJson]); } }); - json.name = this.get_name(); - json.amount_paid = this.get_total_paid() - this.get_change(); - json.amount_total = this.get_total_with_tax(); - json.amount_tax = this.get_total_tax(); - json.amount_return = this.get_total_paid() - this.get_total_with_tax() - this.get_rounding_applied(); - json.lines = orderLines; - json.statement_ids = paymentLines; - json.pos_session_id = this.pos_session_id; - json.pricelist_id = this.pricelist ? this.pricelist.id : false; - json.partner_id = this.get_partner() ? this.get_partner().id : false; - json.user_id = this.pos.user.id; - json.uid = this.uid; - json.sequence_number = this.sequence_number; - json.date_order = serializeDateTime(this.date_order); - json.fiscal_position_id = this.fiscal_position ? this.fiscal_position.id : false; - json.server_id = this.server_id ? this.server_id : false; - json.to_invoice = this.to_invoice ? this.to_invoice : false; - json.shipping_date = this.shippingDate ? this.shippingDate : false; - json.is_tipped = this.is_tipped || false; - json.tip_amount = this.tip_amount || 0; - json.access_token = this.access_token || ""; - json.last_order_preparation_change = JSON.stringify(this.lastOrderPrepaChange); - json.ticket_code = this.ticketCode || ""; - - + var json = { + name: this.get_name(), + amount_paid: this.get_total_paid() - this.get_change(), + amount_total: this.get_total_with_tax(), + amount_tax: this.get_total_tax(), + amount_return: this.get_total_paid() - this.get_total_with_tax() - this.get_rounding_applied(), + lines: orderLines, + statement_ids: paymentLines, + pos_session_id: this.pos_session_id, + pricelist_id: this.pricelist ? this.pricelist.id : false, + partner_id: this.get_partner() ? this.get_partner().id : false, + user_id: this.pos.user.id, + uid: this.uid, + sequence_number: this.sequence_number, + date_order: serializeDateTime(this.date_order), + fiscal_position_id: this.fiscal_position ? this.fiscal_position.id : false, + server_id: this.server_id ? this.server_id : false, + to_invoice: this.to_invoice ? this.to_invoice : false, + shipping_date: this.shippingDate ? this.shippingDate : false, + is_tipped: this.is_tipped || false, + tip_amount: this.tip_amount || 0, + access_token: this.access_token || "", + last_order_preparation_change: JSON.stringify(this.lastOrderPrepaChange), + ticket_code: this.ticketCode || "", + }; if (!this.is_paid && this.user_id) { json.user_id = this.user_id; } diff --git a/advanced_loyalty_management/static/src/js/pos_loyalty_deduction.js b/advanced_loyalty_management/static/src/js/pos_loyalty_deduction.js index 3ebddc6d6..c40334d6b 100644 --- a/advanced_loyalty_management/static/src/js/pos_loyalty_deduction.js +++ b/advanced_loyalty_management/static/src/js/pos_loyalty_deduction.js @@ -1,6 +1,7 @@ /** @odoo-module **/ import { Order } from "@point_of_sale/app/store/models"; import { roundPrecision } from "@web/core/utils/numbers"; +import { _t } from "@web/core/l10n/translation"; import { patch } from "@web/core/utils/patch"; patch(Order.prototype, { diff --git a/advanced_loyalty_management/static/src/js/pos_loyalty_deduction_receipt.js b/advanced_loyalty_management/static/src/js/pos_loyalty_deduction_receipt.js index e7d84986f..2824c489b 100644 --- a/advanced_loyalty_management/static/src/js/pos_loyalty_deduction_receipt.js +++ b/advanced_loyalty_management/static/src/js/pos_loyalty_deduction_receipt.js @@ -7,6 +7,7 @@ patch(Order.prototype, { export_for_printing() { //--------to show the deducted loyalty points details in the order receipt const result = super.export_for_printing(...arguments); + result.RefundOrder = this.paymentlines[0].order._isRefundOrder() result.pointsDeducted = this.pos.lostPoints return result; }, diff --git a/advanced_loyalty_management/static/src/js/pos_payment_screen.js b/advanced_loyalty_management/static/src/js/pos_payment_screen.js index 4ff3ad02a..81a551429 100644 --- a/advanced_loyalty_management/static/src/js/pos_payment_screen.js +++ b/advanced_loyalty_management/static/src/js/pos_payment_screen.js @@ -11,13 +11,10 @@ patch(PaymentScreen.prototype, { 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; + if(order.partner.loyalty_cards.length != undefined){ + pointsOfPartner += order.partner.loyalty_cards[coupon].points } - } - const pointsWon = order.couponPointChanges?.[coupon]?.points || 0; + const pointsWon = order.couponPointChanges[coupon].points const pointsSpent = order.pointsCost const balance = pointsOfPartner + pointsWon - pointsSpent const token = order.access_token diff --git a/advanced_loyalty_management/static/src/js/pos_reward_button.js b/advanced_loyalty_management/static/src/js/pos_reward_button.js index bc3083123..c428027d0 100644 --- a/advanced_loyalty_management/static/src/js/pos_reward_button.js +++ b/advanced_loyalty_management/static/src/js/pos_reward_button.js @@ -40,7 +40,6 @@ patch(RewardButton.prototype,{ rewards = claimableRewards.filter( ({ reward }) => reward.program_id.program_type !== "ewallet" ); - } var pointCheck = false for (const pointChange of Object.values(order.couponPointChanges)){ diff --git a/advanced_loyalty_management/static/src/js/pos_reward_redeem_popup.js b/advanced_loyalty_management/static/src/js/pos_reward_redeem_popup.js index 0c2289600..072cf3085 100644 --- a/advanced_loyalty_management/static/src/js/pos_reward_redeem_popup.js +++ b/advanced_loyalty_management/static/src/js/pos_reward_redeem_popup.js @@ -10,18 +10,16 @@ export class RewardPopup extends AbstractAwaitablePopup { setup(){ this.orm = useService("orm"); this.popup = useService("popup"); - this.action = useService("action"); this.state = useState({ value:'' , redeemPoints:'' }) this.points = useRef("points"); - } toRedeem(ev){ //---validation for popup--- - ev.state.redeemPoints = ev.points.el.value + ev.state.redeemPoints = ev.points.el.value if (isNaN(ev.state.redeemPoints)) { ev.popup.add(ErrorPopup, { body: _t( @@ -38,12 +36,9 @@ export class RewardPopup extends AbstractAwaitablePopup { } save(props,ev){ + //---after giving the points to redeem, the reward is added to orderliness const selectedReward = props.selected_reward - const couponCacheValues = Object.values(props.order.pos.couponCache); - const filteredCoupons = couponCacheValues.filter( - (item) => item.partner_id === props.order.partner.id - ); - const pointsOfPartner = filteredCoupons[0].balance + const pointsOfPartner = props.order.partner.loyalty_cards[selectedReward.coupon_id].points const pointsWon = props.order.couponPointChanges[selectedReward.coupon_id].points const balance = pointsOfPartner + pointsWon - parseInt(ev.state.redeemPoints) const order = props.order.access_token diff --git a/advanced_loyalty_management/static/src/js/pos_ticketscreen.js b/advanced_loyalty_management/static/src/js/pos_ticketscreen.js index 5b33bbfa8..cd103ee63 100644 --- a/advanced_loyalty_management/static/src/js/pos_ticketscreen.js +++ b/advanced_loyalty_management/static/src/js/pos_ticketscreen.js @@ -13,6 +13,7 @@ patch(TicketScreen.prototype, { triggerAtInput: (event) => this._onUpdateSelectedOrderline(event), }); super.setup(...arguments); + }, async onDoRefund() { //---------to get the points cost from the reward lines diff --git a/advanced_loyalty_management/static/src/xml/pos_loyalty_receipt.xml b/advanced_loyalty_management/static/src/xml/pos_loyalty_receipt.xml index 5a267b686..73ddc9d5f 100644 --- a/advanced_loyalty_management/static/src/xml/pos_loyalty_receipt.xml +++ b/advanced_loyalty_management/static/src/xml/pos_loyalty_receipt.xml @@ -6,27 +6,31 @@ - - -
--------------------------------
-
-
-
- - -
Points Lost : - - - - + + + +
--------------------------------
+
+
+
+ + +
Points Lost : + - + + +
+
+
Balance Loyalty Points : +
-
Balance Loyalty Points : - -
- \ No newline at end of file + + + \ No newline at end of file