@managesome/eposmatic-toolkit 0.2.300 → 0.2.301

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.
@@ -87,7 +87,7 @@ interface IGetOffersWithStats {
87
87
  }
88
88
  export declare function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOfferRedemptionCounts, redeemed_offers, platform, currency_symbol, currentItemsPrice, totalDiscountApplied, categories, order_discount_details, }: IGetOffersWithStats): {
89
89
  offersWithStats: IOfferWithStats[];
90
- totalClaimableOffers: number;
90
+ totalClaimableOffers: string[];
91
91
  unlockedOffersApplicableTimes: Record<string, number>;
92
92
  offersWithStatsHashKey: string;
93
93
  unlockedOffersApplicableTimesHashKey: string;
@@ -821,10 +821,10 @@ function getRewardPreviewHashKey(rewardPreview) {
821
821
  // The same rule applies to getUnlockedOffersApplicableTimesHashKey and getRewardPreviewHashKey.
822
822
  function getOffersWithStatsHashKey(offersWithStats, totalClaimableOffers) {
823
823
  if (offersWithStats.length === 0) {
824
- return `offers:v1:empty:${totalClaimableOffers}`;
824
+ return `offers:v1:empty:${totalClaimableOffers.length}`;
825
825
  }
826
826
  const sortedOffers = [...offersWithStats].sort((a, b) => a.offer._id.localeCompare(b.offer._id));
827
- let result = `offers:v1:${totalClaimableOffers}|`;
827
+ let result = `offers:v1:${totalClaimableOffers.length}|`;
828
828
  for (let i = 0; i < sortedOffers.length; i++) {
829
829
  const { offer, stats } = sortedOffers[i];
830
830
  const eligibleItemIds = [...stats.eligible_item_ids].sort().join(',');
@@ -841,7 +841,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
841
841
  const orderDiscount = order_discount_details?.total_discount ?? 0;
842
842
  const itemsDiscount = totalDiscount - orderDiscount;
843
843
  const unlockedOffersApplicableTimes = {};
844
- let totalClaimableOffers = 0;
844
+ let totalClaimableOffers = [];
845
845
  let totalLoyaltyPointsOfCustomer = null;
846
846
  const nowTs = Date.now();
847
847
  const { voucherCodes: spendableVoucherCodesByCode } = calculateCustomerSpendableVoucherCodes({
@@ -1089,7 +1089,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
1089
1089
  stats.message = 'You already have an offer applied to your order.';
1090
1090
  }
1091
1091
  else {
1092
- totalClaimableOffers += 1;
1092
+ totalClaimableOffers.push(offer._id);
1093
1093
  stats.message = `🎉 You have unlocked this offer 🎉`;
1094
1094
  }
1095
1095
  unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
@@ -1118,7 +1118,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
1118
1118
  stats.redeemed_times = redeemedTimes;
1119
1119
  stats.applicable_quantity = applicableQuantity * maxRedeemableClaims;
1120
1120
  if (isClaimable) {
1121
- totalClaimableOffers += 1;
1121
+ totalClaimableOffers.push(offer._id);
1122
1122
  stats.claimable = true;
1123
1123
  stats.message = `🎉 You have unlocked this offer 🎉`;
1124
1124
  }
@@ -1150,7 +1150,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
1150
1150
  }
1151
1151
  else {
1152
1152
  stats.message = `🎉 You have unlocked this offer 🎉`;
1153
- totalClaimableOffers += 1;
1153
+ totalClaimableOffers.push(offer._id);
1154
1154
  }
1155
1155
  unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
1156
1156
  }
@@ -1185,7 +1185,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
1185
1185
  else {
1186
1186
  stats.claimable = true;
1187
1187
  stats.message = `🎉 You have unlocked this offer 🎉`;
1188
- totalClaimableOffers += 1;
1188
+ totalClaimableOffers.push(offer._id);
1189
1189
  }
1190
1190
  unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
1191
1191
  }
@@ -1219,7 +1219,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
1219
1219
  }
1220
1220
  else {
1221
1221
  stats.message = `🎉 You have unlocked this offer 🎉`;
1222
- totalClaimableOffers += 1;
1222
+ totalClaimableOffers.push(offer._id);
1223
1223
  }
1224
1224
  unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
1225
1225
  }
