@managesome/eposmatic-toolkit 0.2.348 → 0.2.350

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.
@@ -2685,6 +2685,7 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
2685
2685
  .filter((voucher) => voucher != null);
2686
2686
  const getVoucherCode = (voucher) => voucher.code.trim().toUpperCase();
2687
2687
  const getVoucherSpendableCount = (voucher) => spendableVoucherCodesByCode[getVoucherCode(voucher)] ?? 0;
2688
+ const redeemedTimesForOffer = getOfferRedeemedTimes(offer._id);
2688
2689
  const isVoucherPathwayUsageAvailable = (voucher) => {
2689
2690
  const maxUsesPerCustomer = voucher.max_uses_per_customer;
2690
2691
  if (maxUsesPerCustomer == null) {
@@ -2705,16 +2706,24 @@ function getOffersWithStats({ offers, customer, vouchers, giftCards, customerOff
2705
2706
  const matchedReferencedVoucherByReference = normalizedVoucherRef == null
2706
2707
  ? null
2707
2708
  : (referencedVouchers.find((voucher) => getVoucherCode(voucher) === normalizedVoucherRef) ?? null);
2709
+ const matchedReferencedVoucherByCartContext = voucherPathwayCartContext.activeVoucherCode == null
2710
+ ? null
2711
+ : (referencedVouchers.find((voucher) => getVoucherCode(voucher) === voucherPathwayCartContext.activeVoucherCode) ?? null);
2708
2712
  const matchedVoucherForAccess = normalizedVoucherRef == null
2709
2713
  ? null
2710
2714
  : (referencedVouchersWithWalletAccess.find((voucher) => getVoucherCode(voucher) === normalizedVoucherRef) ??
2711
2715
  null);
2712
2716
  const firstReferencedVoucherWithWalletInventory = referencedVouchers.find((voucher) => getVoucherSpendableCount(voucher) > 0) ?? null;
2717
+ const singleReferencedVoucherForRedeemedClaim = redeemedTimesForOffer > 0 && referencedVouchers.length === 1 ? referencedVouchers[0] : null;
2713
2718
  const matchedVoucher = matchedVoucherForAccess ?? referencedVouchersWithWalletAccess[0] ?? null;
2714
- const matchingVoucherContext = matchedVoucher ?? matchedReferencedVoucherByReference ?? firstReferencedVoucherWithWalletInventory ?? null;
2719
+ const matchingVoucherContext = matchedVoucher ??
2720
+ matchedReferencedVoucherByReference ??
2721
+ matchedReferencedVoucherByCartContext ??
2722
+ firstReferencedVoucherWithWalletInventory ??
2723
+ singleReferencedVoucherForRedeemedClaim ??
2724
+ null;
2715
2725
  const hasMatchingVoucher = matchingVoucherContext != null;
2716
2726
  const normalizedMatchedVoucherCode = matchingVoucherContext != null ? getVoucherCode(matchingVoucherContext) : null;
2717
- const redeemedTimesForOffer = getOfferRedeemedTimes(offer._id);
2718
2727
  const spendableVoucherCount = normalizedMatchedVoucherCode == null ? 0 : (spendableVoucherCodesByCode[normalizedMatchedVoucherCode] ?? 0);
2719
2728
  const hasVoucherAccess = matchedVoucher != null || (redeemedTimesForOffer > 0 && matchingVoucherContext != null);
2720
2729
  const amountProgress = getPreUnlockProgressPercentage(orderValue, total_amount || 1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@managesome/eposmatic-toolkit",
3
- "version": "0.2.348",
3
+ "version": "0.2.350",
4
4
  "description": "A Toolkit Library for Eposmatic",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",