@managesome/eposmatic-toolkit 0.2.690 → 0.2.692

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)
@@ -94,7 +94,6 @@ export interface ISettingsForWeb {
94
94
  digital_menu_images: ITenant['digital_menu_images'];
95
95
  web_slider_images: ITenant['web_slider_images'];
96
96
  enabled_rating_types: ITenant['enabled_rating_types'];
97
- specials_name: ITenant['specials_name'];
98
97
  web_unpaid_payment_types: WEB_UNPAID_PAYMENT_TYPE_ENUM[];
99
98
  max_preorder_delivery_minutes: ITenant['max_preorder_delivery_minutes'];
100
99
  max_preorder_takeaway_minutes: ITenant['max_preorder_takeaway_minutes'];
@@ -192,7 +191,6 @@ export interface ISettingsForPOS {
192
191
  closed_store_message: ITenant['closed_store_message'];
193
192
  break_time_message: ITenant['break_time_message'];
194
193
  public_business_name: ITenant['public_business_name'];
195
- specials_name: ITenant['specials_name'];
196
194
  order_completion_type: ITenant['order_completion_type'];
197
195
  default_prep_minutes: ITenant['default_prep_minutes'];
198
196
  enabled_review_platforms: ITenant['enabled_review_platforms'];
@@ -211,7 +211,6 @@ function getSettingsForWeb(settings) {
211
211
  digital_menu_images: settings.digital_menu_images,
212
212
  web_slider_images: settings.web_slider_images,
213
213
  enabled_rating_types: settings.enabled_rating_types,
214
- specials_name: settings.specials_name,
215
214
  web_unpaid_payment_types: settings.web_unpaid_payment_types,
216
215
  max_preorder_delivery_minutes: settings.max_preorder_delivery_minutes,
217
216
  max_preorder_takeaway_minutes: settings.max_preorder_takeaway_minutes,
@@ -309,7 +308,6 @@ function getSettingsForPOS(settings) {
309
308
  closed_store_message: settings.closed_store_message,
310
309
  break_time_message: settings.break_time_message,
311
310
  public_business_name: settings.public_business_name,
312
- specials_name: settings.specials_name,
313
311
  order_completion_type: settings.order_completion_type,
314
312
  default_prep_minutes: settings.default_prep_minutes,
315
313
  enabled_review_platforms: settings.enabled_review_platforms,
@@ -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;
@@ -182,7 +182,6 @@ export declare const TenantSchema: Schema<any, import("mongoose").Model<any, any
182
182
  subscription_expiry?: NativeDate | null | undefined;
183
183
  digital_menu_images?: string[] | null | undefined;
184
184
  web_slider_images?: string[] | null | undefined;
185
- specials_name?: string | null | undefined;
186
185
  menu_source?: string | null | undefined;
187
186
  app_version?: string | null | undefined;
188
187
  force_isolated_printing?: boolean | null | undefined;
@@ -364,7 +363,6 @@ export declare const TenantSchema: Schema<any, import("mongoose").Model<any, any
364
363
  subscription_expiry?: NativeDate | null | undefined;
365
364
  digital_menu_images?: string[] | null | undefined;
366
365
  web_slider_images?: string[] | null | undefined;
367
- specials_name?: string | null | undefined;
368
366
  menu_source?: string | null | undefined;
369
367
  app_version?: string | null | undefined;
370
368
  force_isolated_printing?: boolean | null | undefined;
@@ -546,7 +544,6 @@ export declare const TenantSchema: Schema<any, import("mongoose").Model<any, any
546
544
  subscription_expiry?: NativeDate | null | undefined;
547
545
  digital_menu_images?: string[] | null | undefined;
548
546
  web_slider_images?: string[] | null | undefined;
549
- specials_name?: string | null | undefined;
550
547
  menu_source?: string | null | undefined;
551
548
  app_version?: string | null | undefined;
552
549
  force_isolated_printing?: boolean | null | undefined;
@@ -735,10 +735,6 @@ exports.TenantSchema = new mongoose_1.Schema({
735
735
  type: [RatingTypeSchema],
736
736
  default: [],
737
737
  },
738
- specials_name: {
739
- type: String,
740
- required: false,
741
- },
742
738
  order_completion_type: {
743
739
  type: String,
744
740
  enum: constants_1.ALL_ORDER_COMPLETION_TYPES,
@@ -168,7 +168,6 @@ export interface ITenant {
168
168
  digital_menu_images?: string[] | null;
169
169
  web_slider_images?: string[] | null;
170
170
  enabled_rating_types: RATING_TYPE_ENUM[];
171
- specials_name?: string | null;
172
171
  order_completion_type: ORDER_COMPLETION_TYPE_ENUM;
173
172
  fb_link?: string | null;
174
173
  instagram_link?: string | null;
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.692",
4
4
  "description": "A Toolkit Library for Eposmatic",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",