@managesome/eposmatic-toolkit 0.2.763 → 0.2.764
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.
|
@@ -78,9 +78,15 @@ export declare function deStructureSpecialOrderItem(orderItem: IOrderItem, speci
|
|
|
78
78
|
* included_platforms) and no special-hours / platform-based price
|
|
79
79
|
* resolution happens here. Setup fields are copied through as-is:
|
|
80
80
|
* - `item_special_hours` is preserved on the output item,
|
|
81
|
-
* -
|
|
82
|
-
*
|
|
83
|
-
*
|
|
81
|
+
* - ITEM options are platform-open (`excluded_platforms: []`): constituent
|
|
82
|
+
* items are shown even when they don't belong to the current platform (the
|
|
83
|
+
* special's own `included_platforms` is the platform gate — same rule as
|
|
84
|
+
* `convertSpecialsToWorkableSpecials`; the classic drawer engine and the
|
|
85
|
+
* `hasAllModifierOptionsAvailable` gates must not filter them),
|
|
86
|
+
* - HALF-HALF options keep the derived (complement) `excluded_platforms` from
|
|
87
|
+
* the converted half-half item, so the half-half setup's own platform gate
|
|
88
|
+
* still applies (the classic counterpart of the platform-filtered
|
|
89
|
+
* `visibleHalfHalfItems` in the modern flow).
|
|
84
90
|
*
|
|
85
91
|
* Availability-aware consumers compose this with `isSetupApplicable(...)`
|
|
86
92
|
* (and `convertItemToWorkableItem(...)` / `getPlatformModifiers(...)` for
|
|
@@ -432,9 +432,15 @@ function deStructureSpecialOrderItem(orderItem, specialItem) {
|
|
|
432
432
|
* included_platforms) and no special-hours / platform-based price
|
|
433
433
|
* resolution happens here. Setup fields are copied through as-is:
|
|
434
434
|
* - `item_special_hours` is preserved on the output item,
|
|
435
|
-
* -
|
|
436
|
-
*
|
|
437
|
-
*
|
|
435
|
+
* - ITEM options are platform-open (`excluded_platforms: []`): constituent
|
|
436
|
+
* items are shown even when they don't belong to the current platform (the
|
|
437
|
+
* special's own `included_platforms` is the platform gate — same rule as
|
|
438
|
+
* `convertSpecialsToWorkableSpecials`; the classic drawer engine and the
|
|
439
|
+
* `hasAllModifierOptionsAvailable` gates must not filter them),
|
|
440
|
+
* - HALF-HALF options keep the derived (complement) `excluded_platforms` from
|
|
441
|
+
* the converted half-half item, so the half-half setup's own platform gate
|
|
442
|
+
* still applies (the classic counterpart of the platform-filtered
|
|
443
|
+
* `visibleHalfHalfItems` in the modern flow).
|
|
438
444
|
*
|
|
439
445
|
* Availability-aware consumers compose this with `isSetupApplicable(...)`
|
|
440
446
|
* (and `convertItemToWorkableItem(...)` / `getPlatformModifiers(...)` for
|
|
@@ -552,9 +558,15 @@ function convertSpecialToItem(special, itemsMap, halfhalfSetups) {
|
|
|
552
558
|
// Only on a nested half-half: the setup flag so the engine normalizes
|
|
553
559
|
// the option's own segment groups at selection time.
|
|
554
560
|
...(isHalfHalfOption && halfHalfChooseExpensive ? { choose_expensive_segment_price: true } : {}),
|
|
555
|
-
//
|
|
556
|
-
//
|
|
557
|
-
|
|
561
|
+
// Constituent items are NOT platform-gated inside a special (same
|
|
562
|
+
// rule as the menu/list conversion): regular item options are
|
|
563
|
+
// platform-open so the drawer engine (`getPlatformModifiers`) and the
|
|
564
|
+
// availability gates (`hasAllModifierOptionsAvailable`) keep them.
|
|
565
|
+
// Half-half options keep the derived complement — the half-half
|
|
566
|
+
// setup's own platform gate still applies.
|
|
567
|
+
excluded_platforms: isHalfHalfOption
|
|
568
|
+
? (0, platform_catalog_1.getExcludedPlatformsFromIncludedPlatforms)(catalogItem.included_platforms)
|
|
569
|
+
: [],
|
|
558
570
|
// Carry the source item's special hours so the filter layer can apply
|
|
559
571
|
// schedule AVAILABILITY (pure mapping, no resolution here). Item
|
|
560
572
|
// schedule-level PRICING/DISCOUNTS are ignored inside a special: they
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const constants_1 = require("../constants");
|
|
4
|
+
const platform_catalog_1 = require("../helpers/utils/platform-catalog");
|
|
4
5
|
const specials_helpers_1 = require("../helpers/utils/specials-helpers");
|
|
5
6
|
// ============================================================================
|
|
6
7
|
// Specials: platform membership of CONSTITUENT items.
|
|
@@ -108,6 +109,37 @@ function makeSpecialWithModifier(overrides = {}) {
|
|
|
108
109
|
...overrides,
|
|
109
110
|
};
|
|
110
111
|
}
|
|
112
|
+
function makeHalfHalfSetup(overrides = {}) {
|
|
113
|
+
return {
|
|
114
|
+
_id: 'halfhalf-1',
|
|
115
|
+
brand_id: 'brand-1',
|
|
116
|
+
tenants: [TENANT_ID],
|
|
117
|
+
category_id: 'pizza-cat',
|
|
118
|
+
included_platforms: [PLATFORM],
|
|
119
|
+
name: 'Half/Half Pizza Large',
|
|
120
|
+
description: 'Two halves',
|
|
121
|
+
active: true,
|
|
122
|
+
sold_out: [],
|
|
123
|
+
image_url: 'https://example.com/halfhalf.jpg',
|
|
124
|
+
upsell_price: null,
|
|
125
|
+
discount_amount: null,
|
|
126
|
+
is_discount_percentage: false,
|
|
127
|
+
sort_id: 1,
|
|
128
|
+
choose_expensive_segment_price: true,
|
|
129
|
+
segments: [
|
|
130
|
+
{ _id: 'seg-1', name: 'First Pizza', sort_id: 1 },
|
|
131
|
+
{ _id: 'seg-2', name: 'Second Pizza', sort_id: 2 },
|
|
132
|
+
],
|
|
133
|
+
// Ignored inside a special: the segment options ARE the group's own items.
|
|
134
|
+
items: [],
|
|
135
|
+
exclusive_refs: [],
|
|
136
|
+
excluded_refs: [],
|
|
137
|
+
item_special_hours: null,
|
|
138
|
+
createdAt: new Date('2024-01-01'),
|
|
139
|
+
updatedAt: new Date('2024-01-02'),
|
|
140
|
+
...overrides,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
111
143
|
describe('specials: constituent items are not gated by platform membership', () => {
|
|
112
144
|
it('shows the special when every item of the group is outside the platform', () => {
|
|
113
145
|
const itemsMap = {
|
|
@@ -238,3 +270,71 @@ describe('specials: tenant and schedule checks on items are unchanged', () => {
|
|
|
238
270
|
expect(workable.modifier_specials[0].items).toHaveLength(0);
|
|
239
271
|
});
|
|
240
272
|
});
|
|
273
|
+
describe('convertSpecialToItem: classic preview option platform flags', () => {
|
|
274
|
+
it('marks regular item options platform-open so the classic gates keep them', () => {
|
|
275
|
+
const itemsMap = {
|
|
276
|
+
milan: makeItem('milan'),
|
|
277
|
+
torent: makeItem('torent', { included_platforms: [OTHER_PLATFORM] }),
|
|
278
|
+
};
|
|
279
|
+
const special = makeSpecialWithModifier({
|
|
280
|
+
modifier_specials: [
|
|
281
|
+
makeModifierSpecial({
|
|
282
|
+
items: [
|
|
283
|
+
{ item_id: 'milan', sort_id: 1, upsell_price: null },
|
|
284
|
+
{ item_id: 'torent', sort_id: 2, upsell_price: null },
|
|
285
|
+
],
|
|
286
|
+
}),
|
|
287
|
+
],
|
|
288
|
+
});
|
|
289
|
+
const converted = (0, specials_helpers_1.convertSpecialToItem)(special, itemsMap, {});
|
|
290
|
+
expect(converted).not.toBeNull();
|
|
291
|
+
if (converted == null)
|
|
292
|
+
return;
|
|
293
|
+
// Both options are available on every platform — the classic drawer
|
|
294
|
+
// engine and the availability gates must keep them.
|
|
295
|
+
expect(converted.modifiers?.[0].options.map((option) => option.excluded_platforms)).toEqual([[], []]);
|
|
296
|
+
expect((0, platform_catalog_1.hasAllModifierOptionsAvailable)(converted, PLATFORM)).toBe(true);
|
|
297
|
+
});
|
|
298
|
+
it('keeps the derived platform complement on half-half options', () => {
|
|
299
|
+
const itemsMap = { milan: makeItem('milan') };
|
|
300
|
+
const halfhalfSetups = {
|
|
301
|
+
'halfhalf-1': makeHalfHalfSetup({ included_platforms: [OTHER_PLATFORM] }),
|
|
302
|
+
};
|
|
303
|
+
const special = makeSpecialWithModifier({
|
|
304
|
+
modifier_specials: [
|
|
305
|
+
makeModifierSpecial({
|
|
306
|
+
items: [
|
|
307
|
+
{ item_id: 'milan', sort_id: 1, upsell_price: null },
|
|
308
|
+
{ item_id: 'halfhalf-1', sort_id: 2, upsell_price: null },
|
|
309
|
+
],
|
|
310
|
+
}),
|
|
311
|
+
],
|
|
312
|
+
});
|
|
313
|
+
const converted = (0, specials_helpers_1.convertSpecialToItem)(special, itemsMap, halfhalfSetups);
|
|
314
|
+
expect(converted).not.toBeNull();
|
|
315
|
+
if (converted == null)
|
|
316
|
+
return;
|
|
317
|
+
const options = converted.modifiers?.[0].options ?? [];
|
|
318
|
+
// The half-half setup is not on the current platform -> its option keeps
|
|
319
|
+
// the setup's own platform gate ...
|
|
320
|
+
const halfHalfOption = options.find((option) => option._id === 'halfhalf-1');
|
|
321
|
+
expect(halfHalfOption).toBeDefined();
|
|
322
|
+
expect(halfHalfOption?.excluded_platforms).toContain(PLATFORM);
|
|
323
|
+
expect(halfHalfOption?.excluded_platforms).not.toContain(OTHER_PLATFORM);
|
|
324
|
+
// ... while regular items stay platform-open.
|
|
325
|
+
const itemOption = options.find((option) => option._id === 'milan');
|
|
326
|
+
expect(itemOption?.excluded_platforms).toEqual([]);
|
|
327
|
+
});
|
|
328
|
+
it('keeps the classic gate blocking when every item of a group is inactive', () => {
|
|
329
|
+
const itemsMap = {
|
|
330
|
+
milan: makeItem('milan', { active: false }),
|
|
331
|
+
};
|
|
332
|
+
const converted = (0, specials_helpers_1.convertSpecialToItem)(makeSpecialWithModifier(), itemsMap, {});
|
|
333
|
+
// The conversion itself is pure (no availability filtering) ...
|
|
334
|
+
expect(converted).not.toBeNull();
|
|
335
|
+
if (converted == null)
|
|
336
|
+
return;
|
|
337
|
+
// ... while the classic-preview gate still blocks the all-inactive group.
|
|
338
|
+
expect((0, platform_catalog_1.hasAllModifierOptionsAvailable)(converted, PLATFORM)).toBe(false);
|
|
339
|
+
});
|
|
340
|
+
});
|