@managesome/eposmatic-toolkit 0.2.299 → 0.2.300

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1575,18 +1575,21 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
1575
1575
  });
1576
1576
  totalLoyaltyPointsOfCustomer = loyaltyPoints;
1577
1577
  }
1578
- const pointsProgress = getPreUnlockProgressPercentage(totalLoyaltyPointsOfCustomer ?? 0, num_of_points || 1);
1578
+ const orderLevelClaimSignal = order_discount_details?.loyalty_discount_id === offer._id ? 1 : 0;
1579
+ const redeemedTimesForCurrentOffer = Math.max(getOfferRedeemedTimes(offer._id), orderLevelClaimSignal);
1580
+ const effectiveLoyaltyPointsForCurrentOffer = (totalLoyaltyPointsOfCustomer ?? 0) + redeemedTimesForCurrentOffer * (num_of_points ?? 0);
1581
+ const pointsProgress = getPreUnlockProgressPercentage(effectiveLoyaltyPointsForCurrentOffer, num_of_points || 1);
1579
1582
  const amountProgress = getPreUnlockProgressPercentage(orderValue, total_amount || 1);
1580
1583
  const combinedProgress = Math.min(pointsProgress, amountProgress);
1581
- if ((totalLoyaltyPointsOfCustomer ?? 0) >= num_of_points) {
1584
+ if (effectiveLoyaltyPointsForCurrentOffer >= num_of_points) {
1582
1585
  if (orderValue >= total_amount) {
1583
- if ((totalLoyaltyPointsOfCustomer ?? 0) >= num_of_points) {
1586
+ if (effectiveLoyaltyPointsForCurrentOffer >= num_of_points) {
1584
1587
  stats.progress = 100;
1585
1588
  stats.message = `🎉 You have unlocked this offer 🎉`;
1586
1589
  }
1587
1590
  else {
1588
1591
  stats.progress = combinedProgress;
1589
- stats.message = `You are ${(num_of_points - (totalLoyaltyPointsOfCustomer ?? 0)).toFixed(0)} points away from unlocking this offer`;
1592
+ stats.message = `You are ${(num_of_points - effectiveLoyaltyPointsForCurrentOffer).toFixed(0)} points away from unlocking this offer`;
1590
1593
  }
1591
1594
  }
1592
1595
  else {
@@ -1596,10 +1599,10 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
1596
1599
  }
1597
1600
  else {
1598
1601
  stats.progress = combinedProgress;
1599
- stats.message = `You are ${(num_of_points - (totalLoyaltyPointsOfCustomer ?? 0)).toFixed(0)} points away from unlocking this offer`;
1602
+ stats.message = `You are ${(num_of_points - effectiveLoyaltyPointsForCurrentOffer).toFixed(0)} points away from unlocking this offer`;
1600
1603
  }
1601
1604
  if (stats.progress >= 100) {
1602
- const pointBurnTimes = Math.floor((totalLoyaltyPointsOfCustomer ?? 0) / (num_of_points || 1));
1605
+ const pointBurnTimes = Math.floor(effectiveLoyaltyPointsForCurrentOffer / (num_of_points || 1));
1603
1606
  const amountTimes = Math.floor(orderValue / (total_amount || 1));
1604
1607
  const totalUnlockableClaims = Math.min(pointBurnTimes, amountTimes, maxClaimsPerOrder);
1605
1608
  if (offer.reward_type === constants_1.OFFER_REWARD_TYPE_ENUM.DISCOUNT) {
@@ -1613,7 +1616,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
1613
1616
  offersWithStats.push({ offer, stats });
1614
1617
  continue;
1615
1618
  }
1616
- const redeemedTimes = getOfferRedeemedTimes(offer._id);
1619
+ const redeemedTimes = redeemedTimesForCurrentOffer;
1617
1620
  const isRedeemed = redeemedTimes > 0;
1618
1621
  const discountSlotOccupied = isDiscountSlotOccupiedForOffer(offer);
1619
1622
  stats.redeemed_times = redeemedTimes;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@managesome/eposmatic-toolkit",
3
- "version": "0.2.299",
3
+ "version": "0.2.300",
4
4
  "description": "A Toolkit Library for Eposmatic",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",