@managesome/eposmatic-toolkit 0.2.763 → 0.2.765
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.
|
@@ -175,10 +175,10 @@ export declare enum WAREHOUSE_INTERNAL_MOVEMENT_FLOW_ENUM {
|
|
|
175
175
|
EX_WH_TO_WH = "EX_WH_TO_WH",
|
|
176
176
|
BRANCH_TO_EX_WH = "BRANCH_TO_EX_WH",
|
|
177
177
|
EX_WH_TO_BRANCH = "EX_WH_TO_BRANCH",
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
178
|
+
WH_TO_EX_TENANT = "WH_TO_EX_TENANT",
|
|
179
|
+
EX_TENANT_TO_WH = "EX_TENANT_TO_WH",
|
|
180
|
+
BRANCH_TO_EX_TENANT = "BRANCH_TO_EX_TENANT",
|
|
181
|
+
EX_TENANT_TO_BRANCH = "EX_TENANT_TO_BRANCH"
|
|
182
182
|
}
|
|
183
183
|
export declare const ALL_WAREHOUSE_INTERNAL_MOVEMENT_FLOW_NAMES: WAREHOUSE_INTERNAL_MOVEMENT_FLOW_ENUM[];
|
|
184
184
|
export declare enum WAREHOUSE_INTERNAL_MOVEMENT_LOCATION_TYPE_ENUM {
|
|
@@ -186,7 +186,7 @@ export declare enum WAREHOUSE_INTERNAL_MOVEMENT_LOCATION_TYPE_ENUM {
|
|
|
186
186
|
BRANCH = "BRANCH",
|
|
187
187
|
DEPARTMENT = "DEPARTMENT",
|
|
188
188
|
EXTERNAL_WAREHOUSE = "EXTERNAL_WAREHOUSE",
|
|
189
|
-
|
|
189
|
+
EXTERNAL_TENANT = "EXTERNAL_TENANT"
|
|
190
190
|
}
|
|
191
191
|
export declare const ALL_WAREHOUSE_INTERNAL_MOVEMENT_LOCATION_TYPE_NAMES: WAREHOUSE_INTERNAL_MOVEMENT_LOCATION_TYPE_ENUM[];
|
|
192
192
|
export declare enum WAREHOUSE_INTERNAL_MOVEMENT_DIRECTION_ENUM {
|
|
@@ -293,7 +293,7 @@ export declare const ALL_WAREHOUSE_SUPPORT_SPECIALIST_PERMISSION_NAMES: WAREHOUS
|
|
|
293
293
|
export declare enum WAREHOUSE_CLIENT_TYPE_ENUM {
|
|
294
294
|
EXTERNAL = "EXTERNAL",
|
|
295
295
|
EXTERNAL_WAREHOUSE = "EXTERNAL_WAREHOUSE",
|
|
296
|
-
|
|
296
|
+
EXTERNAL_TENANT = "EXTERNAL_TENANT",
|
|
297
297
|
TENANT = "TENANT",
|
|
298
298
|
WAREHOUSE = "WAREHOUSE"
|
|
299
299
|
}
|
|
@@ -301,7 +301,7 @@ export declare const ALL_WAREHOUSE_CLIENT_TYPE_NAMES: WAREHOUSE_CLIENT_TYPE_ENUM
|
|
|
301
301
|
export declare enum TENANT_CLIENT_TYPE_ENUM {
|
|
302
302
|
EXTERNAL = "EXTERNAL",
|
|
303
303
|
EXTERNAL_WAREHOUSE = "EXTERNAL_WAREHOUSE",
|
|
304
|
-
|
|
304
|
+
EXTERNAL_TENANT = "EXTERNAL_TENANT",
|
|
305
305
|
TENANT = "TENANT",
|
|
306
306
|
WAREHOUSE = "WAREHOUSE"
|
|
307
307
|
}
|
|
@@ -309,7 +309,7 @@ export declare const ALL_TENANT_CLIENT_TYPE_NAMES: TENANT_CLIENT_TYPE_ENUM[];
|
|
|
309
309
|
export declare enum VENDOR_TYPE_ENUM {
|
|
310
310
|
EXTERNAL = "EXTERNAL",
|
|
311
311
|
EXTERNAL_WAREHOUSE = "EXTERNAL_WAREHOUSE",
|
|
312
|
-
|
|
312
|
+
EXTERNAL_TENANT = "EXTERNAL_TENANT",
|
|
313
313
|
TENANT = "TENANT",
|
|
314
314
|
WAREHOUSE = "WAREHOUSE"
|
|
315
315
|
}
|
|
@@ -216,10 +216,10 @@ var WAREHOUSE_INTERNAL_MOVEMENT_FLOW_ENUM;
|
|
|
216
216
|
WAREHOUSE_INTERNAL_MOVEMENT_FLOW_ENUM["EX_WH_TO_WH"] = "EX_WH_TO_WH";
|
|
217
217
|
WAREHOUSE_INTERNAL_MOVEMENT_FLOW_ENUM["BRANCH_TO_EX_WH"] = "BRANCH_TO_EX_WH";
|
|
218
218
|
WAREHOUSE_INTERNAL_MOVEMENT_FLOW_ENUM["EX_WH_TO_BRANCH"] = "EX_WH_TO_BRANCH";
|
|
219
|
-
WAREHOUSE_INTERNAL_MOVEMENT_FLOW_ENUM["
|
|
220
|
-
WAREHOUSE_INTERNAL_MOVEMENT_FLOW_ENUM["
|
|
221
|
-
WAREHOUSE_INTERNAL_MOVEMENT_FLOW_ENUM["
|
|
222
|
-
WAREHOUSE_INTERNAL_MOVEMENT_FLOW_ENUM["
|
|
219
|
+
WAREHOUSE_INTERNAL_MOVEMENT_FLOW_ENUM["WH_TO_EX_TENANT"] = "WH_TO_EX_TENANT";
|
|
220
|
+
WAREHOUSE_INTERNAL_MOVEMENT_FLOW_ENUM["EX_TENANT_TO_WH"] = "EX_TENANT_TO_WH";
|
|
221
|
+
WAREHOUSE_INTERNAL_MOVEMENT_FLOW_ENUM["BRANCH_TO_EX_TENANT"] = "BRANCH_TO_EX_TENANT";
|
|
222
|
+
WAREHOUSE_INTERNAL_MOVEMENT_FLOW_ENUM["EX_TENANT_TO_BRANCH"] = "EX_TENANT_TO_BRANCH";
|
|
223
223
|
})(WAREHOUSE_INTERNAL_MOVEMENT_FLOW_ENUM || (exports.WAREHOUSE_INTERNAL_MOVEMENT_FLOW_ENUM = WAREHOUSE_INTERNAL_MOVEMENT_FLOW_ENUM = {}));
|
|
224
224
|
exports.ALL_WAREHOUSE_INTERNAL_MOVEMENT_FLOW_NAMES = Object.values(WAREHOUSE_INTERNAL_MOVEMENT_FLOW_ENUM);
|
|
225
225
|
var WAREHOUSE_INTERNAL_MOVEMENT_LOCATION_TYPE_ENUM;
|
|
@@ -228,7 +228,7 @@ var WAREHOUSE_INTERNAL_MOVEMENT_LOCATION_TYPE_ENUM;
|
|
|
228
228
|
WAREHOUSE_INTERNAL_MOVEMENT_LOCATION_TYPE_ENUM["BRANCH"] = "BRANCH";
|
|
229
229
|
WAREHOUSE_INTERNAL_MOVEMENT_LOCATION_TYPE_ENUM["DEPARTMENT"] = "DEPARTMENT";
|
|
230
230
|
WAREHOUSE_INTERNAL_MOVEMENT_LOCATION_TYPE_ENUM["EXTERNAL_WAREHOUSE"] = "EXTERNAL_WAREHOUSE";
|
|
231
|
-
WAREHOUSE_INTERNAL_MOVEMENT_LOCATION_TYPE_ENUM["
|
|
231
|
+
WAREHOUSE_INTERNAL_MOVEMENT_LOCATION_TYPE_ENUM["EXTERNAL_TENANT"] = "EXTERNAL_TENANT";
|
|
232
232
|
})(WAREHOUSE_INTERNAL_MOVEMENT_LOCATION_TYPE_ENUM || (exports.WAREHOUSE_INTERNAL_MOVEMENT_LOCATION_TYPE_ENUM = WAREHOUSE_INTERNAL_MOVEMENT_LOCATION_TYPE_ENUM = {}));
|
|
233
233
|
exports.ALL_WAREHOUSE_INTERNAL_MOVEMENT_LOCATION_TYPE_NAMES = Object.values(WAREHOUSE_INTERNAL_MOVEMENT_LOCATION_TYPE_ENUM);
|
|
234
234
|
var WAREHOUSE_INTERNAL_MOVEMENT_DIRECTION_ENUM;
|
|
@@ -397,7 +397,7 @@ var WAREHOUSE_CLIENT_TYPE_ENUM;
|
|
|
397
397
|
(function (WAREHOUSE_CLIENT_TYPE_ENUM) {
|
|
398
398
|
WAREHOUSE_CLIENT_TYPE_ENUM["EXTERNAL"] = "EXTERNAL";
|
|
399
399
|
WAREHOUSE_CLIENT_TYPE_ENUM["EXTERNAL_WAREHOUSE"] = "EXTERNAL_WAREHOUSE";
|
|
400
|
-
WAREHOUSE_CLIENT_TYPE_ENUM["
|
|
400
|
+
WAREHOUSE_CLIENT_TYPE_ENUM["EXTERNAL_TENANT"] = "EXTERNAL_TENANT";
|
|
401
401
|
WAREHOUSE_CLIENT_TYPE_ENUM["TENANT"] = "TENANT";
|
|
402
402
|
WAREHOUSE_CLIENT_TYPE_ENUM["WAREHOUSE"] = "WAREHOUSE";
|
|
403
403
|
})(WAREHOUSE_CLIENT_TYPE_ENUM || (exports.WAREHOUSE_CLIENT_TYPE_ENUM = WAREHOUSE_CLIENT_TYPE_ENUM = {}));
|
|
@@ -407,7 +407,7 @@ var TENANT_CLIENT_TYPE_ENUM;
|
|
|
407
407
|
(function (TENANT_CLIENT_TYPE_ENUM) {
|
|
408
408
|
TENANT_CLIENT_TYPE_ENUM["EXTERNAL"] = "EXTERNAL";
|
|
409
409
|
TENANT_CLIENT_TYPE_ENUM["EXTERNAL_WAREHOUSE"] = "EXTERNAL_WAREHOUSE";
|
|
410
|
-
TENANT_CLIENT_TYPE_ENUM["
|
|
410
|
+
TENANT_CLIENT_TYPE_ENUM["EXTERNAL_TENANT"] = "EXTERNAL_TENANT";
|
|
411
411
|
TENANT_CLIENT_TYPE_ENUM["TENANT"] = "TENANT";
|
|
412
412
|
TENANT_CLIENT_TYPE_ENUM["WAREHOUSE"] = "WAREHOUSE";
|
|
413
413
|
})(TENANT_CLIENT_TYPE_ENUM || (exports.TENANT_CLIENT_TYPE_ENUM = TENANT_CLIENT_TYPE_ENUM = {}));
|
|
@@ -417,7 +417,7 @@ var VENDOR_TYPE_ENUM;
|
|
|
417
417
|
(function (VENDOR_TYPE_ENUM) {
|
|
418
418
|
VENDOR_TYPE_ENUM["EXTERNAL"] = "EXTERNAL";
|
|
419
419
|
VENDOR_TYPE_ENUM["EXTERNAL_WAREHOUSE"] = "EXTERNAL_WAREHOUSE";
|
|
420
|
-
VENDOR_TYPE_ENUM["
|
|
420
|
+
VENDOR_TYPE_ENUM["EXTERNAL_TENANT"] = "EXTERNAL_TENANT";
|
|
421
421
|
VENDOR_TYPE_ENUM["TENANT"] = "TENANT";
|
|
422
422
|
VENDOR_TYPE_ENUM["WAREHOUSE"] = "WAREHOUSE";
|
|
423
423
|
})(VENDOR_TYPE_ENUM || (exports.VENDOR_TYPE_ENUM = VENDOR_TYPE_ENUM = {}));
|
|
@@ -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
|
+
});
|