@managesome/eposmatic-toolkit 0.2.690 → 0.2.691

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.
@@ -17,6 +17,7 @@ const constants_1 = require("../../constants");
17
17
  const store_1 = require("../store");
18
18
  const order_engine_1 = require("./order-engine");
19
19
  const platform_catalog_1 = require("./platform-catalog");
20
+ const specials_helpers_1 = require("./specials-helpers");
20
21
  const platform_num_1 = require("./platform-num");
21
22
  const selection_model_1 = require("./selection-model");
22
23
  function getHalfHalfPostedData(data, payload) {
@@ -100,8 +101,11 @@ function convertHalfHalfSetupToWorkableHalfHalfSetup(halfhalfSetups, itemsMap, p
100
101
  discount_amount = applicableSchedule.discount_amount;
101
102
  is_discount_percentage = applicableSchedule.is_discount_percentage;
102
103
  }
103
- const halfhalfItems = [...halfhalfSetup.items];
104
- halfhalfItems.sort((a, b) => a.sort_id - b.sort_id);
104
+ const halfhalfItems = [...halfhalfSetup.items]
105
+ // Respect excluded_refs: items whose item_id (ref) is listed are removed
106
+ // from the selectable list (same semantics as specials' excluded_refs).
107
+ .filter((setupItem) => !halfhalfSetup.excluded_refs.includes(setupItem.item_id))
108
+ .sort((a, b) => a.sort_id - b.sort_id);
105
109
  // Workable segment entries: base price first, own upsells applied after
106
110
  // the optional expensive-segment normalization.
107
111
  const entries = [];
@@ -116,6 +120,9 @@ function convertHalfHalfSetupToWorkableHalfHalfSetup(halfhalfSetups, itemsMap, p
116
120
  if (discount_amount != null) {
117
121
  workableItem.discount_amount = null;
118
122
  }
123
+ // Apply the half-half reference rules to the item's own modifiers:
124
+ // excluded_refs removes modifiers/options, exclusive_refs removes their price.
125
+ workableItem.modifiers = (0, specials_helpers_1.applyModifierSpecialRefRules)(workableItem.modifiers, halfhalfSetup.exclusive_refs, halfhalfSetup.excluded_refs);
119
126
  entries.push({ workableItem, itemUpsell: item.upsell_price });
120
127
  }
121
128
  // choose_expensive_segment_price: copy the most expensive segment's BASE
@@ -144,6 +151,10 @@ function convertHalfHalfSetupToWorkableHalfHalfSetup(halfhalfSetups, itemsMap, p
144
151
  if (itemUpsell != null) {
145
152
  workableItem.price = (0, platform_num_1.mergePriceObjs)(workableItem.price, itemUpsell);
146
153
  }
154
+ // exclusive_refs: this item is a segment option - make it free (price 0).
155
+ if (halfhalfSetup.exclusive_refs.includes(workableItem._id)) {
156
+ workableItem.price = null;
157
+ }
147
158
  items.push(workableItem);
148
159
  }
149
160
  if (items.length === 0)
@@ -203,7 +214,11 @@ function convertHalfHalfToItem(halfhalfSetup, itemsMap, platform, tenant_id) {
203
214
  }
204
215
  }
205
216
  // ── Build shared option list (segment-neutral ids) ─────────────
206
- const halfHalfItems = [...halfhalfSetup.items].sort((a, b) => a.sort_id - b.sort_id);
217
+ const halfHalfItems = [...halfhalfSetup.items]
218
+ // Respect excluded_refs: items whose item_id (ref) is listed are removed
219
+ // from the selectable list (same semantics as specials' excluded_refs).
220
+ .filter((setupItem) => !halfhalfSetup.excluded_refs.includes(setupItem.item_id))
221
+ .sort((a, b) => a.sort_id - b.sort_id);
207
222
  // Aggregate the union of keywords/caveats/dietary_preferences across all
208
223
  // constituent items so the half-half shows them too.
209
224
  const allKeywords = [];
@@ -252,6 +267,10 @@ function convertHalfHalfToItem(halfhalfSetup, itemsMap, platform, tenant_id) {
252
267
  if (itemUpsell != null) {
253
268
  optionPrice = (0, platform_num_1.mergePriceObjs)(optionPrice, itemUpsell);
254
269
  }
270
+ // exclusive_refs: this option becomes free (price 0).
271
+ if (halfhalfSetup.exclusive_refs.includes(catalogItem._id)) {
272
+ optionPrice = null;
273
+ }
255
274
  baseOptions.push({
256
275
  // `_id` is the real item `_id` (like a catalog option id); each segment
257
276
  // creates its own occurrence below. `ref` points to the same item.
@@ -263,7 +282,7 @@ function convertHalfHalfToItem(halfhalfSetup, itemsMap, platform, tenant_id) {
263
282
  sort_id: sortId,
264
283
  excluded_platforms: [],
265
284
  price: optionPrice,
266
- modifiers: workableItem.modifiers,
285
+ modifiers: (0, specials_helpers_1.applyModifierSpecialRefRules)(workableItem.modifiers, halfhalfSetup.exclusive_refs, halfhalfSetup.excluded_refs),
267
286
  });
268
287
  }
269
288
  if (baseOptions.length === 0)
@@ -509,19 +509,6 @@ export declare const HalfHalfSetupSchema: Schema<any, import("mongoose").Model<a
509
509
  }>;
