@managesome/eposmatic-toolkit 0.2.708 → 0.2.710
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/constants/ENUMS.d.ts +1 -0
- package/lib/constants/ENUMS.js +1 -0
- package/lib/helpers/types/catalog.d.ts +2 -1
- package/lib/helpers/utils/halfhalf-setup-helpers.js +2 -0
- package/lib/helpers/utils/minified-catalog.js +2 -0
- package/lib/helpers/utils/order-engine.js +3 -0
- package/lib/helpers/utils/receipt-engine.js +62 -11
- package/lib/helpers/utils/selection-model.d.ts +3 -0
- package/lib/helpers/utils/selection-model.js +1 -0
- package/lib/helpers/utils/simplified-halfhalf.d.ts +4 -3
- package/lib/helpers/utils/simplified-halfhalf.js +8 -6
- package/lib/helpers/utils/simplified-specials.d.ts +4 -4
- package/lib/helpers/utils/simplified-specials.js +10 -9
- package/lib/helpers/utils/specials-helpers.d.ts +3 -3
- package/lib/helpers/utils/specials-helpers.js +39 -7
- package/lib/schemas/models/items.d.ts +27 -0
- package/lib/schemas/models/items.js +7 -0
- package/lib/schemas/models/modifier_extras.d.ts +9 -9
- package/lib/schemas/models/orders.d.ts +981 -0
- package/lib/schemas/models/orders.js +5 -0
- package/lib/schemas/models/rewards_usage.d.ts +3 -3
- package/lib/schemas/models/tenant_cash_in_out.d.ts +3 -3
- package/lib/schemas/models/warehouse_internal_movements.d.ts +3 -3
- package/lib/schemas/models/warehouse_inventory_lot_serial_numbers.d.ts +3 -3
- package/lib/schemas/types/items.d.ts +2 -1
- package/lib/schemas/types/orders.d.ts +2 -1
- package/lib/tests/receipt-engine.test.d.ts +1 -0
- package/lib/tests/receipt-engine.test.js +204 -0
- package/lib/tests/simplified-halfhalf.test.js +4 -4
- package/lib/tests/simplified-specials.test.js +6 -6
- package/lib/tests/specials-halfhalf-options.test.d.ts +1 -0
- package/lib/tests/specials-halfhalf-options.test.js +327 -0
- package/package.json +1 -1
|
@@ -279,6 +279,11 @@ const OptionsSchema = new mongoose_1.Schema({
|
|
|
279
279
|
type: Boolean,
|
|
280
280
|
default: false,
|
|
281
281
|
},
|
|
282
|
+
ref_type: {
|
|
283
|
+
type: String,
|
|
284
|
+
enum: constants_1.ALL_MODIFIER_OPTION_REF_TYPES,
|
|
285
|
+
required: false,
|
|
286
|
+
},
|
|
282
287
|
});
|
|
283
288
|
exports.OrderItemModifiersSchema = new mongoose_1.Schema({
|
|
284
289
|
_id: {
|
|
@@ -10,13 +10,13 @@ export declare const RewardsUsageSchema: Schema<any, import("mongoose").Model<an
|
|
|
10
10
|
_id: import("mongoose").Types.ObjectId;
|
|
11
11
|
createdAt: NativeDate;
|
|
12
12
|
updatedAt: NativeDate;
|
|
13
|
+
ref_type: import("../../constants").REWARDS_USAGE_REF_TYPE_ENUM;
|
|
13
14
|
ref_id: import("mongoose").Types.ObjectId;
|
|
14
15
|
customer_phone: string;
|
|
15
16
|
last_used_at: NativeDate;
|
|
16
17
|
used_count: number;
|
|
17
18
|
assigned_count: number;
|
|
18
19
|
last_assigned_at: NativeDate;
|
|
19
|
-
ref_type: import("../../constants").REWARDS_USAGE_REF_TYPE_ENUM;
|
|
20
20
|
}, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
|
|
21
21
|
createdAt: NativeDate;
|
|
22
22
|
updatedAt: NativeDate;
|
|
@@ -24,13 +24,13 @@ export declare const RewardsUsageSchema: Schema<any, import("mongoose").Model<an
|
|
|
24
24
|
_id: import("mongoose").Types.ObjectId;
|
|
25
25
|
createdAt: NativeDate;
|
|
26
26
|
updatedAt: NativeDate;
|
|
27
|
+
ref_type: import("../../constants").REWARDS_USAGE_REF_TYPE_ENUM;
|
|
27
28
|
ref_id: import("mongoose").Types.ObjectId;
|
|
28
29
|
customer_phone: string;
|
|
29
30
|
last_used_at: NativeDate;
|
|
30
31
|
used_count: number;
|
|
31
32
|
assigned_count: number;
|
|
32
33
|
last_assigned_at: NativeDate;
|
|
33
|
-
ref_type: import("../../constants").REWARDS_USAGE_REF_TYPE_ENUM;
|
|
34
34
|
}>> & import("mongoose").FlatRecord<{
|
|
35
35
|
createdAt: NativeDate;
|
|
36
36
|
updatedAt: NativeDate;
|
|
@@ -38,13 +38,13 @@ export declare const RewardsUsageSchema: Schema<any, import("mongoose").Model<an
|
|
|
38
38
|
_id: import("mongoose").Types.ObjectId;
|
|
39
39
|
createdAt: NativeDate;
|
|
40
40
|
updatedAt: NativeDate;
|
|
41
|
+
ref_type: import("../../constants").REWARDS_USAGE_REF_TYPE_ENUM;
|
|
41
42
|
ref_id: import("mongoose").Types.ObjectId;
|
|
42
43
|
customer_phone: string;
|
|
43
44
|
last_used_at: NativeDate;
|
|
44
45
|
used_count: number;
|
|
45
46
|
assigned_count: number;
|
|
46
47
|
last_assigned_at: NativeDate;
|
|
47
|
-
ref_type: import("../../constants").REWARDS_USAGE_REF_TYPE_ENUM;
|
|
48
48
|
}> & Required<{
|
|
49
49
|
_id: import("mongoose").Types.ObjectId;
|
|
50
50
|
}> & {
|
|
@@ -15,6 +15,7 @@ export declare const TenantCashInOutSchema: Schema<any, import("mongoose").Model
|
|
|
15
15
|
createdAt: NativeDate;
|
|
16
16
|
updatedAt: NativeDate;
|
|
17
17
|
note: string;
|
|
18
|
+
ref_type: import("../../constants").CASH_IN_OUT_REF_ENUM;
|
|
18
19
|
ref_id: import("mongoose").Types.ObjectId;
|
|
19
20
|
amount: number;
|
|
20
21
|
localYear: number;
|
|
@@ -31,7 +32,6 @@ export declare const TenantCashInOutSchema: Schema<any, import("mongoose").Model
|
|
|
31
32
|
localDate: string;
|
|
32
33
|
localTime: string;
|
|
33
34
|
localDayOfYear: number;
|
|
34
|
-
ref_type: import("../../constants").CASH_IN_OUT_REF_ENUM;
|
|
35
35
|
day_id: import("mongoose").Types.ObjectId;
|
|
36
36
|
drawer_id: import("mongoose").Types.ObjectId;
|
|
37
37
|
shift_id: import("mongoose").Types.ObjectId;
|
|
@@ -50,6 +50,7 @@ export declare const TenantCashInOutSchema: Schema<any, import("mongoose").Model
|
|
|
50
50
|
createdAt: NativeDate;
|
|
51
51
|
updatedAt: NativeDate;
|
|
52
52
|
note: string;
|
|
53
|
+
ref_type: import("../../constants").CASH_IN_OUT_REF_ENUM;
|
|
53
54
|
ref_id: import("mongoose").Types.ObjectId;
|
|
54
55
|
amount: number;
|
|
55
56
|
localYear: number;
|
|
@@ -66,7 +67,6 @@ export declare const TenantCashInOutSchema: Schema<any, import("mongoose").Model
|
|
|
66
67
|
localDate: string;
|
|
67
68
|
localTime: string;
|
|
68
69
|
localDayOfYear: number;
|
|
69
|
-
ref_type: import("../../constants").CASH_IN_OUT_REF_ENUM;
|
|
70
70
|
day_id: import("mongoose").Types.ObjectId;
|
|
71
71
|
drawer_id: import("mongoose").Types.ObjectId;
|
|
72
72
|
shift_id: import("mongoose").Types.ObjectId;
|
|
@@ -85,6 +85,7 @@ export declare const TenantCashInOutSchema: Schema<any, import("mongoose").Model
|
|
|
85
85
|
createdAt: NativeDate;
|
|
86
86
|
updatedAt: NativeDate;
|
|
87
87
|
note: string;
|
|
88
|
+
ref_type: import("../../constants").CASH_IN_OUT_REF_ENUM;
|
|
88
89
|
ref_id: import("mongoose").Types.ObjectId;
|
|
89
90
|
amount: number;
|
|
90
91
|
localYear: number;
|
|
@@ -101,7 +102,6 @@ export declare const TenantCashInOutSchema: Schema<any, import("mongoose").Model
|
|
|
101
102
|
localDate: string;
|
|
102
103
|
localTime: string;
|
|
103
104
|
localDayOfYear: number;
|
|
104
|
-
ref_type: import("../../constants").CASH_IN_OUT_REF_ENUM;
|
|
105
105
|
day_id: import("mongoose").Types.ObjectId;
|
|
106
106
|
drawer_id: import("mongoose").Types.ObjectId;
|
|
107
107
|
shift_id: import("mongoose").Types.ObjectId;
|
|
@@ -362,6 +362,7 @@ export declare const WarehouseInternalMovementsSchema: Schema<any, import("mongo
|
|
|
362
362
|
unit_price?: number | null | undefined;
|
|
363
363
|
dispatched_qty?: number | null | undefined;
|
|
364
364
|
}>;
|
|
365
|
+
ref_type: import("../../constants").WAREHOUSE_REF_TYPE_ENUM;
|
|
365
366
|
ref_id: string;
|
|
366
367
|
status: import("../../constants").WAREHOUSE_INTERNAL_MOVEMENT_STATUS_ENUM;
|
|
367
368
|
iterations: import("mongoose").Types.DocumentArray<{
|
|
@@ -747,7 +748,6 @@ export declare const WarehouseInternalMovementsSchema: Schema<any, import("mongo
|
|
|
747
748
|
uid: string;
|
|
748
749
|
};
|
|
749
750
|
doc_number: string;
|
|
750
|
-
ref_type: import("../../constants").WAREHOUSE_REF_TYPE_ENUM;
|
|
751
751
|
record_type: import("../../constants").WAREHOUSE_INTERNAL_MOVEMENT_RECORD_TYPE_ENUM;
|
|
752
752
|
flow: import("../../constants").WAREHOUSE_INTERNAL_MOVEMENT_FLOW_ENUM;
|
|
753
753
|
source_id: string;
|
|
@@ -863,6 +863,7 @@ export declare const WarehouseInternalMovementsSchema: Schema<any, import("mongo
|
|
|
863
863
|
unit_price?: number | null | undefined;
|
|
864
864
|
dispatched_qty?: number | null | undefined;
|
|
865
865
|
}>;
|
|
866
|
+
ref_type: import("../../constants").WAREHOUSE_REF_TYPE_ENUM;
|
|
866
867
|
ref_id: string;
|
|
867
868
|
status: import("../../constants").WAREHOUSE_INTERNAL_MOVEMENT_STATUS_ENUM;
|
|
868
869
|
iterations: import("mongoose").Types.DocumentArray<{
|
|
@@ -1248,7 +1249,6 @@ export declare const WarehouseInternalMovementsSchema: Schema<any, import("mongo
|
|
|
1248
1249
|
uid: string;
|
|
1249
1250
|
};
|
|
1250
1251
|
doc_number: string;
|
|
1251
|
-
ref_type: import("../../constants").WAREHOUSE_REF_TYPE_ENUM;
|
|
1252
1252
|
record_type: import("../../constants").WAREHOUSE_INTERNAL_MOVEMENT_RECORD_TYPE_ENUM;
|
|
1253
1253
|
flow: import("../../constants").WAREHOUSE_INTERNAL_MOVEMENT_FLOW_ENUM;
|
|
1254
1254
|
source_id: string;
|
|
@@ -1364,6 +1364,7 @@ export declare const WarehouseInternalMovementsSchema: Schema<any, import("mongo
|
|
|
1364
1364
|
unit_price?: number | null | undefined;
|
|
1365
1365
|
dispatched_qty?: number | null | undefined;
|
|
1366
1366
|
}>;
|
|
1367
|
+
ref_type: import("../../constants").WAREHOUSE_REF_TYPE_ENUM;
|
|
1367
1368
|
ref_id: string;
|
|
1368
1369
|
status: import("../../constants").WAREHOUSE_INTERNAL_MOVEMENT_STATUS_ENUM;
|
|
1369
1370
|
iterations: import("mongoose").Types.DocumentArray<{
|
|
@@ -1749,7 +1750,6 @@ export declare const WarehouseInternalMovementsSchema: Schema<any, import("mongo
|
|
|
1749
1750
|
uid: string;
|
|
1750
1751
|
};
|
|
1751
1752
|
doc_number: string;
|
|
1752
|
-
ref_type: import("../../constants").WAREHOUSE_REF_TYPE_ENUM;
|
|
1753
1753
|
record_type: import("../../constants").WAREHOUSE_INTERNAL_MOVEMENT_RECORD_TYPE_ENUM;
|
|
1754
1754
|
flow: import("../../constants").WAREHOUSE_INTERNAL_MOVEMENT_FLOW_ENUM;
|
|
1755
1755
|
source_id: string;
|
|
@@ -12,8 +12,8 @@ export declare const WarehouseInventoryLotSerialNumberSchema: Schema<any, import
|
|
|
12
12
|
createdAt: NativeDate;
|
|
13
13
|
updatedAt: NativeDate;
|
|
14
14
|
inventory_code: string;
|
|
15
|
-
ref_id: string;
|
|
16
15
|
ref_type: string;
|
|
16
|
+
ref_id: string;
|
|
17
17
|
tracking_mode: WAREHOUSE_TRACKING_MODE_ENUM;
|
|
18
18
|
doc_type: WAREHOUSE_LOT_SERIAL_DOC_TYPE_ENUM;
|
|
19
19
|
source?: import("../../constants").WAREHOUSE_LOT_SERIAL_MOVEMENT_SOURCE_ENUM | null | undefined;
|
|
@@ -59,8 +59,8 @@ export declare const WarehouseInventoryLotSerialNumberSchema: Schema<any, import
|
|
|
59
59
|
createdAt: NativeDate;
|
|
60
60
|
updatedAt: NativeDate;
|
|
61
61
|
inventory_code: string;
|
|
62
|
-
ref_id: string;
|
|
63
62
|
ref_type: string;
|
|
63
|
+
ref_id: string;
|
|
64
64
|
tracking_mode: WAREHOUSE_TRACKING_MODE_ENUM;
|
|
65
65
|
doc_type: WAREHOUSE_LOT_SERIAL_DOC_TYPE_ENUM;
|
|
66
66
|
source?: import("../../constants").WAREHOUSE_LOT_SERIAL_MOVEMENT_SOURCE_ENUM | null | undefined;
|
|
@@ -106,8 +106,8 @@ export declare const WarehouseInventoryLotSerialNumberSchema: Schema<any, import
|
|
|
106
106
|
createdAt: NativeDate;
|
|
107
107
|
updatedAt: NativeDate;
|
|
108
108
|
inventory_code: string;
|
|
109
|
-
ref_id: string;
|
|
110
109
|
ref_type: string;
|
|
110
|
+
ref_id: string;
|
|
111
111
|
tracking_mode: WAREHOUSE_TRACKING_MODE_ENUM;
|
|
112
112
|
doc_type: WAREHOUSE_LOT_SERIAL_DOC_TYPE_ENUM;
|
|
113
113
|
source?: import("../../constants").WAREHOUSE_LOT_SERIAL_MOVEMENT_SOURCE_ENUM | null | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ITEM_CAVEATS_ENUM, ITEM_DIETARY_PREFERENCE_ENUM, ORDER_ITEM_TYPE_ENUM, PLATFORMS_ENUM } from '../../constants';
|
|
1
|
+
import { ITEM_CAVEATS_ENUM, ITEM_DIETARY_PREFERENCE_ENUM, MODIFIER_OPTION_REF_TYPE_ENUM, ORDER_ITEM_TYPE_ENUM, PLATFORMS_ENUM } from '../../constants';
|
|
2
2
|
import { IIngredient, IItemSpecialHour, IPrice } from './common';
|
|
3
3
|
export interface IModifier {
|
|
4
4
|
_id: string /** * Unique identifier for the modifier */;
|
|
@@ -33,6 +33,7 @@ export interface IModifierOption {
|
|
|
33
33
|
default?: boolean;
|
|
34
34
|
ingredients?: IIngredient[] | null;
|
|
35
35
|
item_modifier_option_special_hours?: IItemSpecialHour[] | null;
|
|
36
|
+
ref_type?: MODIFIER_OPTION_REF_TYPE_ENUM;
|
|
36
37
|
}
|
|
37
38
|
export interface IItem {
|
|
38
39
|
_id: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GIFT_CARD_REWARD_TYPE_ENUM, ORDER_ITEM_TYPE_ENUM, ORDER_STATUS_ENUM, PAYMENT_METHOD_EXPECTED_ENUM, PAYMENT_PROVIDERS_ENUM, PAYMENT_STATUS_ENUM, PAYMENT_TYPE_ENUM, PLATFORMS_ENUM, SPLIT_BILL_TYPE_ENUM } from '../../constants';
|
|
1
|
+
import { GIFT_CARD_REWARD_TYPE_ENUM, MODIFIER_OPTION_REF_TYPE_ENUM, ORDER_ITEM_TYPE_ENUM, ORDER_STATUS_ENUM, PAYMENT_METHOD_EXPECTED_ENUM, PAYMENT_PROVIDERS_ENUM, PAYMENT_STATUS_ENUM, PAYMENT_TYPE_ENUM, PLATFORMS_ENUM, SPLIT_BILL_TYPE_ENUM } from '../../constants';
|
|
2
2
|
import { ILocalTimeFields } from '../../helpers';
|
|
3
3
|
export interface IOrderCourse {
|
|
4
4
|
name: string;
|
|
@@ -55,6 +55,7 @@ export interface IOrderOption {
|
|
|
55
55
|
price: number;
|
|
56
56
|
quantity: number;
|
|
57
57
|
is_free: boolean;
|
|
58
|
+
ref_type?: MODIFIER_OPTION_REF_TYPE_ENUM;
|
|
58
59
|
modifiers: IOrderModifier[] | null;
|
|
59
60
|
}
|
|
60
61
|
export interface ICardDetails {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const constants_1 = require("../constants");
|
|
4
|
+
const receipt_engine_1 = require("../helpers/utils/receipt-engine");
|
|
5
|
+
// =========================><=========================
|
|
6
|
+
function makeItem(_id, name, overrides = {}) {
|
|
7
|
+
return {
|
|
8
|
+
_id,
|
|
9
|
+
item_id: _id,
|
|
10
|
+
item_type: constants_1.ORDER_ITEM_TYPE_ENUM.ITEM,
|
|
11
|
+
name,
|
|
12
|
+
price: 500,
|
|
13
|
+
subtotal: 500,
|
|
14
|
+
tax_rate: 0,
|
|
15
|
+
quantity: 1,
|
|
16
|
+
_net_amount: 500,
|
|
17
|
+
_gross_amount: 500,
|
|
18
|
+
_gst_amount: 0,
|
|
19
|
+
_discount_amount: 0,
|
|
20
|
+
special_instructions: '',
|
|
21
|
+
item_discount_details: null,
|
|
22
|
+
modifiers: null,
|
|
23
|
+
...overrides,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function makeOption(id, ref, name, overrides = {}) {
|
|
27
|
+
return { _id: id, ref, name, price: 500, quantity: 1, is_free: false, modifiers: null, ...overrides };
|
|
28
|
+
}
|
|
29
|
+
function makeModifier(_id, ref, name, options) {
|
|
30
|
+
return { _id, ref, name, options };
|
|
31
|
+
}
|
|
32
|
+
const PIZZA_ONLY_MENU = {
|
|
33
|
+
'cat-deals': { sortId: 0, includedItemsMap: { 'deal-1': { sortId: 0 } } },
|
|
34
|
+
'cat-pizza': {
|
|
35
|
+
sortId: 1,
|
|
36
|
+
includedItemsMap: { 'pizza-milano': { sortId: 0 }, 'pizza-toronto': { sortId: 1 } },
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
const DRINK_ONLY_MENU = {
|
|
40
|
+
'cat-deals': { sortId: 0, includedItemsMap: { 'deal-1': { sortId: 0 } } },
|
|
41
|
+
'cat-drinks': {
|
|
42
|
+
sortId: 1,
|
|
43
|
+
includedItemsMap: { 'cola-next': { sortId: 0 } },
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
// =========================><=========================
|
|
47
|
+
describe('getPartialItems - composite items on partial KOTs (ref_type)', () => {
|
|
48
|
+
it('filters ITEM options by the partial menu and keeps regular OPTION options', () => {
|
|
49
|
+
const deal = makeItem('deal-1', 'Buy 1 Pizza Get 1 Free', {
|
|
50
|
+
item_type: constants_1.ORDER_ITEM_TYPE_ENUM.SPECIAL,
|
|
51
|
+
modifiers: [
|
|
52
|
+
makeModifier('mod-pizza-1', 'modref-pizza-1', 'FIRST PIZZA', [
|
|
53
|
+
makeOption('opt-milano', 'pizza-milano', 'Milano', {
|
|
54
|
+
ref_type: constants_1.MODIFIER_OPTION_REF_TYPE_ENUM.ITEM,
|
|
55
|
+
modifiers: [
|
|
56
|
+
makeModifier('mod-size-1', 'modref-size-1', 'PIZZA SIZE', [
|
|
57
|
+
// regular modifier option (no ref_type / OPTION) -> never partialed
|
|
58
|
+
makeOption('opt-large', 'size-large', 'Large 13"', {
|
|
59
|
+
ref_type: constants_1.MODIFIER_OPTION_REF_TYPE_ENUM.OPTION,
|
|
60
|
+
}),
|
|
61
|
+
]),
|
|
62
|
+
],
|
|
63
|
+
}),
|
|
64
|
+
]),
|
|
65
|
+
makeModifier('mod-pizza-2', 'modref-pizza-2', 'SECOND PIZZA', [
|
|
66
|
+
makeOption('opt-toronto', 'pizza-toronto', 'Toronto', {
|
|
67
|
+
ref_type: constants_1.MODIFIER_OPTION_REF_TYPE_ENUM.ITEM,
|
|
68
|
+
modifiers: [
|
|
69
|
+
makeModifier('mod-size-2', 'modref-size-2', 'PIZZA SIZE', [
|
|
70
|
+
makeOption('opt-medium', 'size-medium', 'Medium 10"'),
|
|
71
|
+
]),
|
|
72
|
+
],
|
|
73
|
+
}),
|
|
74
|
+
]),
|
|
75
|
+
makeModifier('mod-drink', 'modref-drink', 'DRINK', [
|
|
76
|
+
makeOption('opt-cola', 'cola-next', 'Cola Next 1.5 Ltr', {
|
|
77
|
+
ref_type: constants_1.MODIFIER_OPTION_REF_TYPE_ENUM.ITEM,
|
|
78
|
+
}),
|
|
79
|
+
]),
|
|
80
|
+
],
|
|
81
|
+
});
|
|
82
|
+
const categories = [
|
|
83
|
+
{ name: 'Deals', category_id: 'cat-deals', items: [deal] },
|
|
84
|
+
{
|
|
85
|
+
name: 'Pizza',
|
|
86
|
+
category_id: 'cat-pizza',
|
|
87
|
+
items: [makeItem('pizza-milano', 'Milano'), makeItem('pizza-toronto', 'Toronto')],
|
|
88
|
+
},
|
|
89
|
+
];
|
|
90
|
+
const result = (0, receipt_engine_1.getPartialItems)(categories, PIZZA_ONLY_MENU);
|
|
91
|
+
const dealCategory = result.find((c) => c.category_id === 'cat-deals');
|
|
92
|
+
expect(dealCategory).toBeDefined();
|
|
93
|
+
expect(dealCategory.items).toHaveLength(1);
|
|
94
|
+
const trimmedDeal = dealCategory.items[0];
|
|
95
|
+
expect(trimmedDeal.modifiers.map((m) => m.name)).toEqual(['FIRST PIZZA', 'SECOND PIZZA']);
|
|
96
|
+
expect(trimmedDeal.modifiers[0].options.map((o) => o.ref)).toEqual(['pizza-milano']);
|
|
97
|
+
expect(trimmedDeal.modifiers[1].options.map((o) => o.ref)).toEqual(['pizza-toronto']);
|
|
98
|
+
// regular OPTION options survive untouched even though they are not in the menu
|
|
99
|
+
const sizeModifier = trimmedDeal.modifiers[0].options[0].modifiers[0];
|
|
100
|
+
expect(sizeModifier.name).toBe('PIZZA SIZE');
|
|
101
|
+
expect(sizeModifier.options[0].ref).toBe('size-large');
|
|
102
|
+
expect(trimmedDeal.modifiers[1].options[0].modifiers[0].options[0].ref).toBe('size-medium');
|
|
103
|
+
// the drink belongs to the drink KOT
|
|
104
|
+
expect(result.find((c) => c.category_id === 'cat-drinks')).toBeUndefined();
|
|
105
|
+
});
|
|
106
|
+
it('recursively trims a HALF_HALF option by its internal ITEM options', () => {
|
|
107
|
+
const deal = makeItem('deal-2', 'Deal With Half Half', {
|
|
108
|
+
item_type: constants_1.ORDER_ITEM_TYPE_ENUM.SPECIAL,
|
|
109
|
+
modifiers: [
|
|
110
|
+
makeModifier('mod-half', 'modref-half', 'HALF HALF PIZZA', [
|
|
111
|
+
makeOption('opt-half', 'half-pizza-1', 'Half Half Pizza', {
|
|
112
|
+
ref_type: constants_1.MODIFIER_OPTION_REF_TYPE_ENUM.HALF_HALF,
|
|
113
|
+
modifiers: [
|
|
114
|
+
makeModifier('mod-left', 'modref-left', 'LEFT HALF', [
|
|
115
|
+
makeOption('opt-left', 'pizza-milano', 'Milano', {
|
|
116
|
+
ref_type: constants_1.MODIFIER_OPTION_REF_TYPE_ENUM.ITEM,
|
|
117
|
+
}),
|
|
118
|
+
]),
|
|
119
|
+
makeModifier('mod-right', 'modref-right', 'RIGHT HALF', [
|
|
120
|
+
makeOption('opt-right', 'pizza-toronto', 'Toronto', {
|
|
121
|
+
ref_type: constants_1.MODIFIER_OPTION_REF_TYPE_ENUM.ITEM,
|
|
122
|
+
}),
|
|
123
|
+
]),
|
|
124
|
+
],
|
|
125
|
+
}),
|
|
126
|
+
]),
|
|
127
|
+
],
|
|
128
|
+
});
|
|
129
|
+
const categories = [
|
|
130
|
+
{ name: 'Deals', category_id: 'cat-deals', items: [deal] },
|
|
131
|
+
{
|
|
132
|
+
name: 'Pizza',
|
|
133
|
+
category_id: 'cat-pizza',
|
|
134
|
+
items: [makeItem('pizza-milano', 'Milano')],
|
|
135
|
+
},
|
|
136
|
+
];
|
|
137
|
+
const result = (0, receipt_engine_1.getPartialItems)(categories, {
|
|
138
|
+
'cat-deals': { sortId: 0, includedItemsMap: { 'deal-2': { sortId: 0 } } },
|
|
139
|
+
'cat-pizza': {
|
|
140
|
+
sortId: 1,
|
|
141
|
+
includedItemsMap: { 'pizza-milano': { sortId: 0 }, 'half-pizza-1': { sortId: 1 } },
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
const trimmedDeal = result.find((c) => c.category_id === 'cat-deals').items[0];
|
|
145
|
+
expect(trimmedDeal.modifiers).toHaveLength(1);
|
|
146
|
+
const halfOption = trimmedDeal.modifiers[0].options[0];
|
|
147
|
+
expect(halfOption.ref_type).toBe(constants_1.MODIFIER_OPTION_REF_TYPE_ENUM.HALF_HALF);
|
|
148
|
+
// only the LEFT HALF survived; RIGHT HALF (Toronto) is trimmed away
|
|
149
|
+
expect(halfOption.modifiers.map((m) => m.name)).toEqual(['LEFT HALF']);
|
|
150
|
+
expect(halfOption.modifiers[0].options.map((o) => o.ref)).toEqual(['pizza-milano']);
|
|
151
|
+
});
|
|
152
|
+
it('drops a HALF_HALF option whose nested parts are all filtered', () => {
|
|
153
|
+
const deal = makeItem('deal-3', 'Deal With Half Half', {
|
|
154
|
+
item_type: constants_1.ORDER_ITEM_TYPE_ENUM.SPECIAL,
|
|
155
|
+
modifiers: [
|
|
156
|
+
makeModifier('mod-half', 'modref-half', 'HALF HALF PIZZA', [
|
|
157
|
+
makeOption('opt-half', 'half-pizza-1', 'Half Half Pizza', {
|
|
158
|
+
ref_type: constants_1.MODIFIER_OPTION_REF_TYPE_ENUM.HALF_HALF,
|
|
159
|
+
modifiers: [
|
|
160
|
+
makeModifier('mod-left', 'modref-left', 'LEFT HALF', [
|
|
161
|
+
makeOption('opt-left', 'pizza-milano', 'Milano', {
|
|
162
|
+
ref_type: constants_1.MODIFIER_OPTION_REF_TYPE_ENUM.ITEM,
|
|
163
|
+
}),
|
|
164
|
+
]),
|
|
165
|
+
],
|
|
166
|
+
}),
|
|
167
|
+
]),
|
|
168
|
+
makeModifier('mod-drink', 'modref-drink', 'DRINK', [
|
|
169
|
+
makeOption('opt-cola', 'cola-next', 'Cola Next 1.5 Ltr', {
|
|
170
|
+
ref_type: constants_1.MODIFIER_OPTION_REF_TYPE_ENUM.ITEM,
|
|
171
|
+
}),
|
|
172
|
+
]),
|
|
173
|
+
],
|
|
174
|
+
});
|
|
175
|
+
const categories = [
|
|
176
|
+
{ name: 'Deals', category_id: 'cat-deals', items: [deal] },
|
|
177
|
+
{ name: 'Drinks', category_id: 'cat-drinks', items: [makeItem('cola-next', 'Cola Next 1.5 Ltr')] },
|
|
178
|
+
];
|
|
179
|
+
const result = (0, receipt_engine_1.getPartialItems)(categories, {
|
|
180
|
+
'cat-deals': { sortId: 0, includedItemsMap: { 'deal-3': { sortId: 0 } } },
|
|
181
|
+
'cat-drinks': { sortId: 1, includedItemsMap: { 'cola-next': { sortId: 0 } } },
|
|
182
|
+
});
|
|
183
|
+
const trimmedDeal = result.find((c) => c.category_id === 'cat-deals').items[0];
|
|
184
|
+
// half-half gone (its parts belong to the pizza KOT), drink kept
|
|
185
|
+
expect(trimmedDeal.modifiers.map((m) => m.name)).toEqual(['DRINK']);
|
|
186
|
+
expect(trimmedDeal.modifiers[0].options.map((o) => o.ref)).toEqual(['cola-next']);
|
|
187
|
+
});
|
|
188
|
+
it('treats options without ref_type as regular options and keeps them', () => {
|
|
189
|
+
const deal = makeItem('deal-4', 'Legacy Deal', {
|
|
190
|
+
item_type: constants_1.ORDER_ITEM_TYPE_ENUM.SPECIAL,
|
|
191
|
+
modifiers: [
|
|
192
|
+
makeModifier('mod-drink', 'modref-drink', 'DRINK', [
|
|
193
|
+
// legacy stored order: no ref_type at all
|
|
194
|
+
makeOption('opt-cola', 'cola-next', 'Cola Next 1.5 Ltr'),
|
|
195
|
+
]),
|
|
196
|
+
],
|
|
197
|
+
});
|
|
198
|
+
const result = (0, receipt_engine_1.getPartialItems)([{ name: 'Deals', category_id: 'cat-deals', items: [deal] }], {
|
|
199
|
+
'cat-deals': { sortId: 0, includedItemsMap: { 'deal-4': { sortId: 0 } } },
|
|
200
|
+
});
|
|
201
|
+
const trimmedDeal = result.find((c) => c.category_id === 'cat-deals').items[0];
|
|
202
|
+
expect(trimmedDeal.modifiers[0].options.map((o) => o.ref)).toEqual(['cola-next']);
|
|
203
|
+
});
|
|
204
|
+
});
|
|
@@ -116,19 +116,19 @@ describe('convertSimplifiedHalfHalfToSimplifiedItem', () => {
|
|
|
116
116
|
const item = (0, simplified_halfhalf_1.convertSimplifiedHalfHalfToSimplifiedItem)(makeSimplifiedHalfHalfSetup({ sold_out: true }));
|
|
117
117
|
expect(item.sold_out).toBe(true);
|
|
118
118
|
});
|
|
119
|
-
it('
|
|
120
|
-
const item = (0, simplified_halfhalf_1.convertSimplifiedHalfHalfToSimplifiedItem)(makeSimplifiedHalfHalfSetup({ discount_amount:
|
|
119
|
+
it('maps dollar discount_amount to IPrice (no re-scaling)', () => {
|
|
120
|
+
const item = (0, simplified_halfhalf_1.convertSimplifiedHalfHalfToSimplifiedItem)(makeSimplifiedHalfHalfSetup({ discount_amount: 3, is_discount_percentage: true }));
|
|
121
121
|
expect(item.discount_amount).toEqual({ BASE_PRICE: 3 });
|
|
122
122
|
expect(item.is_discount_percentage).toBe(true);
|
|
123
123
|
});
|
|
124
|
-
it('
|
|
124
|
+
it('maps item_special_hours (shape only)', () => {
|
|
125
125
|
const item = (0, simplified_halfhalf_1.convertSimplifiedHalfHalfToSimplifiedItem)(makeSimplifiedHalfHalfSetup({
|
|
126
126
|
item_special_hours: [
|
|
127
127
|
{
|
|
128
128
|
days_index: [constants_1.DAY_INDEX_ENUM.MON],
|
|
129
129
|
start_time: 60,
|
|
130
130
|
end_time: 120,
|
|
131
|
-
price:
|
|
131
|
+
price: 5,
|
|
132
132
|
},
|
|
133
133
|
],
|
|
134
134
|
}));
|
|
@@ -87,24 +87,24 @@ describe('convertSimplifiedSpecialToSimplifiedItem', () => {
|
|
|
87
87
|
const item = (0, simplified_specials_1.convertSimplifiedSpecialToSimplifiedItem)(makeSimplifiedSpecial({ sold_out: true }));
|
|
88
88
|
expect(item.sold_out).toBe(true);
|
|
89
89
|
});
|
|
90
|
-
it('
|
|
91
|
-
const item = (0, simplified_specials_1.convertSimplifiedSpecialToSimplifiedItem)(makeSimplifiedSpecial({ price:
|
|
90
|
+
it('maps dollar price/discount_amount to IPrice (no re-scaling)', () => {
|
|
91
|
+
const item = (0, simplified_specials_1.convertSimplifiedSpecialToSimplifiedItem)(makeSimplifiedSpecial({ price: 12, discount_amount: 3, is_discount_percentage: true }));
|
|
92
92
|
expect(item.price).toEqual({ BASE_PRICE: 12 });
|
|
93
93
|
expect(item.discount_amount).toEqual({ BASE_PRICE: 3 });
|
|
94
94
|
expect(item.is_discount_percentage).toBe(true);
|
|
95
95
|
});
|
|
96
|
-
it('
|
|
97
|
-
const item = (0, simplified_specials_1.convertSimplifiedSpecialToSimplifiedItem)(makeSimplifiedSpecial({ display_price:
|
|
96
|
+
it('carries display_price through unscaled', () => {
|
|
97
|
+
const item = (0, simplified_specials_1.convertSimplifiedSpecialToSimplifiedItem)(makeSimplifiedSpecial({ display_price: 12.5 }));
|
|
98
98
|
expect(item.display_price).toBe(12.5);
|
|
99
99
|
});
|
|
100
|
-
it('
|
|
100
|
+
it('maps item_special_hours (shape only)', () => {
|
|
101
101
|
const item = (0, simplified_specials_1.convertSimplifiedSpecialToSimplifiedItem)(makeSimplifiedSpecial({
|
|
102
102
|
item_special_hours: [
|
|
103
103
|
{
|
|
104
104
|
days_index: [constants_1.DAY_INDEX_ENUM.MON],
|
|
105
105
|
start_time: 60,
|
|
106
106
|
end_time: 120,
|
|
107
|
-
price:
|
|
107
|
+
price: 5,
|
|
108
108
|
},
|
|
109
109
|
],
|
|
110
110
|
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|