@managesome/eposmatic-toolkit 0.2.654 → 0.2.656

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.
@@ -67,8 +67,6 @@ export declare const SUBSCRIPTION_STATUS_COLOR: {
67
67
  EXPIRED: string;
68
68
  DUE_SOON: string;
69
69
  };
70
- export declare const SPECIALS_CATEGORY_ID = "680437e050ad8ba788150b32";
71
- export declare const SPECIALS_CATEGORY_NAME = "Specials";
72
70
  export declare const WALLET_CASHBACK_LOYALTY_DISCOUNT_ID = "wallet_cashback_redemption";
73
71
  export declare const WALLET_CASHBACK_LOYALTY_DISCOUNT_NAME = "Wallet Cashback";
74
72
  export declare const WALLET_CASHBACK_LOYALTY_REFERENCE = "WALLET_CASHBACK";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.STRAIGHT_LINE_ROAD_MULTIPLIER = exports.WALLET_CASHBACK_LOYALTY_REFERENCE = exports.WALLET_CASHBACK_LOYALTY_DISCOUNT_NAME = exports.WALLET_CASHBACK_LOYALTY_DISCOUNT_ID = exports.SPECIALS_CATEGORY_NAME = exports.SPECIALS_CATEGORY_ID = exports.SUBSCRIPTION_STATUS_COLOR = exports.AUTO_DELIVERY_CHARGES_PLATFORMS = exports.TAX_INVOICE_PROVIDER_CHARGES_MAP = exports.PAYMENT_CHARGES_MAP = exports.NOTIFICATION_CHARGES_MAP = exports.WHATSAPP_CHARGES_MAP = exports.SMS_CHARGES_MAP = exports.SMS_UNIT_LENGTH = exports.PROVIDER_OPERATIONAL_COUNTRIES = exports.ALL_PLAFORMS_OBJ = exports.LOW_VALUE_CURRENCY_COUNTRIES = void 0;
3
+ exports.STRAIGHT_LINE_ROAD_MULTIPLIER = exports.WALLET_CASHBACK_LOYALTY_REFERENCE = exports.WALLET_CASHBACK_LOYALTY_DISCOUNT_NAME = exports.WALLET_CASHBACK_LOYALTY_DISCOUNT_ID = exports.SUBSCRIPTION_STATUS_COLOR = exports.AUTO_DELIVERY_CHARGES_PLATFORMS = exports.TAX_INVOICE_PROVIDER_CHARGES_MAP = exports.PAYMENT_CHARGES_MAP = exports.NOTIFICATION_CHARGES_MAP = exports.WHATSAPP_CHARGES_MAP = exports.SMS_CHARGES_MAP = exports.SMS_UNIT_LENGTH = exports.PROVIDER_OPERATIONAL_COUNTRIES = exports.ALL_PLAFORMS_OBJ = exports.LOW_VALUE_CURRENCY_COUNTRIES = void 0;
4
4
  const ENUMS_1 = require("./ENUMS");