@@ -1254,7 +1254,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
1254
1254
  else {
1255
1255
  stats.claimable = true;
1256
1256
  stats.message = `🎉 You have unlocked this offer 🎉`;
1257
- totalClaimableOffers += 1;
1257
+ totalClaimableOffers.push(offer._id);
1258
1258
  }
1259
1259
  unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
1260
1260
  }
@@ -1271,7 +1271,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
1271
1271
  stats.redeemed_times = redeemedTimes;
1272
1272
  stats.applicable_quantity = applicableQuantity;
1273
1273
  if (isClaimable) {
1274
- totalClaimableOffers += 1;
1274
+ totalClaimableOffers.push(offer._id);
1275
1275
  stats.claimable = true;
1276
1276
  stats.message = `🎉 You have unlocked this offer 🎉`;
1277
1277
  }
@@ -1284,7 +1284,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
1284
1284
  }
1285
1285
  if (stats.progress >= 100 && isOfferUsesPerCustomerExhausted(offer)) {
1286
1286
  if (stats.claimable) {
1287
- totalClaimableOffers = Math.max(0, totalClaimableOffers - 1);
1287
+ totalClaimableOffers = totalClaimableOffers.filter((id) => id !== offer._id);
1288
1288
  }
1289
1289
  stats.claimable = false;
1290
1290
  stats.message = '⛔️ You have reached your personal limit for this offer ⛔️';
@@ -1367,7 +1367,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
1367
1367
  stats.message = 'You already have an offer applied to your order.';
1368
1368
  }
1369
1369
  else {
1370
- totalClaimableOffers += 1;
1370
+ totalClaimableOffers.push(offer._id);
1371
1371
  stats.message = `🎉 You have unlocked this offer 🎉`;
1372
1372
  }
1373
1373
  unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
@@ -1393,7 +1393,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
1393
1393
  stats.applicable_quantity = applicableQuantity * Math.max(1, totalUnlockableClaims);
1394
1394
  stats.claimable = isClaimable;
1395
1395
  if (isClaimable) {
1396
- totalClaimableOffers += 1;
1396
+ totalClaimableOffers.push(offer._id);
1397
1397
  stats.message = `🎉 You have unlocked this offer 🎉`;
1398
1398
  }
1399
1399
  else {
@@ -1417,7 +1417,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
1417
1417
  stats.message = 'This offer is redeemed ✅';
1418
1418
  }
1419
1419
  else {
1420
- totalClaimableOffers += 1;
1420
+ totalClaimableOffers.push(offer._id);
1421
1421
  stats.message = `🎉 You have unlocked this offer 🎉`;
1422
1422
  }
1423
1423
  unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
@@ -1450,7 +1450,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
1450
1450
  stats.message = 'This offer is redeemed ✅';
1451
1451
  }
1452
1452
  else {
1453
- totalClaimableOffers += 1;
1453
+ totalClaimableOffers.push(offer._id);
1454
1454
  stats.message = `🎉 You have unlocked this offer 🎉`;
1455
1455
  }
1456
1456
  unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
@@ -1479,7 +1479,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
1479
1479
  stats.message = 'This offer is redeemed ✅';
1480
1480
  }
1481
1481
  else {
1482
- totalClaimableOffers += 1;
1482
+ totalClaimableOffers.push(offer._id);
1483
1483
  stats.message = `🎉 You have unlocked this offer 🎉`;
1484
1484
  }
1485
1485
  unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
@@ -1512,7 +1512,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
1512
1512
  stats.message = 'This offer is redeemed ✅';
1513
1513
  }
1514
1514
  else {
1515
- totalClaimableOffers += 1;
1515
+ totalClaimableOffers.push(offer._id);
1516
1516
  stats.message = `🎉 You have unlocked this offer 🎉`;
1517
1517
  }
1518
1518
  unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
