@managesome/eposmatic-toolkit 0.2.349 → 0.2.351
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,22 +2706,30 @@ 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 ??
|
|
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);
|
|
2721
2730
|
if (!hasMatchingVoucher) {
|
|
2722
2731
|
stats.progress = 0;
|
|
2723
|
-
stats.message = `
|
|
2732
|
+
stats.message = `Enter a matching voucher code to unlock this offer`;
|
|
2724
2733
|
}
|
|
2725
2734
|
else if (!hasVoucherAccess) {
|
|
2726
2735
|
stats.progress = 0;
|