5
5
  /**
6
6
  * Countries with low-value currencies that should have:
@@ -366,8 +366,6 @@ exports.SUBSCRIPTION_STATUS_COLOR = {
366
366
  [ENUMS_1.SUBSCRIPTION_STATUS_ENUM.EXPIRED]: '#ff0000',
367
367
  [ENUMS_1.SUBSCRIPTION_STATUS_ENUM.DUE_SOON]: '#ffb300',
368
368
  };
369
- exports.SPECIALS_CATEGORY_ID = '680437e050ad8ba788150b32';
370
- exports.SPECIALS_CATEGORY_NAME = 'Specials';
371
369
  exports.WALLET_CASHBACK_LOYALTY_DISCOUNT_ID = 'wallet_cashback_redemption';
372
370
  exports.WALLET_CASHBACK_LOYALTY_DISCOUNT_NAME = 'Wallet Cashback';
373
371
  exports.WALLET_CASHBACK_LOYALTY_REFERENCE = 'WALLET_CASHBACK';
@@ -40,6 +40,20 @@ interface IConvertSpecialItemToOrderItem {
40
40
  existingOrderItem?: IOrderItem;
41
41
  }
42
42
  export declare function convertSpecialItemToOrderItem({ specialItem, modifierSpecials, quantity, platform, existingOrderItem, }: IConvertSpecialItemToOrderItem): IOrderItem;
43
+ /**
44
+ * De-structures a special IOrderItem back into the legacy selection format
45
+ * used by the SpecialsScreen selection flow (edit without classic preview).
46
+ *
47
+ * Each modifier on the order item maps back to its `IModifierSpecial` group
48
+ * (matched by ref or _id), and each selected option becomes a selection
49
+ * order item placed into the next free slot (up to modifier_special.quantity).
50
+ *
51
+ * Returns null if the order item doesn't belong to the provided special.
52
+ */
53
+ export declare function deStructureSpecialOrderItem(orderItem: IOrderItem, specialItem: IWorkableSpecialMenu<IItem>): {
54
+ modifierSpecials: IModifierSpecials[];
55
+ quantity: number;
56
+ } | null;
43
57
  /**
44
58
  * Converts an ISpecial into an IItem so it can flow through the standard
45
59
  * catalog → drawer → cart pipeline just like a regular catalog item.
@@ -10,6 +10,7 @@ exports.getSpecialsDeletedData = getSpecialsDeletedData;
10
10
  exports.getSpecialWithPrice = getSpecialWithPrice;
11
11
  exports.convertSpecialsToWorkableSpecials = convertSpecialsToWorkableSpecials;
12
12
  exports.convertSpecialItemToOrderItem = convertSpecialItemToOrderItem;
13
+ exports.deStructureSpecialOrderItem = deStructureSpecialOrderItem;
13
14
  exports.convertSpecialToItem = convertSpecialToItem;
14
15
  const bson_objectid_1 = __importDefault(require("bson-objectid"));
15
16
  const constants_1 = require("../../constants");
@@ -217,6 +218,57 @@ function convertSpecialItemToOrderItem({ specialItem, modifierSpecials, quantity
217
218
  return orderItem;
218
219
  }
219
220
  // ====================================================================================================
221
+ /**
222
+ * De-structures a special IOrderItem back into the legacy selection format
223
+ * used by the SpecialsScreen selection flow (edit without classic preview).
224
+ *
225
+ * Each modifier on the order item maps back to its `IModifierSpecial` group
226
+ * (matched by ref or _id), and each selected option becomes a selection
227
+ * order item placed into the next free slot (up to modifier_special.quantity).
228
+ *
229
+ * Returns null if the order item doesn't belong to the provided special.
230
+ */
231
+ function deStructureSpecialOrderItem(orderItem, specialItem) {
232
+ if (orderItem.item_id !== specialItem._id)
233
+ return null;
234
+ const orderModifiers = orderItem.modifiers ?? [];
235
+ const modifierSpecials = [];
236
+ for (let i = 0; i < specialItem.modifier_specials.length; i++) {
237
+ const modifierSpecial = specialItem.modifier_specials[i];
238
+ const orderModifier = orderModifiers.find((modifier) => modifier.ref === modifierSpecial._id || modifier._id === modifierSpecial._id);
239
+ const selectedItems = new Array(modifierSpecial.quantity).fill(null);
240
+ if (orderModifier != null) {
241
+ for (let j = 0; j < orderModifier.options.length; j++) {
242
+ const option = orderModifier.options[j];
243
+ const slotIndex = selectedItems.findIndex((item) => item === null);
244
+ if (slotIndex === -1)
245
+ break;
246
+ selectedItems[slotIndex] = {
247
+ _id: option._id,
248
+ item_id: option.ref,
249
+ menu_id: orderItem.menu_id ?? null,
250
+ item_type: constants_1.ORDER_ITEM_TYPE_ENUM.SPECIAL,
251
+ name: option.name,
252
+ price: option.price,
253
+ subtotal: option.price,
254
+ tax_rate: 0,
255
+ quantity: option.quantity,
256
+ special_instructions: '',
257
+ item_discount_details: null,
258
+ modifiers: option.modifiers ?? null,
259
+ // These values will be auto calculated
260
+ _discount_amount: 0,
261
+ _gross_amount: 0,
262
+ _gst_amount: 0,
263
+ _net_amount: 0,
264
+ };
265
+ }
266
+ }
267
+ modifierSpecials.push({ _id: modifierSpecial._id, selectedItems });
268
+ }
269
+ return { modifierSpecials, quantity: orderItem.quantity };
270
+ }
271
+ // ====================================================================================================
220
272
  /**
221
273
  * Converts an ISpecial into an IItem so it can flow through the standard
222
274
  * catalog → drawer → cart pipeline just like a regular catalog item.
@@ -322,7 +374,7 @@ function convertSpecialToItem(special, itemsMap, platform, tenant_id) {
322
374
  _id: special._id,
323
375
  brand_id: special.brand_id,
324
376
  tenants: special.tenants,
325
- category_id: special.category_id ?? constants_1.SPECIALS_CATEGORY_ID,
377
+ category_id: special.category_id,
326
378
  included_platforms: special.included_platforms,
327
379
  name: special.name,
328
380
  hide_name: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@managesome/eposmatic-toolkit",
3
- "version": "0.2.654",
3
+ "version": "0.2.656",
4
4
  "description": "A Toolkit Library for Eposmatic",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",