@managesome/eposmatic-toolkit 0.2.708 → 0.2.709
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/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/tests/simplified-halfhalf.test.js +4 -4
- package/lib/tests/simplified-specials.test.js +6 -6
- package/package.json +1 -1
|
@@ -13,9 +13,10 @@ export declare function convertHalfHalfSetupsToSimplifiedHalfHalfSetups(halfhalf
|
|
|
13
13
|
* mapping of what ISimplifiedCatalogItem can represent:
|
|
14
14
|
* - item `price`/`tax_rate` are null (there is no base price on the payload;
|
|
15
15
|
* the per-segment prices come from the constituent items at selection time),
|
|
16
|
-
* - `discount_amount` and `item_special_hours` are
|
|
17
|
-
*
|
|
18
|
-
*
|
|
16
|
+
* - `discount_amount` and `item_special_hours` are already in the dollar/UI
|
|
17
|
+
* domain (converted at slice ingest via `getSimplifiedHalfHalfSetupWithPrice`),
|
|
18
|
+
* so only the minified shape is normalized — NO currency re-scaling,
|
|
19
|
+
* mirroring `convertHalfHalfToItem` after `getHalfhalfSetupWithPrice`,
|
|
19
20
|
* - no `modifiers` are produced (selection structure isn't part of the
|
|
20
21
|
* simplified setup),
|
|
21
22
|
* - `sort_id` is not part of the payload, so it defaults to 0 (same as
|
|
@@ -42,18 +42,20 @@ function convertHalfHalfSetupsToSimplifiedHalfHalfSetups(halfhalfSetups, tenantI
|
|
|
42
42
|
* mapping of what ISimplifiedCatalogItem can represent:
|
|
43
43
|
* - item `price`/`tax_rate` are null (there is no base price on the payload;
|
|
44
44
|
* the per-segment prices come from the constituent items at selection time),
|
|
45
|
-
* - `discount_amount` and `item_special_hours` are
|
|
46
|
-
*
|
|
47
|
-
*
|
|
45
|
+
* - `discount_amount` and `item_special_hours` are already in the dollar/UI
|
|
46
|
+
* domain (converted at slice ingest via `getSimplifiedHalfHalfSetupWithPrice`),
|
|
47
|
+
* so only the minified shape is normalized — NO currency re-scaling,
|
|
48
|
+
* mirroring `convertHalfHalfToItem` after `getHalfhalfSetupWithPrice`,
|
|
48
49
|
* - no `modifiers` are produced (selection structure isn't part of the
|
|
49
50
|
* simplified setup),
|
|
50
51
|
* - `sort_id` is not part of the payload, so it defaults to 0 (same as
|
|
51
52
|
* `convertHalfHalfToItem`).
|
|
52
53
|
*/
|
|
53
54
|
function convertSimplifiedHalfHalfToSimplifiedItem(halfhalfSetup) {
|
|
54
|
-
//
|
|
55
|
-
|
|
56
|
-
const
|
|
55
|
+
// Dollar/UI domain input (set at slice ingest) — normalize the minified
|
|
56
|
+
// shape only, no currency re-scaling (mirrors convertHalfHalfToItem).
|
|
57
|
+
const discount_amount = (0, minified_catalog_1.convertMinifiedPlatformNumToOriginalPlatformNum)(halfhalfSetup.discount_amount);
|
|
58
|
+
const item_special_hours = (0, minified_catalog_1.convertMinifiedSpecialHoursToOriginalSpecialHours)(halfhalfSetup.item_special_hours);
|
|
57
59
|
return {
|
|
58
60
|
sold_out: halfhalfSetup.sold_out,
|
|
59
61
|
is_discount_percentage: halfhalfSetup.is_discount_percentage,
|
|
@@ -11,10 +11,10 @@ export declare function convertSpecialsToSimplifiedSpecials(specials: ISpecial[]
|
|
|
11
11
|
* The simplified special payload carries only menu-list data — the
|
|
12
12
|
* modifier_specials selection structure is dropped — so this is a pure field
|
|
13
13
|
* mapping of what ISimplifiedCatalogItem can represent:
|
|
14
|
-
* -
|
|
15
|
-
*
|
|
16
|
-
* (
|
|
17
|
-
*
|
|
14
|
+
* - the simplified setup is already in the dollar/UI domain (converted at
|
|
15
|
+
* slice ingest via `getSimplifiedSpecialWithPrice`), so only the minified
|
|
16
|
+
* shape is normalized (scalar → `{ BASE_PRICE }`) — NO currency re-scaling,
|
|
17
|
+
* mirroring `convertSpecialToItem` after `getSpecialWithPrice`,
|
|
18
18
|
* - `tax_rate` is null (not part of the special payload, mirrors
|
|
19
19
|
* `convertSpecialToItem`),
|
|
20
20
|
* - no `modifiers` are produced (selection structure isn't part of the
|
|
@@ -43,21 +43,22 @@ function convertSpecialsToSimplifiedSpecials(specials, tenantId) {
|
|
|
43
43
|
* The simplified special payload carries only menu-list data — the
|
|
44
44
|
* modifier_specials selection structure is dropped — so this is a pure field
|
|
45
45
|
* mapping of what ISimplifiedCatalogItem can represent:
|
|
46
|
-
* -
|
|
47
|
-
*
|
|
48
|
-
* (
|
|
49
|
-
*
|
|
46
|
+
* - the simplified setup is already in the dollar/UI domain (converted at
|
|
47
|
+
* slice ingest via `getSimplifiedSpecialWithPrice`), so only the minified
|
|
48
|
+
* shape is normalized (scalar → `{ BASE_PRICE }`) — NO currency re-scaling,
|
|
49
|
+
* mirroring `convertSpecialToItem` after `getSpecialWithPrice`,
|
|
50
50
|
* - `tax_rate` is null (not part of the special payload, mirrors
|
|
51
51
|
* `convertSpecialToItem`),
|
|
52
52
|
* - no `modifiers` are produced (selection structure isn't part of the
|
|
53
53
|
* simplified setup).
|
|
54
54
|
*/
|
|
55
55
|
function convertSimplifiedSpecialToSimplifiedItem(special) {
|
|
56
|
-
//
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
const
|
|
56
|
+
// Dollar/UI domain input (set at slice ingest) — normalize the minified
|
|
57
|
+
// shape only, no currency re-scaling (mirrors convertSpecialToItem).
|
|
58
|
+
const price = (0, minified_catalog_1.convertMinifiedPlatformNumToOriginalPlatformNum)(special.price);
|
|
59
|
+
const discount_amount = (0, minified_catalog_1.convertMinifiedPlatformNumToOriginalPlatformNum)(special.discount_amount);
|
|
60
|
+
const item_special_hours = (0, minified_catalog_1.convertMinifiedSpecialHoursToOriginalSpecialHours)(special.item_special_hours);
|
|
61
|
+
const display_price = special.display_price ?? undefined;
|
|
61
62
|
return {
|
|
62
63
|
sold_out: special.sold_out,
|
|
63
64
|
is_discount_percentage: special.is_discount_percentage,
|
|
@@ -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
|
}));
|