Browse Source

Sep 13: [FIX] Bug fixed 'advanced_loyalty_management'

17.0
Risvana Cybro 3 days ago
parent
commit
99c729ab6b
  1. 2
      advanced_loyalty_management/__manifest__.py
  2. 19
      advanced_loyalty_management/doc/RELEASE_NOTES.md
  3. 1
      advanced_loyalty_management/models/pos_refund.py
  4. 59
      advanced_loyalty_management/static/src/js/pos_loyalty_card.js
  5. 1
      advanced_loyalty_management/static/src/js/pos_loyalty_deduction.js
  6. 1
      advanced_loyalty_management/static/src/js/pos_loyalty_deduction_receipt.js
  7. 9
      advanced_loyalty_management/static/src/js/pos_payment_screen.js
  8. 1
      advanced_loyalty_management/static/src/js/pos_reward_button.js
  9. 11
      advanced_loyalty_management/static/src/js/pos_reward_redeem_popup.js
  10. 1
      advanced_loyalty_management/static/src/js/pos_ticketscreen.js
  11. 40
      advanced_loyalty_management/static/src/xml/pos_loyalty_receipt.xml

2
advanced_loyalty_management/__manifest__.py

@ -21,7 +21,7 @@
############################################################################# #############################################################################
{ {
'name': 'Advanced Loyalty Management', 'name': 'Advanced Loyalty Management',
'version': '17.0.1.0.2', 'version': '17.0.1.0.3',
'category': 'Point of Sale', 'category': 'Point of Sale',
'summary': 'Advanced loyalty Management', 'summary': 'Advanced loyalty Management',
'description': """When an order is refunded, any loyalty points gained from 'description': """When an order is refunded, any loyalty points gained from

19
advanced_loyalty_management/doc/RELEASE_NOTES.md

@ -5,18 +5,7 @@
#### ADD #### ADD
- Initial Commit for Advanced Loyalty Management - Initial Commit for Advanced Loyalty Management
#### 10.09.2025
#### 25.11.2024 #### Version 17.0.1.0.3
#### Version 17.0.1.0.1 ##### BUG FIX
#### ADD - Fixed an issue that occurred on the receipt screen that appeared after the order refund.
- 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.

1
advanced_loyalty_management/models/pos_refund.py

@ -30,7 +30,6 @@ class PosOrder(models.Model):
def _compute_order_name(self): def _compute_order_name(self):
"""Compute the loyalty points when order is refunded""" """Compute the loyalty points when order is refunded"""
res = super()._compute_order_name() res = super()._compute_order_name()
partner_id = self.partner_id partner_id = self.partner_id
li = [line.mapped('price_subtotal_incl') for line li = [line.mapped('price_subtotal_incl') for line

59
advanced_loyalty_management/static/src/js/pos_loyalty_card.js

@ -1,5 +1,5 @@
/** @odoo-module **/ /** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import { patch } from "@web/core/utils/patch"; import { patch } from "@web/core/utils/patch";
import { Order } from "@point_of_sale/app/store/models"; import { Order } from "@point_of_sale/app/store/models";
import { roundPrecision as round_pr } from "@web/core/utils/numbers"; 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 discountProduct = reward.discount_line_product_id;
const rewardCode = _newRandomRewardCode(); const rewardCode = _newRandomRewardCode();
const points = this._getRealCouponPoints(args["coupon_id"]) const points = this._getRealCouponPoints(args["coupon_id"])
const cost = reward.clear_wallet ? this._getRealCouponPoints(args["coupon_id"]) :reward.pointsToRedeem const cost = reward.clear_wallet ? points :reward.pointsToRedeem
if (!discount || discount <= 0) {
console.error("Invalid redemption discount:", { reward });
return [];
}
return[ return[
{ {
product: discountProduct, product: discountProduct,
@ -137,7 +133,6 @@ patch(Order.prototype,{
}, },
export_as_JSON() { export_as_JSON() {
const json = super.export_as_JSON(...arguments);
//when change is converted the amount returned is changed //when change is converted the amount returned is changed
var orderLines, paymentLines; var orderLines, paymentLines;
orderLines = []; orderLines = [];
@ -151,31 +146,31 @@ patch(Order.prototype,{
return paymentLines.push([0, 0, itemAsJson]); return paymentLines.push([0, 0, itemAsJson]);
} }
}); });
json.name = this.get_name(); var json = {
json.amount_paid = this.get_total_paid() - this.get_change(); name: this.get_name(),
json.amount_total = this.get_total_with_tax(); amount_paid: this.get_total_paid() - this.get_change(),
json.amount_tax = this.get_total_tax(); amount_total: this.get_total_with_tax(),
json.amount_return = this.get_total_paid() - this.get_total_with_tax() - this.get_rounding_applied(); amount_tax: this.get_total_tax(),
json.lines = orderLines; amount_return: this.get_total_paid() - this.get_total_with_tax() - this.get_rounding_applied(),
json.statement_ids = paymentLines; lines: orderLines,
json.pos_session_id = this.pos_session_id; statement_ids: paymentLines,
json.pricelist_id = this.pricelist ? this.pricelist.id : false; pos_session_id: this.pos_session_id,
json.partner_id = this.get_partner() ? this.get_partner().id : false; pricelist_id: this.pricelist ? this.pricelist.id : false,
json.user_id = this.pos.user.id; partner_id: this.get_partner() ? this.get_partner().id : false,
json.uid = this.uid; user_id: this.pos.user.id,
json.sequence_number = this.sequence_number; uid: this.uid,
json.date_order = serializeDateTime(this.date_order); sequence_number: this.sequence_number,
json.fiscal_position_id = this.fiscal_position ? this.fiscal_position.id : false; date_order: serializeDateTime(this.date_order),
json.server_id = this.server_id ? this.server_id : false; fiscal_position_id: this.fiscal_position ? this.fiscal_position.id : false,
json.to_invoice = this.to_invoice ? this.to_invoice : false; server_id: this.server_id ? this.server_id : false,
json.shipping_date = this.shippingDate ? this.shippingDate : false; to_invoice: this.to_invoice ? this.to_invoice : false,
json.is_tipped = this.is_tipped || false; shipping_date: this.shippingDate ? this.shippingDate : false,
json.tip_amount = this.tip_amount || 0; is_tipped: this.is_tipped || false,
json.access_token = this.access_token || ""; tip_amount: this.tip_amount || 0,
json.last_order_preparation_change = JSON.stringify(this.lastOrderPrepaChange); access_token: this.access_token || "",
json.ticket_code = this.ticketCode || ""; last_order_preparation_change: JSON.stringify(this.lastOrderPrepaChange),
ticket_code: this.ticketCode || "",
};
if (!this.is_paid && this.user_id) { if (!this.is_paid && this.user_id) {
json.user_id = this.user_id; json.user_id = this.user_id;
} }

1
advanced_loyalty_management/static/src/js/pos_loyalty_deduction.js

@ -1,6 +1,7 @@
/** @odoo-module **/ /** @odoo-module **/
import { Order } from "@point_of_sale/app/store/models"; import { Order } from "@point_of_sale/app/store/models";
import { roundPrecision } from "@web/core/utils/numbers"; import { roundPrecision } from "@web/core/utils/numbers";
import { _t } from "@web/core/l10n/translation";
import { patch } from "@web/core/utils/patch"; import { patch } from "@web/core/utils/patch";
patch(Order.prototype, { patch(Order.prototype, {

1
advanced_loyalty_management/static/src/js/pos_loyalty_deduction_receipt.js

@ -7,6 +7,7 @@ patch(Order.prototype, {
export_for_printing() { export_for_printing() {
//--------to show the deducted loyalty points details in the order receipt //--------to show the deducted loyalty points details in the order receipt
const result = super.export_for_printing(...arguments); const result = super.export_for_printing(...arguments);
result.RefundOrder = this.paymentlines[0].order._isRefundOrder()
result.pointsDeducted = this.pos.lostPoints result.pointsDeducted = this.pos.lostPoints
return result; return result;
}, },

9
advanced_loyalty_management/static/src/js/pos_payment_screen.js

@ -11,13 +11,10 @@ patch(PaymentScreen.prototype, {
const order = this.pos.get_order() const order = this.pos.get_order()
const coupon = order.selectedCoupon const coupon = order.selectedCoupon
let pointsOfPartner = 0 let pointsOfPartner = 0
if (order.partner && Array.isArray(order.partner.loyalty_cards)) { if(order.partner.loyalty_cards.length != undefined){
const loyaltyCard = order.partner.loyalty_cards[coupon]; pointsOfPartner += order.partner.loyalty_cards[coupon].points
if (loyaltyCard && loyaltyCard.points !== undefined) {
pointsOfPartner += loyaltyCard.points;
} }
} const pointsWon = order.couponPointChanges[coupon].points
const pointsWon = order.couponPointChanges?.[coupon]?.points || 0;
const pointsSpent = order.pointsCost const pointsSpent = order.pointsCost
const balance = pointsOfPartner + pointsWon - pointsSpent const balance = pointsOfPartner + pointsWon - pointsSpent
const token = order.access_token const token = order.access_token

1
advanced_loyalty_management/static/src/js/pos_reward_button.js

@ -40,7 +40,6 @@ patch(RewardButton.prototype,{
rewards = claimableRewards.filter( rewards = claimableRewards.filter(
({ reward }) => reward.program_id.program_type !== "ewallet" ({ reward }) => reward.program_id.program_type !== "ewallet"
); );
} }
var pointCheck = false var pointCheck = false
for (const pointChange of Object.values(order.couponPointChanges)){ for (const pointChange of Object.values(order.couponPointChanges)){

11
advanced_loyalty_management/static/src/js/pos_reward_redeem_popup.js

@ -10,18 +10,16 @@ export class RewardPopup extends AbstractAwaitablePopup {
setup(){ setup(){
this.orm = useService("orm"); this.orm = useService("orm");
this.popup = useService("popup"); this.popup = useService("popup");
this.action = useService("action");
this.state = useState({ this.state = useState({
value:'' , value:'' ,
redeemPoints:'' redeemPoints:''
}) })
this.points = useRef("points"); this.points = useRef("points");
} }
toRedeem(ev){ toRedeem(ev){
//---validation for popup--- //---validation for popup---
ev.state.redeemPoints = ev.points.el.value ev.state.redeemPoints = ev.points.el.value
if (isNaN(ev.state.redeemPoints)) { if (isNaN(ev.state.redeemPoints)) {
ev.popup.add(ErrorPopup, { ev.popup.add(ErrorPopup, {
body: _t( body: _t(
@ -38,12 +36,9 @@ export class RewardPopup extends AbstractAwaitablePopup {
} }
save(props,ev){ save(props,ev){
//---after giving the points to redeem, the reward is added to orderliness
const selectedReward = props.selected_reward const selectedReward = props.selected_reward
const couponCacheValues = Object.values(props.order.pos.couponCache); const pointsOfPartner = props.order.partner.loyalty_cards[selectedReward.coupon_id].points
const filteredCoupons = couponCacheValues.filter(
(item) => item.partner_id === props.order.partner.id
);
const pointsOfPartner = filteredCoupons[0].balance
const pointsWon = props.order.couponPointChanges[selectedReward.coupon_id].points const pointsWon = props.order.couponPointChanges[selectedReward.coupon_id].points
const balance = pointsOfPartner + pointsWon - parseInt(ev.state.redeemPoints) const balance = pointsOfPartner + pointsWon - parseInt(ev.state.redeemPoints)
const order = props.order.access_token const order = props.order.access_token

1
advanced_loyalty_management/static/src/js/pos_ticketscreen.js

@ -13,6 +13,7 @@ patch(TicketScreen.prototype, {
triggerAtInput: (event) => this._onUpdateSelectedOrderline(event), triggerAtInput: (event) => this._onUpdateSelectedOrderline(event),
}); });
super.setup(...arguments); super.setup(...arguments);
}, },
async onDoRefund() { async onDoRefund() {
//---------to get the points cost from the reward lines //---------to get the points cost from the reward lines

40
advanced_loyalty_management/static/src/xml/pos_loyalty_receipt.xml

@ -6,27 +6,31 @@
<xpath expr="//div[hasclass('before-footer')]" position="before"> <xpath expr="//div[hasclass('before-footer')]" position="before">
<t t-foreach="props.data.pointsDeducted or []" t-as="deductedPoints" <t t-foreach="props.data.pointsDeducted or []" t-as="deductedPoints"
t-key="deductedPoints.ruleId"> t-key="deductedPoints.ruleId">
<t t-if="deductedPoints.lostPoint != 0"> <t t-if="this.props.data.RefundOrder">
<span class="pos-receipt-center-align"> <t t-if="deductedPoints.lostPoint != 0">
<div>--------------------------------</div> <span class="pos-receipt-center-align">
<br/> <div>--------------------------------</div>
<div t-esc='deductedPoints.programName' <br/>
class="pos-receipt-title"/> <div t-esc='deductedPoints.programName'
<br/> class="pos-receipt-title"/>
</span> <br/>
<t t-if='deductedPoints.lostPoint'> </span>
<div>Points Lost : <t t-if='deductedPoints.lostPoint'>
<span class='pos-receipt-right-align'>- <div>Points Lost :
<t t-esc='deductedPoints.lostPoint'/> <span class='pos-receipt-right-align'>-
</span> <t t-esc='deductedPoints.lostPoint'/>
</span>
</div>
</t>
<div>Balance Loyalty Points :
<span t-esc='deductedPoints.newPoint'
class="pos-receipt-right-align"/>
</div> </div>
</t> </t>
<div>Balance Loyalty Points :
<span t-esc='deductedPoints.newPoint'
class="pos-receipt-right-align"/>
</div>
</t> </t>
</t> </t>
</xpath> </xpath>
</t> </t>
</odoo> </odoo>
<!--this._isRefundOrder()-->
Loading…
Cancel
Save