510
510
  excluded_refs: string[];
511
511
  exclusive_refs: string[];
512
- segments: import("mongoose").Types.DocumentArray<{
513
- _id: import("mongoose").Types.ObjectId;
514
- name: string;
515
- sort_id: number;
516
- }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
517
- _id: import("mongoose").Types.ObjectId;
518
- name: string;
519
- sort_id: number;
520
- }> & {
521
- _id: import("mongoose").Types.ObjectId;
522
- name: string;
523
- sort_id: number;
524
- }>;
525
512
  upsell_price: {
526
513
  "POS_WALK-IN": number;
527
514
  "POS_TAKE-AWAY": number;
@@ -565,6 +552,19 @@ export declare const HalfHalfSetupSchema: Schema<any, import("mongoose").Model<a
565
552
  KEETA_DELIVERY: number;
566
553
  BASE_PRICE: number;
567
554
  };
555
+ segments: import("mongoose").Types.DocumentArray<{
556
+ _id: import("mongoose").Types.ObjectId;
557
+ name: string;
558
+ sort_id: number;
559
+ }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
560
+ _id: import("mongoose").Types.ObjectId;
561
+ name: string;
562
+ sort_id: number;
563
+ }> & {
564
+ _id: import("mongoose").Types.ObjectId;
565
+ name: string;
566
+ sort_id: number;
567
+ }>;
568
568
  choose_expensive_segment_price: boolean;
569
569
  }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
570
570
  createdAt: NativeDate;
@@ -1053,19 +1053,6 @@ export declare const HalfHalfSetupSchema: Schema<any, import("mongoose").Model<a
1053
1053
  }>;
1054
1054
  excluded_refs: string[];
1055
1055
  exclusive_refs: string[];
1056
- segments: import("mongoose").Types.DocumentArray<{
1057
- _id: import("mongoose").Types.ObjectId;
1058
- name: string;
1059
- sort_id: number;
1060
- }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
1061
- _id: import("mongoose").Types.ObjectId;
1062
- name: string;
1063
- sort_id: number;
1064
- }> & {
1065
- _id: import("mongoose").Types.ObjectId;
1066
- name: string;
1067
- sort_id: number;
1068
- }>;
1069
1056
  upsell_price: {
1070
1057
  "POS_WALK-IN": number;
1071
1058
  "POS_TAKE-AWAY": number;
@@ -1109,6 +1096,19 @@ export declare const HalfHalfSetupSchema: Schema<any, import("mongoose").Model<a
1109
1096
  KEETA_DELIVERY: number;
1110
1097
  BASE_PRICE: number;
1111
1098
  };
1099
+ segments: import("mongoose").Types.DocumentArray<{
1100
+ _id: import("mongoose").Types.ObjectId;
1101
+ name: string;
1102
+ sort_id: number;
1103
+ }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
1104
+ _id: import("mongoose").Types.ObjectId;
1105
+ name: string;
1106
+ sort_id: number;
1107
+ }> & {
1108
+ _id: import("mongoose").Types.ObjectId;
1109
+ name: string;
1110
+ sort_id: number;
1111
+ }>;
1112
1112
  choose_expensive_segment_price: boolean;
1113
1113
  }>> & import("mongoose").FlatRecord<{
1114
1114
  createdAt: NativeDate;
@@ -1597,19 +1597,6 @@ export declare const HalfHalfSetupSchema: Schema<any, import("mongoose").Model<a
1597
1597
  }>;
1598
1598
  excluded_refs: string[];
1599
1599
  exclusive_refs: string[];
1600
- segments: import("mongoose").Types.DocumentArray<{
1601
- _id: import("mongoose").Types.ObjectId;
1602
- name: string;
1603
- sort_id: number;
1604
- }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
1605
- _id: import("mongoose").Types.ObjectId;
1606
- name: string;
1607
- sort_id: number;
1608
- }> & {
1609
- _id: import("mongoose").Types.ObjectId;
1610
- name: string;
1611
- sort_id: number;
1612
- }>;
1613
1600
  upsell_price: {
1614
1601
  "POS_WALK-IN": number;
1615
1602
  "POS_TAKE-AWAY": number;
@@ -1653,6 +1640,19 @@ export declare const HalfHalfSetupSchema: Schema<any, import("mongoose").Model<a
1653
1640
  KEETA_DELIVERY: number;
1654
1641
  BASE_PRICE: number;
1655
1642
  };
1643
+ segments: import("mongoose").Types.DocumentArray<{
1644
+ _id: import("mongoose").Types.ObjectId;
1645
+ name: string;
1646
+ sort_id: number;
1647
+ }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
1648
+ _id: import("mongoose").Types.ObjectId;
1649
+ name: string;
1650
+ sort_id: number;
1651
+ }> & {
1652
+ _id: import("mongoose").Types.ObjectId;
1653
+ name: string;
1654
+ sort_id: number;
1655
+ }>;
1656
1656
  choose_expensive_segment_price: boolean;
1657
1657
  }> & Required<{
1658
1658
  _id: import("mongoose").Types.ObjectId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@managesome/eposmatic-toolkit",
3
- "version": "0.2.690",
3
+ "version": "0.2.691",
4
4
  "description": "A Toolkit Library for Eposmatic",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",