@managesome/eposmatic-toolkit 0.4.37 → 0.4.39
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.
- package/esm/constants/accounting-templates.js +431 -0
- package/esm/constants/index.js +1 -0
- package/esm/helpers/store/cart-actions.js +54 -6
- package/esm/helpers/utils/cart-helpers.js +19 -5
- package/esm/helpers/utils/common.js +18 -1
- package/esm/helpers/utils/offer-apply-helpers.js +5 -3
- package/esm/helpers/utils/offers-helpers.js +92 -63
- package/lib/constants/accounting-templates.d.ts +8 -0
- package/lib/constants/accounting-templates.js +434 -0
- package/lib/constants/index.d.ts +1 -0
- package/lib/constants/index.js +1 -0
- package/lib/helpers/store/cart-actions.js +54 -6
- package/lib/helpers/utils/cart-helpers.js +19 -5
- package/lib/helpers/utils/common.d.ts +15 -0
- package/lib/helpers/utils/common.js +19 -1
- package/lib/helpers/utils/offer-apply-helpers.js +5 -3
- package/lib/helpers/utils/offers-helpers.d.ts +15 -4
- package/lib/helpers/utils/offers-helpers.js +92 -62
- package/lib/schemas/models/expense_categories.d.ts +3 -3
- package/lib/schemas/models/expense_details.d.ts +3 -3
- package/lib/schemas/models/gift_cards.d.ts +3 -3
- package/lib/schemas/models/halfhalf_setup.d.ts +3 -3
- package/lib/schemas/models/internal_invoices.d.ts +3 -3
- package/lib/schemas/models/items.d.ts +12 -12
- package/lib/schemas/models/marketing_fingerprints.d.ts +3 -3
- package/lib/schemas/models/modifier_extras.d.ts +3 -3
- package/lib/schemas/models/offers.d.ts +3 -3
- package/lib/schemas/models/public_holidays.d.ts +3 -3
- package/lib/schemas/models/specials.d.ts +3 -3
- package/lib/schemas/models/tenant_chart_of_accounts.d.ts +3 -3
- package/lib/schemas/models/tenant_hr_departments.d.ts +3 -3
- package/lib/schemas/models/tenant_hr_documents.d.ts +3 -3
- package/lib/schemas/models/tenant_hr_policies.d.ts +3 -3
- package/lib/schemas/models/tenant_hr_positions.d.ts +3 -3
- package/lib/schemas/models/tenant_journal_entries.d.ts +3 -3
- package/lib/schemas/models/void_order_items.d.ts +3 -3
- package/lib/schemas/models/vouchers.d.ts +3 -3
- package/lib/schemas/models/warehouse_communications.d.ts +3 -3
- package/lib/schemas/models/warehouse_items.d.ts +3 -3
- package/lib/schemas/models/warehouse_void_purchase_order_items.d.ts +3 -3
- package/lib/schemas/models/warehouse_void_sale_order_items.d.ts +3 -3
- package/lib/schemas/types/tenant_chart_of_accounts.d.ts +7 -0
- package/lib/tests/cart-helpers-edit-item-refs.test.d.ts +1 -0
- package/lib/tests/cart-helpers-edit-item-refs.test.js +99 -0
- package/lib/tests/code-redemption-helpers.test.d.ts +1 -0
- package/lib/tests/code-redemption-helpers.test.js +246 -0
- package/lib/tests/gift-card-helpers.test.d.ts +1 -0
- package/lib/tests/gift-card-helpers.test.js +100 -0
- package/lib/tests/offer-claim-regressions.test.d.ts +1 -0
- package/lib/tests/offer-claim-regressions.test.js +367 -0
- package/lib/tests/offers-helpers.test.js +24 -4
- package/lib/tests/offers-matrix.test.js +248 -20
- package/lib/tests/ref-exclusion-matching.test.d.ts +1 -0
- package/lib/tests/ref-exclusion-matching.test.js +168 -0
- package/lib/tests/wallet-cashback-helpers.test.d.ts +1 -0
- package/lib/tests/wallet-cashback-helpers.test.js +108 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CUSTOMER_REDEMPTION_TYPE_ENUM, OFFER_REWARD_TYPE_ENUM, PATHWAY_TO_UNLOCK_TYPE_ENUM, PATHWAY_TO_UNLOCK_TYPE_ORDERS_SCOPE_ENUM, PLATFORMS_BY_ORDER_FROM, WALLET_CASHBACK_LOYALTY_DISCOUNT_ID, } from '../../constants';
|
|
2
|
-
import { calculateEligibleOfferDiscountDetails, parseNum } from './common';
|
|
2
|
+
import { calculateEligibleOfferDiscountDetails, doesOrderItemMatchRefs, parseNum } from './common';
|
|
3
3
|
import { findApplicableSchedule } from './platform-catalog';
|
|
4
4
|
import { convertSpecialHoursFromCents, convertSpecialHoursToCents } from './platform-num';
|
|
5
5
|
import { convertPriceFromCents, convertPriceToCents } from './price-conversion';
|
|
@@ -214,9 +214,15 @@ function calculatePointsRedeemedForOffer(redeemedOffer, totalOrderPrice, categor
|
|
|
214
214
|
}
|
|
215
215
|
let times = 1;
|
|
216
216
|
if (!redeemedOffer.reward_points.once_per_order) {
|
|
217
|
+
// A spend threshold chunks the reward: one claim per "threshold" of spend.
|
|
218
|
+
// No threshold (`0` / null) means the offer simply has no minimum spend - it
|
|
219
|
+
// must NOT be read as "one claim per currency unit", which would multiply the
|
|
220
|
+
// reward by the cart total.
|
|
217
221
|
const getUnlockTimesByOrderAmount = (orderValue, totalAmount) => {
|
|
218
|
-
const
|
|
219
|
-
|
|
222
|
+
const requiredAmount = Number(totalAmount);
|
|
223
|
+
if (!Number.isFinite(requiredAmount) || requiredAmount <= 0)
|
|
224
|
+
return 1;
|
|
225
|
+
return Math.max(1, Math.floor(orderValue / requiredAmount));
|
|
220
226
|
};
|
|
221
227
|
// This means that we need to see if the condition to unlock the redeemedOffer is met multiple times
|
|
222
228
|
// i.e. if the customer has ordered 2 pizzas, and the redeemedOffer is applicable for 1 pizza
|
|
@@ -237,7 +243,7 @@ function calculatePointsRedeemedForOffer(redeemedOffer, totalOrderPrice, categor
|
|
|
237
243
|
if (bachelorItems >= num_of_items) {
|
|
238
244
|
if (totalOrderPrice >= total_amount) {
|
|
239
245
|
const timesForItems = Math.floor(bachelorItems / (num_of_items || 1));
|
|
240
|
-
const timesForAmount =
|
|
246
|
+
const timesForAmount = getUnlockTimesByOrderAmount(totalOrderPrice, total_amount);
|
|
241
247
|
// we need to find the minimum of the two
|
|
242
248
|
const minTimes = Math.min(timesForItems, timesForAmount);
|
|
243
249
|
const maxClaims = max_claims == null ? Infinity : Math.max(1, max_claims);
|
|
@@ -805,9 +811,11 @@ function hasEligibleItemsForDiscount(categories, excluded_refs) {
|
|
|
805
811
|
if (excluded_refs.includes(category.category_id)) {
|
|
806
812
|
continue;
|
|
807
813
|
}
|
|
808
|
-
//
|
|
814
|
+
// Item-level only: these lists hold item ids, and an excluded category is
|
|
815
|
+
// skipped above. Modifier/option refs belong to the reward's "Hide Options" /
|
|
816
|
+
// "Discount Not Applicable" lists and never reach this gate.
|
|
809
817
|
for (const item of category.items ?? []) {
|
|
810
|
-
if (!
|
|
818
|
+
if (!doesOrderItemMatchRefs(item, excluded_refs)) {
|
|
811
819
|
return true; // Found at least one eligible item
|
|
812
820
|
}
|
|
813
821
|
}
|
|
@@ -848,15 +856,31 @@ export function getOfferRewardApplicableQuantity(offer) {
|
|
|
848
856
|
}
|
|
849
857
|
// ====================================================================================================================
|
|
850
858
|
/**
|
|
851
|
-
*
|
|
859
|
+
* True when an offer's pathway and reward both draw on the same wallet resource
|
|
860
|
+
* (points to earn points, a voucher to earn a voucher). The admin blocks both
|
|
861
|
+
* cells, so they are only reachable through legacy or externally written rows;
|
|
862
|
+
* the engine refuses them rather than counting the resource twice.
|
|
863
|
+
*
|
|
864
|
+
* Deliberately a function rather than an inline test: it keeps the runtime guard
|
|
865
|
+
* without letting the compiler narrow the offer union (which would mark the
|
|
866
|
+
* remaining reward branches as unreachable).
|
|
867
|
+
*/
|
|
868
|
+
export function isOfferPathwayAndRewardSharingResource(offer) {
|
|
869
|
+
return ((offer.pathway_to_unlock_type === PATHWAY_TO_UNLOCK_TYPE_ENUM.POINTS &&
|
|
870
|
+
offer.reward_type === OFFER_REWARD_TYPE_ENUM.POINTS) ||
|
|
871
|
+
(offer.pathway_to_unlock_type === PATHWAY_TO_UNLOCK_TYPE_ENUM.VOUCHER &&
|
|
872
|
+
offer.reward_type === OFFER_REWARD_TYPE_ENUM.VOUCHER));
|
|
873
|
+
}
|
|
874
|
+
/**
|
|
875
|
+
* Claims of `offer` evidenced by the stamped cart items.
|
|
852
876
|
*
|
|
853
877
|
* ITEMS / DISCOUNT_ITEMS rewards are claimed by selecting items, and the
|
|
854
878
|
* selection is persisted on each item's `item_discount_details`. That entry is
|
|
855
879
|
* folded into `redeemed_offers` later, by the cart reconcile — which itself runs
|
|
856
880
|
* only after the cart has already been evaluated. Eligibility that reads ONLY
|
|
857
|
-
* `redeemed_offers`
|
|
858
|
-
*
|
|
859
|
-
*
|
|
881
|
+
* `redeemed_offers` misses the claim for exactly one cycle, and because
|
|
882
|
+
* `calculateCustomerLoyaltyPoints` does count the cart-item evidence, the points
|
|
883
|
+
* spent by the claim would be deducted and never credited back. The offer then
|
|
860
884
|
* reads unaffordable, `unlockedOffersApplicableTimes` drops to 0 and the cart
|
|
861
885
|
* reconcile strips the reward item that granted it.
|
|
862
886
|
*
|
|
@@ -1239,9 +1263,10 @@ function getOfferOrderValueExcludedRefs(offer) {
|
|
|
1239
1263
|
if (offer.reward_type === OFFER_REWARD_TYPE_ENUM.DISCOUNT) {
|
|
1240
1264
|
return offer.reward_discount?.excluded_refs ?? [];
|
|
1241
1265
|
}
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1266
|
+
// DISCOUNT_ITEMS deliberately does NOT contribute here: its excluded_refs /
|
|
1267
|
+
// exclusive_refs are option-level lists (same as an ITEMS reward) that act on
|
|
1268
|
+
// the modifier tree at selection time. Which items are eligible is decided by
|
|
1269
|
+
// `item_ids`, not by the spend-qualification base.
|
|
1245
1270
|
if (offer.reward_type === OFFER_REWARD_TYPE_ENUM.CASHBACK) {
|
|
1246
1271
|
return offer.reward_cashback?.excluded_refs ?? [];
|
|
1247
1272
|
}
|
|
@@ -1912,9 +1937,14 @@ export function getOffersWithStats({ offers, customer, vouchers, giftCards, cust
|
|
|
1912
1937
|
const remainingBudget = getRemainingClaimBudgetForOffer(offerToCheck);
|
|
1913
1938
|
return remainingBudget == null ? perOrderClaims : Math.min(perOrderClaims, remainingBudget);
|
|
1914
1939
|
};
|
|
1940
|
+
// Same rule as getUnlockTimesByOrderAmount: a threshold chunks the reward, but
|
|
1941
|
+
// an absent threshold means "no minimum spend" = a single claim, never
|
|
1942
|
+
// `floor(orderValue / 1)` claims.
|
|
1915
1943
|
const getOrderValueClaimTimes = (orderValue, minAmount) => {
|
|
1916
|
-
const
|
|
1917
|
-
|
|
1944
|
+
const requiredAmount = Number(minAmount);
|
|
1945
|
+
if (!Number.isFinite(requiredAmount) || requiredAmount <= 0)
|
|
1946
|
+
return 1;
|
|
1947
|
+
return Math.max(1, Math.floor(orderValue / requiredAmount));
|
|
1918
1948
|
};
|
|
1919
1949
|
const getOrdersBetweenUnlocksStats = ({ totalOrders, ordersBetweenUnlocks, }) => {
|
|
1920
1950
|
const normalizedTotalOrders = Math.max(0, Math.floor(Number.isFinite(totalOrders) ? totalOrders : 0));
|
|
@@ -2030,6 +2060,13 @@ export function getOffersWithStats({ offers, customer, vouchers, giftCards, cust
|
|
|
2030
2060
|
action_hint: null,
|
|
2031
2061
|
auto_apply: offer.auto_apply ?? false,
|
|
2032
2062
|
};
|
|
2063
|
+
if (isOfferPathwayAndRewardSharingResource(offer)) {
|
|
2064
|
+
stats.invalid_offer = true;
|
|
2065
|
+
stats.claimable = false;
|
|
2066
|
+
stats.message = `This offer is misconfigured: its pathway and reward use the same resource`;
|
|
2067
|
+
offersWithStats.push({ offer, stats });
|
|
2068
|
+
continue;
|
|
2069
|
+
}
|
|
2033
2070
|
if (offer.pathway_to_unlock_type === PATHWAY_TO_UNLOCK_TYPE_ENUM.ORDERS) {
|
|
2034
2071
|
if (offer.pathway_to_unlock_type_orders == null) {
|
|
2035
2072
|
stats.invalid_offer = true;
|
|
@@ -2139,16 +2176,9 @@ export function getOffersWithStats({ offers, customer, vouchers, giftCards, cust
|
|
|
2139
2176
|
else if (offer.reward_type === OFFER_REWARD_TYPE_ENUM.DISCOUNT_ITEMS) {
|
|
2140
2177
|
if (offer.reward_discount_items == null)
|
|
2141
2178
|
continue;
|
|
2142
|
-
//
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
// All items are excluded, offer cannot be unlocked
|
|
2146
|
-
stats.progress = 0;
|
|
2147
|
-
stats.claimable = false;
|
|
2148
|
-
stats.message = `⛔️ No eligible items for this offer ⛔️`;
|
|
2149
|
-
offersWithStats.push({ offer, stats });
|
|
2150
|
-
continue;
|
|
2151
|
-
}
|
|
2179
|
+
// No "all items excluded" gate here: DISCOUNT_ITEMS acts on the modifier
|
|
2180
|
+
// tree (excluded_refs / exclusive_refs), and item eligibility is driven by
|
|
2181
|
+
// item_ids, not by an item-level exclusion list.
|
|
2152
2182
|
const applicableQuantity = offer.reward_discount_items.num_of_items || 1;
|
|
2153
2183
|
const totalOfferItemsSelected = getTotalSelectedOfferItemsAgainstOffer(categories, offer._id);
|
|
2154
2184
|
const redeemedTimes = getItemRewardRedeemedTimes({
|
|
@@ -2445,14 +2475,9 @@ export function getOffersWithStats({ offers, customer, vouchers, giftCards, cust
|
|
|
2445
2475
|
else if (offer.reward_type === OFFER_REWARD_TYPE_ENUM.DISCOUNT_ITEMS) {
|
|
2446
2476
|
if (offer.reward_discount_items == null)
|
|
2447
2477
|
continue;
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
stats.claimable = false;
|
|
2452
|
-
stats.message = `⛔️ No eligible items for this offer ⛔️`;
|
|
2453
|
-
offersWithStats.push({ offer, stats });
|
|
2454
|
-
continue;
|
|
2455
|
-
}
|
|
2478
|
+
// No "all items excluded" gate here: DISCOUNT_ITEMS acts on the modifier
|
|
2479
|
+
// tree (excluded_refs / exclusive_refs), and item eligibility is driven by
|
|
2480
|
+
// item_ids, not by an item-level exclusion list.
|
|
2456
2481
|
const applicableQuantity = offer.reward_discount_items.num_of_items || 1;
|
|
2457
2482
|
const redeemedTimes = getItemRewardRedeemedTimes({
|
|
2458
2483
|
totalOfferItemsSelected,
|
|
@@ -2690,14 +2715,10 @@ export function getOffersWithStats({ offers, customer, vouchers, giftCards, cust
|
|
|
2690
2715
|
const combinedProgress = Math.min(pointsProgress, amountProgress);
|
|
2691
2716
|
if (effectiveLoyaltyPointsForCurrentOffer >= num_of_points) {
|
|
2692
2717
|
if (orderValue >= total_amount) {
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
else {
|
|
2698
|
-
stats.progress = combinedProgress;
|
|
2699
|
-
stats.message = `You are ${(num_of_points - effectiveLoyaltyPointsForCurrentOffer).toFixed(0)} points away from unlocking this offer`;
|
|
2700
|
-
}
|
|
2718
|
+
// The points axis is already satisfied by the outer condition; only the
|
|
2719
|
+
// spend axis was in question here.
|
|
2720
|
+
stats.progress = 100;
|
|
2721
|
+
stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
2701
2722
|
}
|
|
2702
2723
|
else {
|
|
2703
2724
|
stats.progress = combinedProgress;
|
|
@@ -2709,7 +2730,9 @@ export function getOffersWithStats({ offers, customer, vouchers, giftCards, cust
|
|
|
2709
2730
|
stats.message = `You are ${(num_of_points - effectiveLoyaltyPointsForCurrentOffer).toFixed(0)} points away from unlocking this offer`;
|
|
2710
2731
|
}
|
|
2711
2732
|
if (stats.progress >= 100) {
|
|
2712
|
-
|
|
2733
|
+
// A reward that costs zero points is free - it must not burn the whole
|
|
2734
|
+
// balance into claims (same rule as a zero spend threshold).
|
|
2735
|
+
const pointBurnTimes = num_of_points > 0 ? Math.floor(effectiveLoyaltyPointsForCurrentOffer / num_of_points) : 1;
|
|
2713
2736
|
const amountTimes = total_amount != null && total_amount > 0 ? Math.floor(orderValue / total_amount) : pointBurnTimes;
|
|
2714
2737
|
const totalUnlockableClaims = clampClaimsToRemainingClaimBudget(offer, Math.min(pointBurnTimes, amountTimes, maxClaimsPerOrder));
|
|
2715
2738
|
if (offer.reward_type === OFFER_REWARD_TYPE_ENUM.DISCOUNT) {
|
|
@@ -2744,14 +2767,9 @@ export function getOffersWithStats({ offers, customer, vouchers, giftCards, cust
|
|
|
2744
2767
|
else if (offer.reward_type === OFFER_REWARD_TYPE_ENUM.DISCOUNT_ITEMS) {
|
|
2745
2768
|
if (offer.reward_discount_items == null)
|
|
2746
2769
|
continue;
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
stats.claimable = false;
|
|
2751
|
-
stats.message = `⛔️ No eligible items for this offer ⛔️`;
|
|
2752
|
-
offersWithStats.push({ offer, stats });
|
|
2753
|
-
continue;
|
|
2754
|
-
}
|
|
2770
|
+
// No "all items excluded" gate here: DISCOUNT_ITEMS acts on the modifier
|
|
2771
|
+
// tree (excluded_refs / exclusive_refs), and item eligibility is driven by
|
|
2772
|
+
// item_ids, not by an item-level exclusion list.
|
|
2755
2773
|
const totalOfferItemsSelected = getTotalSelectedOfferItemsAgainstOffer(categories, offer._id);
|
|
2756
2774
|
const applicableQuantity = offer.reward_discount_items.num_of_items || 1;
|
|
2757
2775
|
const redeemedTimes = getItemRewardRedeemedTimes({
|
|
@@ -2991,6 +3009,14 @@ export function getOffersWithStats({ offers, customer, vouchers, giftCards, cust
|
|
|
2991
3009
|
firstReferencedVoucherWithWalletInventory ??
|
|
2992
3010
|
singleReferencedVoucherForRedeemedClaim ??
|
|
2993
3011
|
null;
|
|
3012
|
+
// Distinguish "the customer has not entered a code" from "this offer's
|
|
3013
|
+
// voucher cannot be used at all". When the tenant configured voucher ids
|
|
3014
|
+
// but none resolves to a usable voucher (inactive, expired, used up, or
|
|
3015
|
+
// deleted), telling the customer to "enter a matching voucher code" is a
|
|
3016
|
+
// dead end - they may already hold the code.
|
|
3017
|
+
const hasUnavailableReferencedVoucher = referencedVouchers.length === 0 &&
|
|
3018
|
+
voucher_ids.length > 0 &&
|
|
3019
|
+
voucher_ids.every((voucherId) => !vouchersById.has(voucherId));
|
|
2994
3020
|
const hasMatchingVoucher = matchingVoucherContext != null;
|
|
2995
3021
|
const normalizedMatchedVoucherCode = matchingVoucherContext != null ? getVoucherCode(matchingVoucherContext) : null;
|
|
2996
3022
|
const spendableVoucherCount = normalizedMatchedVoucherCode == null ? 0 : (spendableVoucherCodesByCode[normalizedMatchedVoucherCode] ?? 0);
|
|
@@ -2998,7 +3024,9 @@ export function getOffersWithStats({ offers, customer, vouchers, giftCards, cust
|
|
|
2998
3024
|
const amountProgress = getPreUnlockProgressPercentage(orderValue, total_amount);
|
|
2999
3025
|
if (!hasMatchingVoucher) {
|
|
3000
3026
|
stats.progress = 0;
|
|
3001
|
-
stats.message =
|
|
3027
|
+
stats.message = hasUnavailableReferencedVoucher
|
|
3028
|
+
? `⛔️ This offer's voucher is no longer available ⛔️`
|
|
3029
|
+
: `Enter a matching voucher code to unlock this offer`;
|
|
3002
3030
|
}
|
|
3003
3031
|
else if (!hasVoucherAccess) {
|
|
3004
3032
|
stats.progress = 0;
|
|
@@ -3049,14 +3077,9 @@ export function getOffersWithStats({ offers, customer, vouchers, giftCards, cust
|
|
|
3049
3077
|
else if (offer.reward_type === OFFER_REWARD_TYPE_ENUM.DISCOUNT_ITEMS) {
|
|
3050
3078
|
if (offer.reward_discount_items == null)
|
|
3051
3079
|
continue;
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
stats.claimable = false;
|
|
3056
|
-
stats.message = `⛔️ No eligible items for this offer ⛔️`;
|
|
3057
|
-
offersWithStats.push({ offer, stats });
|
|
3058
|
-
continue;
|
|
3059
|
-
}
|
|
3080
|
+
// No "all items excluded" gate here: DISCOUNT_ITEMS acts on the modifier
|
|
3081
|
+
// tree (excluded_refs / exclusive_refs), and item eligibility is driven by
|
|
3082
|
+
// item_ids, not by an item-level exclusion list.
|
|
3060
3083
|
const totalOfferItemsSelected = getTotalSelectedOfferItemsAgainstOffer(categories, offer._id);
|
|
3061
3084
|
const applicableQuantity = offer.reward_discount_items.num_of_items || 1;
|
|
3062
3085
|
const redeemedTimes = getItemRewardRedeemedTimes({
|
|
@@ -3064,7 +3087,9 @@ export function getOffersWithStats({ offers, customer, vouchers, giftCards, cust
|
|
|
3064
3087
|
applicableQuantity,
|
|
3065
3088
|
});
|
|
3066
3089
|
const maxClaimsPerOrder = max_claims == null ? Infinity : Math.max(1, max_claims);
|
|
3067
|
-
|
|
3090
|
+
// No spend threshold on a voucher pathway means "no minimum spend", so the
|
|
3091
|
+
// vouchers held - not a spend chunk count - decide how many claims fit.
|
|
3092
|
+
const unlockTimesForAmount = total_amount > 0 ? getOrderValueClaimTimes(orderValue, total_amount) : Infinity;
|
|
3068
3093
|
const voucherInventoryClaimCap = matchingVoucherContext != null ? Math.max(0, spendableVoucherCount + redeemedTimesForOffer) : Infinity;
|
|
3069
3094
|
const totalUnlockableClaims = clampClaimsToRemainingClaimBudget(offer, Math.min(unlockTimesForAmount, maxClaimsPerOrder, voucherInventoryClaimCap));
|
|
3070
3095
|
const isClaimable = redeemedTimes < totalUnlockableClaims;
|
|
@@ -3085,7 +3110,9 @@ export function getOffersWithStats({ offers, customer, vouchers, giftCards, cust
|
|
|
3085
3110
|
continue;
|
|
3086
3111
|
const redeemedTimes = getOfferRedeemedTimes(offer._id);
|
|
3087
3112
|
const maxClaimsPerOrder = max_claims == null ? Infinity : Math.max(1, max_claims);
|
|
3088
|
-
|
|
3113
|
+
// No spend threshold on a voucher pathway means "no minimum spend", so the
|
|
3114
|
+
// vouchers held - not a spend chunk count - decide how many claims fit.
|
|
3115
|
+
const unlockTimesForAmount = total_amount > 0 ? getOrderValueClaimTimes(orderValue, total_amount) : Infinity;
|
|
3089
3116
|
const voucherInventoryClaimCap = matchingVoucherContext != null ? Math.max(0, spendableVoucherCount + redeemedTimesForOffer) : Infinity;
|
|
3090
3117
|
const totalUnlockableClaims = clampClaimsToRemainingClaimBudget(offer, Math.min(unlockTimesForAmount, maxClaimsPerOrder, voucherInventoryClaimCap));
|
|
3091
3118
|
const maxRedeemableClaims = getPointsMaxRedeemableClaims({
|
|
@@ -3161,7 +3188,7 @@ export function getOffersWithStats({ offers, customer, vouchers, giftCards, cust
|
|
|
3161
3188
|
// (every total_amount unlocks one claim), capped by max_claims
|
|
3162
3189
|
// and the voucher inventory available for this order.
|
|
3163
3190
|
const maxClaimsPerOrder = max_claims == null ? Infinity : Math.max(1, max_claims);
|
|
3164
|
-
const unlockTimesForAmount = getOrderValueClaimTimes(orderValue, total_amount);
|
|
3191
|
+
const unlockTimesForAmount = total_amount > 0 ? getOrderValueClaimTimes(orderValue, total_amount) : Infinity;
|
|
3165
3192
|
const voucherInventoryClaimCap = matchingVoucherContext != null ? Math.max(0, spendableVoucherCount + redeemedTimesForOffer) : Infinity;
|
|
3166
3193
|
const totalUnlockableClaims = clampClaimsToRemainingClaimBudget(offer, Math.min(unlockTimesForAmount, maxClaimsPerOrder, voucherInventoryClaimCap));
|
|
3167
3194
|
const maxRedeemableClaims = getPathwayMaxRedeemableClaims(totalUnlockableClaims);
|
|
@@ -3213,7 +3240,9 @@ export function getOffersWithStats({ offers, customer, vouchers, giftCards, cust
|
|
|
3213
3240
|
applicableQuantity,
|
|
3214
3241
|
});
|
|
3215
3242
|
const maxClaimsPerOrder = max_claims == null ? Infinity : Math.max(1, max_claims);
|
|
3216
|
-
|
|
3243
|
+
// No spend threshold on a voucher pathway means "no minimum spend", so the
|
|
3244
|
+
// vouchers held - not a spend chunk count - decide how many claims fit.
|
|
3245
|
+
const unlockTimesForAmount = total_amount > 0 ? getOrderValueClaimTimes(orderValue, total_amount) : Infinity;
|
|
3217
3246
|
const voucherInventoryClaimCap = matchingVoucherContext != null ? Math.max(0, spendableVoucherCount + redeemedTimesForOffer) : Infinity;
|
|
3218
3247
|
const totalUnlockableClaims = clampClaimsToRemainingClaimBudget(offer, Math.min(unlockTimesForAmount, maxClaimsPerOrder, voucherInventoryClaimCap));
|
|
3219
3248
|
const isClaimable = redeemedTimes < totalUnlockableClaims;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IAccountTemplateEntry } from '../schemas/types/tenant_chart_of_accounts';
|
|
2
|
+
/**
|
|
3
|
+
* Default restaurant chart of accounts (Pakistan-first, PKR) — the seed used by
|
|
4
|
+
* `POST /tenant-chart-of-accounts/seed-template` and the admin panel's
|
|
5
|
+
* "Load Restaurant Template" action. Entries are flat posting accounts; tenants
|
|
6
|
+
* nest their own sub-accounts afterwards, and seeding never overwrites existing codes.
|
|
7
|
+
*/
|
|
8
|
+
export declare const RESTAURANT_ACCOUNTS_TEMPLATE: IAccountTemplateEntry[];
|