@@ -1530,7 +1530,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
1530
1530
  stats.applicable_quantity = applicableQuantity * Math.max(1, totalUnlockableClaims);
1531
1531
  stats.claimable = isClaimable;
1532
1532
  if (isClaimable) {
1533
- totalClaimableOffers += 1;
1533
+ totalClaimableOffers.push(offer._id);
1534
1534
  stats.message = `🎉 You have unlocked this offer 🎉`;
1535
1535
  }
1536
1536
  else {
@@ -1541,7 +1541,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
1541
1541
  }
1542
1542
  if (stats.progress >= 100 && isOfferUsesPerCustomerExhausted(offer)) {
1543
1543
  if (stats.claimable) {
1544
- totalClaimableOffers = Math.max(0, totalClaimableOffers - 1);
1544
+ totalClaimableOffers = totalClaimableOffers.filter((id) => id !== offer._id);
1545
1545
  }
1546
1546
  stats.claimable = false;
1547
1547
  stats.message = '⛔️ You have reached your personal limit for this offer ⛔️';
@@ -1629,7 +1629,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
1629
1629
  stats.message = 'You already have an offer applied to your order.';
1630
1630
  }
1631
1631
  else {
1632
- totalClaimableOffers += 1;
1632
+ totalClaimableOffers.push(offer._id);
1633
1633
  stats.message = `🎉 You have unlocked this offer 🎉`;
1634
1634
  }
1635
1635
  unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
@@ -1656,7 +1656,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
1656
1656
  stats.applicable_quantity = applicableQuantity * Math.max(1, totalUnlockableClaims);
1657
1657
  stats.claimable = isClaimable;
1658
1658
  if (isClaimable) {
1659
- totalClaimableOffers += 1;
1659
+ totalClaimableOffers.push(offer._id);
1660
1660
  stats.message = `🎉 You have unlocked this offer 🎉`;
1661
1661
  }
1662
1662
  else {
@@ -1680,7 +1680,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
1680
1680
  stats.message = 'This offer is redeemed ✅';
1681
1681
  }
1682
1682
  else {
1683
- totalClaimableOffers += 1;
1683
+ totalClaimableOffers.push(offer._id);
1684
1684
  stats.message = `🎉 You have unlocked this offer 🎉`;
1685
1685
  }
1686
1686
  unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
@@ -1713,7 +1713,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
1713
1713
  stats.message = 'This offer is redeemed ✅';
1714
1714
  }
1715
1715
  else {
1716
- totalClaimableOffers += 1;
1716
+ totalClaimableOffers.push(offer._id);
1717
1717
  stats.message = `🎉 You have unlocked this offer 🎉`;
1718
1718
  }
1719
1719
  unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
@@ -1742,7 +1742,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
1742
1742
  stats.message = 'This offer is redeemed ✅';
1743
1743
  }
1744
1744
  else {
1745
- totalClaimableOffers += 1;
1745
+ totalClaimableOffers.push(offer._id);
1746
1746
  stats.message = `🎉 You have unlocked this offer 🎉`;
1747
1747
  }
1748
1748
  unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
@@ -1775,7 +1775,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
1775
1775
  stats.message = 'This offer is redeemed ✅';
1776
1776
  }
1777
1777
  else {
1778
- totalClaimableOffers += 1;
1778
+ totalClaimableOffers.push(offer._id);
1779
1779
  stats.message = `🎉 You have unlocked this offer 🎉`;
1780
1780
  }
1781
1781
  unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
@@ -1794,7 +1794,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
1794
1794
  stats.applicable_quantity = applicableQuantity * Math.max(1, totalUnlockableClaims);
1795
1795
  stats.claimable = isClaimable;
1796
1796
  if (isClaimable) {
1797
- totalClaimableOffers += 1;
1797
+ totalClaimableOffers.push(offer._id);
1798
1798
  stats.message = `🎉 You have unlocked this offer 🎉`;
1799
1799
  }
1800
1800
  else {
@@ -1805,7 +1805,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
1805
1805
  }
