@managesome/eposmatic-toolkit 0.2.252 → 0.2.254

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.
@@ -330,6 +330,64 @@ function calculateGstForItem({ subtotal, totalOrderDiscount, applyGSTOnOriginalP
330
330
  }
331
331
  return gst_amount;
332
332
  }
333
+ function getRedeemedOffersMap(orderDiscountDetails, categories, existingRedeemedOffers) {
334
+ const normalizedExistingRedeemedOffers = {};
335
+ const derivedRedeemedOffers = {};
336
+ const getNormalizedOfferId = (offerId) => {
337
+ if (offerId == null)
338
+ return null;
339
+ const normalizedOfferId = offerId.toString().trim();
340
+ return normalizedOfferId.length > 0 ? normalizedOfferId : null;
341
+ };
342
+ const getSafeCount = (value, fallback = 1) => {
343
+ const parsedCount = Number(value);
344
+ if (!Number.isFinite(parsedCount) || parsedCount <= 0) {
345
+ return fallback;
346
+ }
347
+ return Math.floor(parsedCount);
348
+ };
349
+ const incrementOfferCount = (offerId, quantity = 1) => {
350
+ const normalizedOfferId = getNormalizedOfferId(offerId);
351
+ if (normalizedOfferId == null)
352
+ return;
353
+ const safeQuantity = getSafeCount(quantity, 1);
354
+ derivedRedeemedOffers[normalizedOfferId] = (derivedRedeemedOffers[normalizedOfferId] ?? 0) + safeQuantity;
355
+ };
356
+ if (existingRedeemedOffers != null) {
357
+ const entries = Object.entries(existingRedeemedOffers);
358
+ for (let i = 0; i < entries.length; i++) {
359
+ const [offerId, count] = entries[i];
360
+ const normalizedOfferId = getNormalizedOfferId(offerId);
361
+ if (normalizedOfferId == null)
362
+ continue;
363
+ normalizedExistingRedeemedOffers[normalizedOfferId] = getSafeCount(count, 0);
364
+ }
365
+ }
366
+ incrementOfferCount(orderDiscountDetails?.loyalty_discount_id, 1);
367
+ incrementOfferCount(orderDiscountDetails?.voucher_discount_id, 1);
368
+ for (let i = 0; i < categories.length; i++) {
369
+ const category = categories[i];
370
+ for (let j = 0; j < category.items.length; j++) {
371
+ const item = category.items[j];
372
+ if (item.item_discount_details == null)
373
+ continue;
374
+ const itemQuantity = Number.isFinite(item.quantity) && item.quantity > 0 ? Math.floor(item.quantity) : 1;
375
+ incrementOfferCount(item.item_discount_details.loyalty_discount_id, itemQuantity);
376
+ incrementOfferCount(item.item_discount_details.voucher_discount_id, itemQuantity);
377
+ }
378
+ }
379
+ const redeemedOffers = {
380
+ ...normalizedExistingRedeemedOffers,
381
+ };
382
+ const derivedOfferIds = Object.keys(derivedRedeemedOffers);
383
+ for (let i = 0; i < derivedOfferIds.length; i++) {
384
+ const offerId = derivedOfferIds[i];
385
+ const existingCount = normalizedExistingRedeemedOffers[offerId] ?? 0;
386
+ const derivedCount = derivedRedeemedOffers[offerId] ?? 0;
387
+ redeemedOffers[offerId] = Math.max(existingCount, derivedCount);
388
+ }
389
+ return Object.keys(redeemedOffers).length > 0 ? redeemedOffers : null;
390
+ }
333
391
  function calculateCartOrderInfoAndSyncData(data, courses, listnerSettings, calculateItemMetadata) {
334
392
  const isCompleted = data.order_status === constants_1.ORDER_STATUS_ENUM.COMPLETED;
335
393
  /* ===============================><=============================== */
@@ -598,6 +656,7 @@ function calculateCartOrderInfoAndSyncData(data, courses, listnerSettings, calcu
598
656
  ...data,
599
657
  categories,
600
658
  order_discount_details,
659
+ redeemed_offers: getRedeemedOffersMap(order_discount_details, categories, data.redeemed_offers),
601
660
  total_discount_applied,
602
661
  delivery_details,
603
662
  tax_amount,
@@ -212,7 +212,7 @@ function calculatePointsRedeemedForOffer(redeemedOffer, totalOrderPrice, categor
212
212
  // then we need to calculate the points redeemed for 2 pizzas
213
213
  if (redeemedOffer.pathway_to_unlock_type === constants_1.PATHWAY_TO_UNLOCK_TYPE_ENUM.ITEMS) {
214
214
  if (redeemedOffer.pathway_to_unlock_type_items != null) {
215
- const { num_of_items, max_claims, max_same_item_quantity, total_amount, excluded_refs, exclusive_refs, item_ids, category_ids, } = redeemedOffer.pathway_to_unlock_type_items;
215
+ const { num_of_items, max_claims, min_same_item_quantity, max_same_item_quantity, total_amount, excluded_refs, exclusive_refs, item_ids, category_ids, } = redeemedOffer.pathway_to_unlock_type_items;
216
216
  // A Bachelor Item is an item that meets the criteria of the redeemedOffer and doesn't have any redeemedOffer applied to it
217
217
  const bachelorItems = getCartItemsApplicableToOfferItemsQuantity({
218
218
  categories,
@@ -220,6 +220,7 @@ function calculatePointsRedeemedForOffer(redeemedOffer, totalOrderPrice, categor
220
220
  exclusive_refs,
221
221
  item_ids,
222
222
  category_ids,
223
+ min_same_item_quantity,
223
224
  max_same_item_quantity,
224
225
  });
225
226
  if (bachelorItems >= num_of_items) {
@@ -375,7 +376,7 @@ function calculateCustomerLoyaltyPoints({ customerLoyaltyPoints, orderDiscountDe
375
376
  deductedLoyaltyPoints,
376
377
  };
377
378
  }
378
- function getCartItemsApplicableToOfferItemsQuantity({ categories, excluded_refs, exclusive_refs, item_ids, category_ids, max_same_item_quantity, }) {
379
+ function getCartItemsApplicableToOfferItemsQuantity({ categories, excluded_refs, exclusive_refs, item_ids, category_ids, min_same_item_quantity, max_same_item_quantity, }) {
379
380
  if (categories == null)
380
381
  return 0;
381
382
  const checkIfItemHasAnyRef = (item, refs_arr) => {
@@ -411,14 +412,26 @@ function getCartItemsApplicableToOfferItemsQuantity({ categories, excluded_refs,
411
412
  };
412
413
  const applicableItems = categories.reduce((acc, category) => {
413
414
  category.items.forEach((item) => {
415
+ const hasItemFilter = item_ids.length > 0;
416
+ const hasCategoryFilter = category_ids.length > 0;
414
417
  const isItemMatched = item_ids.length > 0 && item_ids.includes(item.item_id);
415
418
  const isCategoryMatched = category_ids.length > 0 && category_ids.includes(category.category_id);
419
+ const isItemCategoryScopeMatched = hasItemFilter && hasCategoryFilter
420
+ ? isItemMatched && isCategoryMatched
421
+ : hasItemFilter
422
+ ? isItemMatched
423
+ : hasCategoryFilter
424
+ ? isCategoryMatched
425
+ : false;
416
426
  if (
417
427
  // We only want to check for items that don't have any loyalty or voucher discounts
418
428
  item.item_discount_details?.loyalty_discount_id == null &&
419
429
  item.item_discount_details?.voucher_discount_id == null &&
420
- // Item matches either explicit item list or selected category list.
421
- (isItemMatched || isCategoryMatched) &&
430
+ // Matching precedence:
431
+ // 1) only item_ids => match item_ids,
432
+ // 2) only category_ids => match category_ids,
433
+ // 3) both => match item_ids within matched category_ids.
434
+ isItemCategoryScopeMatched &&
422
435
  // We only want to check for items that don't have any modifiers/options that are excluded
423
436
  (excluded_refs.length === 0 || (excluded_refs.length > 0 && !checkIfItemHasAnyRef(item, excluded_refs))) &&
424
437
  // We only want to check for items that have at least one modifier/option that is inclusive
@@ -432,13 +445,18 @@ function getCartItemsApplicableToOfferItemsQuantity({ categories, excluded_refs,
432
445
  });
433
446
  return acc;
434
447
  }, []) ?? [];
435
- const maxSameItemQuantity = max_same_item_quantity == null ? Infinity : Math.max(1, max_same_item_quantity);
448
+ const minSameItemQuantity = min_same_item_quantity == null ? 1 : Math.max(1, min_same_item_quantity);
449
+ const maxSameItemQuantity = max_same_item_quantity == null ? Infinity : Math.max(minSameItemQuantity, max_same_item_quantity);
436
450
  const quantityByItemId = applicableItems.reduce((acc, item) => {
437
451
  acc[item.item_id] = (acc[item.item_id] ?? 0) + item.quantity;
438
452
  return acc;
439
453
  }, {});
440
454
  const totalQuantity = Object.values(quantityByItemId).reduce((acc, quantity) => {
441
- acc += Math.min(quantity, maxSameItemQuantity);
455
+ const boundedQuantity = Math.min(quantity, maxSameItemQuantity);
456
+ if (boundedQuantity < minSameItemQuantity) {
457
+ return acc;
458
+ }
459
+ acc += boundedQuantity;
442
460
  return acc;
443
461
  }, 0);
444
462
  return totalQuantity;
@@ -651,10 +669,13 @@ function getOffersWithStats({ offers, customer, vouchers, customerVoucherUsage,
651
669
  if (Number.isFinite(redeemedTimes) && redeemedTimes > 0) {
652
670
  return Math.floor(redeemedTimes);
653
671
  }
654
- const redeemedFromDiscountDetails = order_discount_details != null &&
655
- (order_discount_details.loyalty_discount_id === offerId ||
656
- order_discount_details.voucher_discount_id === offerId);
657
- return redeemedFromDiscountDetails ? 1 : 0;
672
+ return 0;
673
+ };
674
+ const getItemRewardRedeemedTimes = ({ offerId, totalOfferItemsSelected, applicableQuantity, }) => {
675
+ const selectedRewardTimes = Math.floor(totalOfferItemsSelected / applicableQuantity);
676
+ const mappedRedeemedTimes = getOfferRedeemedTimes(offerId);
677
+ // Keep item-based reward redemption in sync with the canonical redeemed_offers map.
678
+ return Math.max(selectedRewardTimes, mappedRedeemedTimes);
658
679
  };
659
680
  const getOrdersScopedStats = ({ scope, currentOrderValue, }) => {
660
681
  if (scope === constants_1.PATHWAY_TO_UNLOCK_TYPE_ORDERS_SCOPE_ENUM.OVERALL) {
@@ -781,19 +802,17 @@ function getOffersWithStats({ offers, customer, vouchers, customerVoucherUsage,
781
802
  offersWithStats.push({ offer, stats });
782
803
  continue;
783
804
  }
784
- const claimable = order_discount_details == null ||
785
- (order_discount_details.loyalty_discount_id != offer._id &&
786
- order_discount_details.voucher_discount_id != offer._id);
787
- stats.claimable = claimable;
805
+ const redeemedTimes = getOfferRedeemedTimes(offer._id);
806
+ const isRedeemed = redeemedTimes > 0;
807
+ stats.claimable = !isRedeemed;
788
808
  stats.applicable_quantity = 1;
789
- if (claimable) {
809
+ stats.redeemed_times = redeemedTimes;
810
+ if (!isRedeemed) {
790
811
  totalClaimableOffers += 1;
791
- stats.redeemed_times = 0;
792
812
  stats.message = `🎉 You have unlocked this offer 🎉`;
793
813
  }
794
814
  else {
795
815
  stats.message = 'This offer is redeemed ✅';
796
- stats.redeemed_times = 1;
797
816
  }
798
817
  unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
799
818
  }
@@ -812,7 +831,11 @@ function getOffersWithStats({ offers, customer, vouchers, customerVoucherUsage,
812
831
  }
813
832
  const applicableQuantity = offer.reward_discount_items.num_of_items || 1;
814
833
  const totalOfferItemsSelected = (0, exports.getTotalSelectedOfferItemsAgainstOffer)(categories, offer._id);
815
- const redeemedTimes = Math.floor(totalOfferItemsSelected / applicableQuantity);
834
+ const redeemedTimes = getItemRewardRedeemedTimes({
835
+ offerId: offer._id,
836
+ totalOfferItemsSelected,
837
+ applicableQuantity,
838
+ });
816
839
  const maxRedeemableClaims = 1;
817
840
  const isClaimable = redeemedTimes < maxRedeemableClaims;
818
841
  stats.redeemed_times = redeemedTimes;
@@ -913,8 +936,12 @@ function getOffersWithStats({ offers, customer, vouchers, customerVoucherUsage,
913
936
  continue;
914
937
  const applicableQuantity = offer.reward_items.num_of_items || 1;
915
938
  const totalOfferItemsSelected = (0, exports.getTotalSelectedOfferItemsAgainstOffer)(categories, offer._id);
916
- const redeemedTimes = Math.floor(totalOfferItemsSelected / applicableQuantity);
917
- const isClaimable = totalOfferItemsSelected < applicableQuantity;
939
+ const redeemedTimes = getItemRewardRedeemedTimes({
940
+ offerId: offer._id,
941
+ totalOfferItemsSelected,
942
+ applicableQuantity,
943
+ });
944
+ const isClaimable = redeemedTimes < 1;
918
945
  stats.redeemed_times = redeemedTimes;
919
946
  stats.applicable_quantity = applicableQuantity;
920
947
  if (isClaimable) {
@@ -943,13 +970,14 @@ function getOffersWithStats({ offers, customer, vouchers, customerVoucherUsage,
943
970
  continue;
944
971
  }
945
972
  const orderValue = orderPrice - totalDiscount;
946
- const { num_of_items, max_claims, max_same_item_quantity, total_amount, excluded_refs, exclusive_refs, item_ids, category_ids, } = offer.pathway_to_unlock_type_items;
973
+ const { num_of_items, max_claims, min_same_item_quantity, max_same_item_quantity, total_amount, excluded_refs, exclusive_refs, item_ids, category_ids, } = offer.pathway_to_unlock_type_items;
947
974
  const bachelorItems = getCartItemsApplicableToOfferItemsQuantity({
948
975
  categories,
949
976
  excluded_refs,
950
977
  exclusive_refs,
951
978
  item_ids,
952
979
  category_ids,
980
+ min_same_item_quantity,
953
981
  max_same_item_quantity,
954
982
  });
955
983
  const totalOfferItemsSelected = (0, exports.getTotalSelectedOfferItemsAgainstOffer)(categories, offer._id);
@@ -1016,7 +1044,11 @@ function getOffersWithStats({ offers, customer, vouchers, customerVoucherUsage,
1016
1044
  continue;
1017
1045
  }
1018
1046
  const applicableQuantity = offer.reward_discount_items.num_of_items || 1;
1019
- const redeemedTimes = Math.floor(totalOfferItemsSelected / applicableQuantity);
1047
+ const redeemedTimes = getItemRewardRedeemedTimes({
1048
+ offerId: offer._id,
1049
+ totalOfferItemsSelected,
1050
+ applicableQuantity,
1051
+ });
1020
1052
  const isClaimable = redeemedTimes < totalUnlockableClaims;
1021
1053
  stats.redeemed_times = redeemedTimes;
1022
1054
  stats.applicable_quantity = applicableQuantity * Math.max(1, totalUnlockableClaims);
@@ -1110,7 +1142,11 @@ function getOffersWithStats({ offers, customer, vouchers, customerVoucherUsage,
1110
1142
  if (offer.reward_items == null)
1111
1143
  continue;
1112
1144
  const applicableQuantity = offer.reward_items.num_of_items || 1;
1113
- const redeemedTimes = Math.floor(totalOfferItemsSelected / applicableQuantity);
1145
+ const redeemedTimes = getItemRewardRedeemedTimes({
1146
+ offerId: offer._id,
1147
+ totalOfferItemsSelected,
1148
+ applicableQuantity,
1149
+ });
1114
1150
  const isClaimable = redeemedTimes < totalUnlockableClaims;
1115
1151
  stats.redeemed_times = redeemedTimes;
1116
1152
  stats.applicable_quantity = applicableQuantity * Math.max(1, totalUnlockableClaims);
@@ -1215,7 +1251,11 @@ function getOffersWithStats({ offers, customer, vouchers, customerVoucherUsage,
1215
1251
  }
1216
1252
  const totalOfferItemsSelected = (0, exports.getTotalSelectedOfferItemsAgainstOffer)(categories, offer._id);
1217
1253
  const applicableQuantity = offer.reward_discount_items.num_of_items || 1;
1218
- const redeemedTimes = Math.floor(totalOfferItemsSelected / applicableQuantity);
1254
+ const redeemedTimes = getItemRewardRedeemedTimes({
1255
+ offerId: offer._id,
1256
+ totalOfferItemsSelected,
1257
+ applicableQuantity,
1258
+ });
1219
1259
  const isClaimable = redeemedTimes < totalUnlockableClaims;
1220
1260
  stats.redeemed_times = redeemedTimes;
1221
1261
  stats.applicable_quantity = applicableQuantity * Math.max(1, totalUnlockableClaims);
@@ -1310,7 +1350,11 @@ function getOffersWithStats({ offers, customer, vouchers, customerVoucherUsage,
1310
1350
  continue;
1311
1351
  const totalOfferItemsSelected = (0, exports.getTotalSelectedOfferItemsAgainstOffer)(categories, offer._id);
1312
1352
  const applicableQuantity = offer.reward_items.num_of_items || 1;
1313
- const redeemedTimes = Math.floor(totalOfferItemsSelected / applicableQuantity);
1353
+ const redeemedTimes = getItemRewardRedeemedTimes({
1354
+ offerId: offer._id,
1355
+ totalOfferItemsSelected,
1356
+ applicableQuantity,
1357
+ });
1314
1358
  const isClaimable = redeemedTimes < totalUnlockableClaims;
1315
1359
  stats.redeemed_times = redeemedTimes;
1316
1360
  stats.applicable_quantity = applicableQuantity * Math.max(1, totalUnlockableClaims);
@@ -1418,7 +1462,11 @@ function getOffersWithStats({ offers, customer, vouchers, customerVoucherUsage,
1418
1462
  }
1419
1463
  const totalOfferItemsSelected = (0, exports.getTotalSelectedOfferItemsAgainstOffer)(categories, offer._id);
1420
1464
  const applicableQuantity = offer.reward_discount_items.num_of_items || 1;
1421
- const redeemedTimes = Math.floor(totalOfferItemsSelected / applicableQuantity);
1465
+ const redeemedTimes = getItemRewardRedeemedTimes({
1466
+ offerId: offer._id,
1467
+ totalOfferItemsSelected,
1468
+ applicableQuantity,
1469
+ });
1422
1470
  const maxRedeemableClaims = 1;
1423
1471
  const isClaimable = redeemedTimes < maxRedeemableClaims;
1424
1472
  stats.redeemed_times = redeemedTimes;
@@ -1514,8 +1562,12 @@ function getOffersWithStats({ offers, customer, vouchers, customerVoucherUsage,
1514
1562
  continue;
1515
1563
  const totalOfferItemsSelected = (0, exports.getTotalSelectedOfferItemsAgainstOffer)(categories, offer._id);
1516
1564
  const applicableQuantity = offer.reward_items.num_of_items || 1;
1517
- const redeemedTimes = Math.floor(totalOfferItemsSelected / applicableQuantity);
1518
- const isClaimable = totalOfferItemsSelected < applicableQuantity;
1565
+ const redeemedTimes = getItemRewardRedeemedTimes({
1566
+ offerId: offer._id,
1567
+ totalOfferItemsSelected,
1568
+ applicableQuantity,
1569
+ });
1570
+ const isClaimable = redeemedTimes < 1;
1519
1571
  stats.redeemed_times = redeemedTimes;
1520
1572
  stats.applicable_quantity = applicableQuantity;
1521
1573
  stats.claimable = isClaimable;
@@ -1,6 +1,8 @@
1
1
  import { CURRENCY_SYMBOL_ENUM } from '../../constants';
2
2
  export interface IVoidItemsReportRow {
3
3
  platform?: string;
4
+ vendor_name?: string;
5
+ client_name?: string;
4
6
  order_number: number | null;
5
7
  quantity: number;
6
8
  subtotal: number;
@@ -11,6 +11,14 @@ const common_1 = require("./common");
11
11
  // Generate HTML template for void items report
12
12
  function getVoidItemsReportHtml(props) {
13
13
  const { data, tenantName, from, to, width = 800, monochrome = false, currency_symbol } = props;
14
+ const hasVendorName = data.some((item) => typeof item.vendor_name === 'string' && item.vendor_name.trim().length > 0);
15
+ const hasClientName = data.some((item) => typeof item.client_name === 'string' && item.client_name.trim().length > 0);
16
+ const hasPartyNameColumn = hasVendorName || hasClientName;
17
+ const partyNameColumnTitle = hasVendorName && !hasClientName
18
+ ? 'Vendor Name'
19
+ : hasClientName && !hasVendorName
20
+ ? 'Client Name'
21
+ : 'Vendor/Client Name';
14
22
  const mainStyle = width ? `style="width: ${width}px; max-width: ${width}px"` : '';
15
23
  const fromFormatted = from ? (0, moment_1.default)(from).format('MMM DD, YYYY') : 'N/A';
16
24
  const toFormatted = to ? (0, moment_1.default)(to).format('MMM DD, YYYY') : 'N/A';
@@ -239,7 +247,7 @@ function getVoidItemsReportHtml(props) {
239
247
  if (data.length === 0) {
240
248
  return `
241
249
  <tr>
242
- <td colspan="12" class="no-data">
250
+ <td colspan="${hasPartyNameColumn ? 13 : 12}" class="no-data">
243
251
  No void items data available for the selected period.
244
252
  </td>
245
253
  </tr>
@@ -261,6 +269,7 @@ function getVoidItemsReportHtml(props) {
261
269
  <span class="quantity-removed">${removedQuantity}</span>
262
270
  </td>
263
271
  <td>${item.name || 'N/A'}</td>
272
+ ${hasPartyNameColumn ? `<td>${item.vendor_name || item.client_name || 'N/A'}</td>` : ''}
264
273
  <td class="text-right">${(0, common_1.localeAmount)(currency_symbol, voidAmount)}</td>
265
274
  <td class="void-reason">${item.void_reason ? (0, common_1.getFormattedCancellationReason)(item.void_reason) : 'N/A'}</td>
266
275
  <td>${item.staff_name || 'N/A'}</td>
@@ -302,6 +311,7 @@ function getVoidItemsReportHtml(props) {
302
311
  <th>Order Number</th>
303
312
  <th>Quantity Removed</th>
304
313
  <th>Item</th>
314
+ ${hasPartyNameColumn ? `<th>${partyNameColumnTitle}</th>` : ''}
305
315
  <th>Void Amount</th>
306
316
  <th>Reason</th>
307
317
  <th>Staff Name</th>
@@ -16,12 +16,11 @@ export declare const OfferSchema: Schema<any, import("mongoose").Model<any, any,
16
16
  image_url: string;
17
17
  description: string;
18
18
  brand_id: string;
19
- active: boolean;
20
19
  sort_id: number;
21
20
  included_platforms: import("../../constants").PLATFORMS_ENUM[];
22
- auto_apply: boolean;
23
21
  pathway_to_unlock_type: import("../../constants").PATHWAY_TO_UNLOCK_TYPE_ENUM;
24
22
  reward_type: import("../../constants").OFFER_REWARD_TYPE_ENUM;
23
+ active?: boolean | null | undefined;
25
24
  offer_special_hours?: import("mongoose").Types.DocumentArray<{
26
25
  days_index: import("../../constants").DAY_INDEX_ENUM[];
27
26
  disabled_outside_date_range: boolean;
@@ -308,6 +307,7 @@ export declare const OfferSchema: Schema<any, import("mongoose").Model<any, any,
308
307
  BASE_PRICE: number;
309
308
  } | null | undefined;
310
309
  }> | null | undefined;
310
+ auto_apply?: boolean | null | undefined;
311
311
  pathway_to_unlock_type_items?: {
312
312
  excluded_refs: string[];
313
313
  exclusive_refs: string[];
@@ -315,6 +315,7 @@ export declare const OfferSchema: Schema<any, import("mongoose").Model<any, any,
315
315
  total_amount: number;
316
316
  item_ids?: import("mongoose").Types.ObjectId[] | null | undefined;
317
317
  max_claims?: number | null | undefined;
318
+ min_same_item_quantity?: number | null | undefined;
318
319
  max_same_item_quantity?: number | null | undefined;
319
320
  category_ids?: import("mongoose").Types.ObjectId[] | null | undefined;
320
321
  } | null | undefined;
@@ -352,17 +353,17 @@ export declare const OfferSchema: Schema<any, import("mongoose").Model<any, any,
352
353
  }> | null | undefined;
353
354
  } | null | undefined;
354
355
  reward_discount?: {
355
- is_discount_percentage: boolean;
356
356
  excluded_refs: string[];
357
357
  discount_value: number;
358
+ is_discount_percentage?: boolean | null | undefined;
358
359
  } | null | undefined;
359
360
  reward_discount_items?: {
360
- is_discount_percentage: boolean;
361
361
  item_ids: import("mongoose").Types.ObjectId[];
362
362
  excluded_refs: string[];
363
363
  exclusive_refs: string[];
364
364
  num_of_items: number;
365
365
  discount_value: number;
366
+ is_discount_percentage?: boolean | null | undefined;
366
367
  allocation?: import("mongoose").Types.DocumentArray<{
367
368
  item_ids: import("mongoose").Types.ObjectId[];
368
369
  quantity: number;
@@ -376,12 +377,12 @@ export declare const OfferSchema: Schema<any, import("mongoose").Model<any, any,
376
377
  } | null | undefined;
377
378
  reward_points?: {
378
379
  num_of_points: number;
379
- once_per_order: boolean;
380
+ once_per_order?: boolean | null | undefined;
380
381
  } | null | undefined;
381
382
  reward_cashback?: {
382
383
  excluded_refs: string[];
383
384
  cashback_value: number;
384
- is_cashback_percentage: boolean;
385
+ is_cashback_percentage?: boolean | null | undefined;
385
386
  max_cashback_amount?: number | null | undefined;
386
387
  } | null | undefined;
387
388
  reward_gift_cards?: {
@@ -402,12 +403,11 @@ export declare const OfferSchema: Schema<any, import("mongoose").Model<any, any,
402
403
  image_url: string;
403
404
  description: string;
404
405
  brand_id: string;
405
- active: boolean;
406
406
  sort_id: number;
407
407
  included_platforms: import("../../constants").PLATFORMS_ENUM[];
408
- auto_apply: boolean;
409
408
  pathway_to_unlock_type: import("../../constants").PATHWAY_TO_UNLOCK_TYPE_ENUM;
410
409
  reward_type: import("../../constants").OFFER_REWARD_TYPE_ENUM;
410
+ active?: boolean | null | undefined;
411
411
  offer_special_hours?: import("mongoose").Types.DocumentArray<{
412
412
  days_index: import("../../constants").DAY_INDEX_ENUM[];
413
413
  disabled_outside_date_range: boolean;
@@ -694,6 +694,7 @@ export declare const OfferSchema: Schema<any, import("mongoose").Model<any, any,
694
694
  BASE_PRICE: number;
695
695
  } | null | undefined;
696
696
  }> | null | undefined;
697
+ auto_apply?: boolean | null | undefined;
697
698
  pathway_to_unlock_type_items?: {
698
699
  excluded_refs: string[];
699
700
  exclusive_refs: string[];
@@ -701,6 +702,7 @@ export declare const OfferSchema: Schema<any, import("mongoose").Model<any, any,
701
702
  total_amount: number;
702
703
  item_ids?: import("mongoose").Types.ObjectId[] | null | undefined;
703
704
  max_claims?: number | null | undefined;
705
+ min_same_item_quantity?: number | null | undefined;
704
706
  max_same_item_quantity?: number | null | undefined;
705
707
  category_ids?: import("mongoose").Types.ObjectId[] | null | undefined;
706
708
  } | null | undefined;
@@ -738,17 +740,17 @@ export declare const OfferSchema: Schema<any, import("mongoose").Model<any, any,
738
740
  }> | null | undefined;
739
741
  } | null | undefined;
740
742
  reward_discount?: {
741
- is_discount_percentage: boolean;
742
743
  excluded_refs: string[];
743
744
  discount_value: number;
745
+ is_discount_percentage?: boolean | null | undefined;
744
746
  } | null | undefined;
745
747
  reward_discount_items?: {
746
- is_discount_percentage: boolean;
747
748
  item_ids: import("mongoose").Types.ObjectId[];
748
749
  excluded_refs: string[];
749
750
  exclusive_refs: string[];
750
751
  num_of_items: number;
751
752
  discount_value: number;
753
+ is_discount_percentage?: boolean | null | undefined;
752
754
  allocation?: import("mongoose").Types.DocumentArray<{
753
755
  item_ids: import("mongoose").Types.ObjectId[];
754
756
  quantity: number;
@@ -762,12 +764,12 @@ export declare const OfferSchema: Schema<any, import("mongoose").Model<any, any,
762
764
  } | null | undefined;
763
765
  reward_points?: {
764
766
  num_of_points: number;
765
- once_per_order: boolean;
767
+ once_per_order?: boolean | null | undefined;
766
768
  } | null | undefined;
767
769
  reward_cashback?: {
768
770
  excluded_refs: string[];
769
771
  cashback_value: number;
770
- is_cashback_percentage: boolean;
772
+ is_cashback_percentage?: boolean | null | undefined;
771
773
  max_cashback_amount?: number | null | undefined;
772
774
  } | null | undefined;
773
775
  reward_gift_cards?: {
@@ -788,12 +790,11 @@ export declare const OfferSchema: Schema<any, import("mongoose").Model<any, any,
788
790
  image_url: string;
789
791
  description: string;
790
792
  brand_id: string;
791
- active: boolean;
792
793
  sort_id: number;
793
794
  included_platforms: import("../../constants").PLATFORMS_ENUM[];
794
- auto_apply: boolean;
795
795
  pathway_to_unlock_type: import("../../constants").PATHWAY_TO_UNLOCK_TYPE_ENUM;
796
796
  reward_type: import("../../constants").OFFER_REWARD_TYPE_ENUM;
797
+ active?: boolean | null | undefined;
797
798
  offer_special_hours?: import("mongoose").Types.DocumentArray<{
798
799
  days_index: import("../../constants").DAY_INDEX_ENUM[];
799
800
  disabled_outside_date_range: boolean;
@@ -1080,6 +1081,7 @@ export declare const OfferSchema: Schema<any, import("mongoose").Model<any, any,
1080
1081
  BASE_PRICE: number;
1081
1082
  } | null | undefined;
1082
1083
  }> | null | undefined;
1084
+ auto_apply?: boolean | null | undefined;
1083
1085
  pathway_to_unlock_type_items?: {
1084
1086
  excluded_refs: string[];
1085
1087
  exclusive_refs: string[];
@@ -1087,6 +1089,7 @@ export declare const OfferSchema: Schema<any, import("mongoose").Model<any, any,
1087
1089
  total_amount: number;
1088
1090
  item_ids?: import("mongoose").Types.ObjectId[] | null | undefined;
1089
1091
  max_claims?: number | null | undefined;
1092
+ min_same_item_quantity?: number | null | undefined;
1090
1093
  max_same_item_quantity?: number | null | undefined;
1091
1094
  category_ids?: import("mongoose").Types.ObjectId[] | null | undefined;
1092
1095
  } | null | undefined;
@@ -1124,17 +1127,17 @@ export declare const OfferSchema: Schema<any, import("mongoose").Model<any, any,
1124
1127
  }> | null | undefined;
1125
1128
  } | null | undefined;
1126
1129
  reward_discount?: {
1127
- is_discount_percentage: boolean;
1128
1130
  excluded_refs: string[];
1129
1131
  discount_value: number;
1132
+ is_discount_percentage?: boolean | null | undefined;
1130
1133
  } | null | undefined;
1131
1134
  reward_discount_items?: {
1132
- is_discount_percentage: boolean;
1133
1135
  item_ids: import("mongoose").Types.ObjectId[];
1134
1136
  excluded_refs: string[];
1135
1137
  exclusive_refs: string[];
1136
1138
  num_of_items: number;
1137
1139
  discount_value: number;
1140
+ is_discount_percentage?: boolean | null | undefined;
1138
1141
  allocation?: import("mongoose").Types.DocumentArray<{
1139
1142
  item_ids: import("mongoose").Types.ObjectId[];
1140
1143
  quantity: number;
@@ -1148,12 +1151,12 @@ export declare const OfferSchema: Schema<any, import("mongoose").Model<any, any,
1148
1151
  } | null | undefined;
1149
1152
  reward_points?: {
1150
1153
  num_of_points: number;
1151
- once_per_order: boolean;
1154
+ once_per_order?: boolean | null | undefined;
1152
1155
  } | null | undefined;
1153
1156
  reward_cashback?: {
1154
1157
  excluded_refs: string[];
1155
1158
  cashback_value: number;
1156
- is_cashback_percentage: boolean;
1159
+ is_cashback_percentage?: boolean | null | undefined;
1157
1160
  max_cashback_amount?: number | null | undefined;
1158
1161
  } | null | undefined;
1159
1162
  reward_gift_cards?: {
@@ -12,12 +12,14 @@ const PathwayToUnlockTypeItemsSchema = new mongoose_1.Schema({
12
12
  max_claims: {
13
13
  type: Number,
14
14
  required: false,
15
- default: 1,
15
+ },
16
+ min_same_item_quantity: {
17
+ type: Number,
18
+ required: false,
16
19
  },
17
20
  max_same_item_quantity: {
18
21
  type: Number,
19
22
  required: false,
20
- default: null,
21
23
  },
22
24
  total_amount: {
23
25
  type: Number,
@@ -25,21 +27,17 @@ const PathwayToUnlockTypeItemsSchema = new mongoose_1.Schema({
25
27
  },
26
28
  excluded_refs: {
27
29
  type: [String],
28
- default: [],
29
30
  },
30
31
  exclusive_refs: {
31
32
  type: [String],
32
- default: [],
33
33
  },
34
34
  item_ids: {
35
35
  type: [mongoose_1.Schema.Types.ObjectId],
36
36
  required: false,
37
- default: [],
38
37
  },
39
38
  category_ids: {
40
39
  type: [mongoose_1.Schema.Types.ObjectId],
41
40
  required: false,
42
- default: [],
43
41
  },
44
42
  }, {
45
43
  _id: false,
@@ -115,11 +113,9 @@ const RewardItemsSchema = new mongoose_1.Schema({
115
113
  },
116
114
  excluded_refs: {
117
115
  type: [String],
118
- default: [],
119
116
  },
120
117
  exclusive_refs: {
121
118
  type: [String],
122
- default: [],
123
119
  },
124
120
  item_ids: {
125
121
  type: [mongoose_1.Schema.Types.ObjectId],
@@ -153,11 +149,9 @@ const RewardDiscountSchema = new mongoose_1.Schema({
153
149
  },
154
150
  is_discount_percentage: {
155
151
  type: Boolean,
156
- default: false,
157
152
  },
158
153
  excluded_refs: {
159
154
  type: [String],
160
- default: [],
161
155
  },
162
156
  }, {
163
157
  _id: false,
@@ -170,11 +164,9 @@ const RewardDiscountItemsSchema = new mongoose_1.Schema({
170
164
  },
171
165
  excluded_refs: {
172
166
  type: [String],
173
- default: [],
174
167
  },
175
168
  exclusive_refs: {
176
169
  type: [String],
177
- default: [],
178
170
  },
179
171
  item_ids: {
180
172
  type: [mongoose_1.Schema.Types.ObjectId],
@@ -203,7 +195,6 @@ const RewardDiscountItemsSchema = new mongoose_1.Schema({
203
195
  },
204
196
  is_discount_percentage: {
205
197
  type: Boolean,
206
- default: false,
207
198
  },
208
199
  }, {
209
200
  _id: false,
@@ -216,7 +207,6 @@ const RewardPointsSchema = new mongoose_1.Schema({
216
207
  },
217
208
  once_per_order: {
218
209
  type: Boolean,
219
- default: false,
220
210
  },
221
211
  }, {
222
212
  _id: false,
@@ -229,7 +219,6 @@ const RewardCashbackSchema = new mongoose_1.Schema({
229
219
  },
230
220
  is_cashback_percentage: {
231
221
  type: Boolean,
232
- default: false,
233
222
  },
234
223
  max_cashback_amount: {
235
224
  type: Number,
@@ -237,7 +226,6 @@ const RewardCashbackSchema = new mongoose_1.Schema({
237
226
  },
238
227
  excluded_refs: {
239
228
  type: [String],
240
- default: [],
241
229
  },
242
230
  }, {
243
231
  _id: false,
@@ -294,7 +282,6 @@ exports.OfferSchema = new mongoose_1.Schema({
294
282
  },
295
283
  active: {
296
284
  type: Boolean,
297
- default: true,
298
285
  },
299
286
  included_platforms: {
300
287
  type: [item_1.PlatformsSchema],
@@ -311,7 +298,6 @@ exports.OfferSchema = new mongoose_1.Schema({
311
298
  },
312
299
  auto_apply: {
313
300
  type: Boolean,
314
- default: false,
315
301
  },
316
302
  pathway_to_unlock_type: {
317
303
  type: String,
@@ -23,6 +23,7 @@ export declare const VoidPurchaseOrderItemSchema: Schema<any, import("mongoose")
23
23
  subtotal: number;
24
24
  warehouse_id: string;
25
25
  vendor_id: import("mongoose").Types.ObjectId;
26
+ vendor_name: string;
26
27
  order_item_id: import("mongoose").Types.ObjectId;
27
28
  void_type: import("../../constants").VOID_PURCHASE_ORDER_ITEM_TYPE_ENUM;
28
29
  iteration: number;
@@ -77,6 +78,7 @@ export declare const VoidPurchaseOrderItemSchema: Schema<any, import("mongoose")
77
78
  subtotal: number;
78
79
  warehouse_id: string;
79
80
  vendor_id: import("mongoose").Types.ObjectId;
81
+ vendor_name: string;
80
82
  order_item_id: import("mongoose").Types.ObjectId;
81
83
  void_type: import("../../constants").VOID_PURCHASE_ORDER_ITEM_TYPE_ENUM;
82
84
  iteration: number;
@@ -131,6 +133,7 @@ export declare const VoidPurchaseOrderItemSchema: Schema<any, import("mongoose")
131
133
  subtotal: number;
132
134
  warehouse_id: string;
133
135
  vendor_id: import("mongoose").Types.ObjectId;
136
+ vendor_name: string;
134
137
  order_item_id: import("mongoose").Types.ObjectId;
135
138
  void_type: import("../../constants").VOID_PURCHASE_ORDER_ITEM_TYPE_ENUM;
136
139
  iteration: number;
@@ -92,6 +92,10 @@ exports.VoidPurchaseOrderItemSchema = new mongoose_1.Schema({
92
92
  required: true,
93
93
  ref: warehouse_vendors_1.WAREHOUSE_VENDORS_COLLECTION_NAME,
94
94
  },
95
+ vendor_name: {
96
+ type: String,
97
+ required: true,
98
+ },
95
99
  staff_id: {
96
100
  type: String,
97
101
  required: true,
@@ -29,6 +29,7 @@ export declare const VoidWarehouseInvoiceItemSchema: Schema<any, import("mongoos
29
29
  total_adjusted_subtotal: number;
30
30
  order_punched_at: NativeDate;
31
31
  client_id: import("mongoose").Types.ObjectId;
32
+ client_name: string;
32
33
  adjustments?: import("mongoose").Types.DocumentArray<{
33
34
  _id: import("mongoose").Types.ObjectId;
34
35
  order_id: import("mongoose").Types.ObjectId;
@@ -83,6 +84,7 @@ export declare const VoidWarehouseInvoiceItemSchema: Schema<any, import("mongoos
83
84
  total_adjusted_subtotal: number;
84
85
  order_punched_at: NativeDate;
85
86
  client_id: import("mongoose").Types.ObjectId;
87
+ client_name: string;
86
88
  adjustments?: import("mongoose").Types.DocumentArray<{
87
89
  _id: import("mongoose").Types.ObjectId;
88
90
  order_id: import("mongoose").Types.ObjectId;
@@ -137,6 +139,7 @@ export declare const VoidWarehouseInvoiceItemSchema: Schema<any, import("mongoos
137
139
  total_adjusted_subtotal: number;
138
140
  order_punched_at: NativeDate;
139
141
  client_id: import("mongoose").Types.ObjectId;
142
+ client_name: string;
140
143
  adjustments?: import("mongoose").Types.DocumentArray<{
141
144
  _id: import("mongoose").Types.ObjectId;
142
145
  order_id: import("mongoose").Types.ObjectId;
@@ -92,6 +92,10 @@ exports.VoidWarehouseInvoiceItemSchema = new mongoose_1.Schema({
92
92
  required: true,
93
93
  ref: warehouse_clients_1.WAREHOUSE_CLIENTS_COLLECTION_NAME,
94
94
  },
95
+ client_name: {
96
+ type: String,
97
+ required: true,
98
+ },
95
99
  staff_id: {
96
100
  type: String,
97
101
  required: true,
@@ -10,6 +10,7 @@ export interface IPathwayToUnlockTypeOrders {
10
10
  export interface IPathwayToUnlockTypeItems {
11
11
  num_of_items: number;
12
12
  max_claims: number | null;
13
+ min_same_item_quantity: number | null;
13
14
  max_same_item_quantity: number | null;
14
15
  total_amount: number;
15
16
  excluded_refs: string[];
@@ -18,6 +18,7 @@ export interface IVoidPurchaseOrderItem {
18
18
  order_item_id: string;
19
19
  void_type: VOID_PURCHASE_ORDER_ITEM_TYPE_ENUM;
20
20
  vendor_id: string;
21
+ vendor_name: string;
21
22
  staff_id: string;
22
23
  staff_name: string;
23
24
  void_reason: string;
@@ -18,6 +18,7 @@ export interface IVoidWarehouseInvoiceItem {
18
18
  order_item_id: string;
19
19
  void_type: VOID_WAREHOUSE_INVOICE_ITEM_TYPE_ENUM;
20
20
  client_id: string;
21
+ client_name: string;
21
22
  staff_id: string;
22
23
  staff_name: string;
23
24
  void_reason: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@managesome/eposmatic-toolkit",
3
- "version": "0.2.252",
3
+ "version": "0.2.254",
4
4
  "description": "A Toolkit Library for Eposmatic",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",