@managesome/eposmatic-toolkit 0.2.744 → 0.2.746
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.
- package/lib/helpers/utils/halfhalf-setup-helpers.js +9 -7
- package/lib/schemas/models/halfhalf_setup.d.ts +3 -0
- package/lib/schemas/models/halfhalf_setup.js +4 -0
- package/lib/schemas/types/halfhalf_setup.d.ts +1 -0
- package/lib/tests/choose-expensive-edge-cases.test.js +3 -0
- package/lib/tests/choose-expensive-flow-verification.test.js +1 -0
- package/lib/tests/simplified-halfhalf.test.js +1 -0
- package/lib/tests/specials-halfhalf-options.test.js +1 -0
- package/lib/tests/specials-halfhalf-pricing.test.js +1 -0
- package/package.json +1 -1
|
@@ -25,7 +25,7 @@ const specials_helpers_1 = require("./specials-helpers");
|
|
|
25
25
|
function getHalfHalfPostedData(data, payload) {
|
|
26
26
|
return data.some((half) => half._id === payload._id)
|
|
27
27
|
? data
|
|
28
|
-
: data.concat(getHalfhalfSetupWithPrice(payload)).sort(
|
|
28
|
+
: data.concat(getHalfhalfSetupWithPrice(payload)).sort((a, b) => (a.sort_id ?? 0) - (b.sort_id ?? 0));
|
|
29
29
|
}
|
|
30
30
|
function renderBulkHalfHalfUpdate(data, payload) {
|
|
31
31
|
return data
|
|
@@ -35,7 +35,7 @@ function renderBulkHalfHalfUpdate(data, payload) {
|
|
|
35
35
|
? { ...halfHalf, ...(updatedHalfHalf != null ? getHalfhalfSetupWithPrice(updatedHalfHalf) : {}) }
|
|
36
36
|
: halfHalf;
|
|
37
37
|
})
|
|
38
|
-
.sort(
|
|
38
|
+
.sort((a, b) => (a.sort_id ?? 0) - (b.sort_id ?? 0));
|
|
39
39
|
}
|
|
40
40
|
function getHalfHalfUpdatedData(data, payload) {
|
|
41
41
|
return data
|
|
@@ -45,10 +45,10 @@ function getHalfHalfUpdatedData(data, payload) {
|
|
|
45
45
|
...getHalfhalfSetupWithPrice(payload),
|
|
46
46
|
}
|
|
47
47
|
: halfHalf)
|
|
48
|
-
.sort(
|
|
48
|
+
.sort((a, b) => (a.sort_id ?? 0) - (b.sort_id ?? 0));
|
|
49
49
|
}
|
|
50
50
|
function getHalfHalfDeletedData(data, payload) {
|
|
51
|
-
return data.filter((halfHalf) => halfHalf._id !== payload).sort(
|
|
51
|
+
return data.filter((halfHalf) => halfHalf._id !== payload).sort((a, b) => (a.sort_id ?? 0) - (b.sort_id ?? 0));
|
|
52
52
|
}
|
|
53
53
|
// ====================================================================================================
|
|
54
54
|
function getHalfhalfSetupWithPrice(halfhalfSetup, writeable) {
|
|
@@ -144,9 +144,11 @@ function convertHalfHalfSetupToWorkableHalfHalfSetup(halfhalfSetups, itemsMap, p
|
|
|
144
144
|
if (!platform || !tenant_id)
|
|
145
145
|
return [];
|
|
146
146
|
const isSimple = typeof itemsMap[Object.keys(itemsMap)[0]]?.sold_out === 'boolean';
|
|
147
|
+
// Order the menu by the setup's sort_id (same as specials).
|
|
148
|
+
const sortedHalfhalfSetups = [...halfhalfSetups].sort((a, b) => (a.sort_id ?? 0) - (b.sort_id ?? 0));
|
|
147
149
|
const halfhalfMenu = [];
|
|
148
|
-
for (let i = 0; i <
|
|
149
|
-
const halfhalfSetup =
|
|
150
|
+
for (let i = 0; i < sortedHalfhalfSetups.length; i++) {
|
|
151
|
+
const halfhalfSetup = sortedHalfhalfSetups[i];
|
|
150
152
|
if (!halfhalfSetup.active ||
|
|
151
153
|
!halfhalfSetup.tenants.includes(tenant_id) ||
|
|
152
154
|
!halfhalfSetup.included_platforms.includes(platform))
|
|
@@ -401,7 +403,7 @@ function convertHalfHalfToItem(halfhalfSetup, itemsMap, options) {
|
|
|
401
403
|
description: halfhalfSetup.description,
|
|
402
404
|
active: halfhalfSetup.active,
|
|
403
405
|
sold_out: halfhalfSetup.sold_out,
|
|
404
|
-
sort_id:
|
|
406
|
+
sort_id: halfhalfSetup.sort_id,
|
|
405
407
|
// half-half-level upsell is added ONCE at item level; segment options
|
|
406
408
|
// carry the per-segment base (+ own item upsell) prices. Inside a special
|
|
407
409
|
// the half-half's own setup upsell is IGNORED — the item price is the
|
|
@@ -77,6 +77,7 @@ export declare const HalfHalfSetupSchema: Schema<any, import("mongoose").Model<a
|
|
|
77
77
|
image_url: string;
|
|
78
78
|
brand_id: string;
|
|
79
79
|
active: boolean;
|
|
80
|
+
sort_id: number;
|
|
80
81
|
category_id: import("mongoose").Types.ObjectId;
|
|
81
82
|
items: import("mongoose").Types.DocumentArray<{
|
|
82
83
|
sort_id: number;
|
|
@@ -621,6 +622,7 @@ export declare const HalfHalfSetupSchema: Schema<any, import("mongoose").Model<a
|
|
|
621
622
|
image_url: string;
|
|
622
623
|
brand_id: string;
|
|
623
624
|
active: boolean;
|
|
625
|
+
sort_id: number;
|
|
624
626
|
category_id: import("mongoose").Types.ObjectId;
|
|
625
627
|
items: import("mongoose").Types.DocumentArray<{
|
|
626
628
|
sort_id: number;
|
|
@@ -1165,6 +1167,7 @@ export declare const HalfHalfSetupSchema: Schema<any, import("mongoose").Model<a
|
|
|
1165
1167
|
image_url: string;
|
|
1166
1168
|
brand_id: string;
|
|
1167
1169
|
active: boolean;
|
|
1170
|
+
sort_id: number;
|
|
1168
1171
|
category_id: import("mongoose").Types.ObjectId;
|
|
1169
1172
|
items: import("mongoose").Types.DocumentArray<{
|
|
1170
1173
|
sort_id: number;
|
|
@@ -21,6 +21,7 @@ export interface IHalfHalfSetup {
|
|
|
21
21
|
upsell_price: IPrice | null;
|
|
22
22
|
discount_amount: IPrice | null;
|
|
23
23
|
is_discount_percentage: boolean;
|
|
24
|
+
sort_id: number;
|
|
24
25
|
choose_expensive_segment_price: boolean;
|
|
25
26
|
item_special_hours: IItemSpecialHour[] | null;
|
|
26
27
|
items: ISpecialItem[];
|
|
@@ -442,6 +442,7 @@ describe('choose_expensive_segment_price — classic edge cases', () => {
|
|
|
442
442
|
upsell_price: null,
|
|
443
443
|
discount_amount: null,
|
|
444
444
|
is_discount_percentage: false,
|
|
445
|
+
sort_id: 1,
|
|
445
446
|
choose_expensive_segment_price: true,
|
|
446
447
|
segments: [
|
|
447
448
|
{ _id: 'seg-1', name: 'First Half', sort_id: 1 },
|
|
@@ -765,6 +766,7 @@ function makeWorkableHalfHalf() {
|
|
|
765
766
|
upsell_price: null,
|
|
766
767
|
discount_amount: null,
|
|
767
768
|
is_discount_percentage: false,
|
|
769
|
+
sort_id: 1,
|
|
768
770
|
choose_expensive_segment_price: true,
|
|
769
771
|
segments: [
|
|
770
772
|
{ _id: 'seg-1', name: 'First Half', sort_id: 1 },
|
|
@@ -900,6 +902,7 @@ describe('classic vs modern parity (same setup + same halves -> same charge)', (
|
|
|
900
902
|
upsell_price: null,
|
|
901
903
|
discount_amount: null,
|
|
902
904
|
is_discount_percentage: false,
|
|
905
|
+
sort_id: 1,
|
|
903
906
|
choose_expensive_segment_price: true,
|
|
904
907
|
segments: [
|
|
905
908
|
{ _id: 'seg-1', name: 'First Half', sort_id: 1 },
|
|
@@ -22,6 +22,7 @@ function makeHalfHalfSetup(overrides = {}) {
|
|
|
22
22
|
upsell_price: { BASE_PRICE: 1000 },
|
|
23
23
|
discount_amount: null,
|
|
24
24
|
is_discount_percentage: false,
|
|
25
|
+
sort_id: 1,
|
|
25
26
|
choose_expensive_segment_price: true,
|
|
26
27
|
item_special_hours: null,
|
|
27
28
|
items: [{ item_id: 'item-1', sort_id: 1, upsell_price: { BASE_PRICE: 500 } }],
|
|
@@ -97,6 +97,7 @@ function makeHalfHalfSetup(overrides = {}) {
|
|
|
97
97
|
upsell_price: { BASE_PRICE: 300 },
|
|
98
98
|
discount_amount: null,
|
|
99
99
|
is_discount_percentage: false,
|
|
100
|
+
sort_id: 1,
|
|
100
101
|
choose_expensive_segment_price: true,
|
|
101
102
|
segments: [
|
|
102
103
|
{ _id: 'seg-1', name: 'First Half', sort_id: 1 },
|