1806
1806
  if (stats.progress >= 100 && isOfferUsesPerCustomerExhausted(offer)) {
1807
1807
  if (stats.claimable) {
1808
- totalClaimableOffers = Math.max(0, totalClaimableOffers - 1);
1808
+ totalClaimableOffers = totalClaimableOffers.filter((id) => id !== offer._id);
1809
1809
  }
1810
1810
  stats.claimable = false;
1811
1811
  stats.message = '⛔️ You have reached your personal limit for this offer ⛔️';
@@ -1891,7 +1891,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
1891
1891
  stats.message = 'You already have an offer applied to your order.';
1892
1892
  }
1893
1893
  else {
1894
- totalClaimableOffers += 1;
1894
+ totalClaimableOffers.push(offer._id);
1895
1895
  stats.message = `🎉 You have unlocked this offer 🎉`;
1896
1896
  }
1897
1897
  unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
@@ -1919,7 +1919,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
1919
1919
  stats.applicable_quantity = applicableQuantity * maxRedeemableClaims;
1920
1920
  stats.claimable = isClaimable;
1921
1921
  if (isClaimable) {
1922
- totalClaimableOffers += 1;
1922
+ totalClaimableOffers.push(offer._id);
1923
1923
  stats.message = `🎉 You have unlocked this offer 🎉`;
1924
1924
  }
1925
1925
  else {
@@ -1949,7 +1949,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
1949
1949
  stats.message = 'This offer is redeemed ✅';
1950
1950
  }
1951
1951
  else {
1952
- totalClaimableOffers += 1;
1952
+ totalClaimableOffers.push(offer._id);
1953
1953
  stats.message = `🎉 You have unlocked this offer 🎉`;
1954
1954
  }
1955
1955
  unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
@@ -1982,7 +1982,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
1982
1982
  stats.message = 'This offer is redeemed ✅';
1983
1983
  }
1984
1984
  else {
1985
- totalClaimableOffers += 1;
1985
+ totalClaimableOffers.push(offer._id);
1986
1986
  stats.message = `🎉 You have unlocked this offer 🎉`;
1987
1987
  }
1988
1988
  unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
@@ -2017,7 +2017,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
2017
2017
  stats.message = 'This offer is redeemed ✅';
2018
2018
  }
2019
2019
  else {
2020
- totalClaimableOffers += 1;
2020
+ totalClaimableOffers.push(offer._id);
2021
2021
  stats.message = `🎉 You have unlocked this offer 🎉`;
2022
2022
  }
2023
2023
  unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
@@ -2050,7 +2050,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
2050
2050
  stats.message = 'This offer is redeemed ✅';
2051
2051
  }
2052
2052
  else {
2053
- totalClaimableOffers += 1;
2053
+ totalClaimableOffers.push(offer._id);
2054
2054
  stats.message = `🎉 You have unlocked this offer 🎉`;
2055
2055
  }
2056
2056
  unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
@@ -2069,7 +2069,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
2069
2069
  stats.applicable_quantity = applicableQuantity;
2070
2070
  stats.claimable = isClaimable;
2071
2071
  if (isClaimable) {
2072
- totalClaimableOffers += 1;
2072
+ totalClaimableOffers.push(offer._id);
2073
2073
  stats.message = `🎉 You have unlocked this offer 🎉`;
2074
2074
  }
2075
2075
  else {
@@ -2080,7 +2080,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
2080
2080
  }
2081
2081
  if (stats.progress >= 100 && isOfferUsesPerCustomerExhausted(offer)) {
2082
2082
  if (stats.claimable) {
2083
- totalClaimableOffers = Math.max(0, totalClaimableOffers - 1);
2083
+ totalClaimableOffers = totalClaimableOffers.filter((id) => id !== offer._id);
2084
2084
  }
2085
2085
  stats.claimable = false;
2086
2086
  stats.message = '⛔️ You have reached your personal limit for this offer ⛔️';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@managesome/eposmatic-toolkit",
3
- "version": "0.2.300",
3
+ "version": "0.2.301",
4
4
  "description": "A Toolkit Library for Eposmatic",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",