@managesome/eposmatic-toolkit 0.4.44 → 0.4.46
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/esm/constants/MATERIALIZED_REPORTS.js +19 -9
- package/esm/helpers/materialized-reports/materialized-prep-time-classification-helpers.js +122 -31
- package/esm/helpers/materialized-reports/materialized-prep-time-compile-helpers.js +9 -7
- package/esm/helpers/materialized-reports/tenant-prep-time-formatter.js +5 -7
- package/esm/schemas/models/materialized_tenant_prep_time_entries.js +1 -1
- package/lib/constants/MATERIALIZED_REPORTS.d.ts +19 -9
- package/lib/constants/MATERIALIZED_REPORTS.js +19 -9
- package/lib/helpers/materialized-reports/materialized-prep-time-classification-helpers.d.ts +36 -3
- package/lib/helpers/materialized-reports/materialized-prep-time-classification-helpers.js +122 -31
- package/lib/helpers/materialized-reports/materialized-prep-time-compile-helpers.d.ts +9 -3
- package/lib/helpers/materialized-reports/materialized-prep-time-compile-helpers.js +9 -7
- package/lib/helpers/materialized-reports/tenant-prep-time-formatter.d.ts +1 -1
- package/lib/helpers/materialized-reports/tenant-prep-time-formatter.js +5 -7
- package/lib/schemas/models/materialized_tenant_prep_time_entries.js +1 -1
- package/lib/schemas/types/materialized_tenant_prep_time_entries.d.ts +4 -1
- package/lib/schemas/types/materialized_tenant_prep_time_reports.d.ts +9 -7
- package/lib/tests/materialized-reports/materialized-prep-time-classification.test.js +178 -23
- package/lib/tests/materialized-reports/materialized-prep-time-close-day.test.js +1 -2
- package/lib/tests/materialized-reports/materialized-prep-time-compile.test.js +35 -5
- package/lib/tests/materialized-reports/materialized-prep-time-constants.test.js +2 -1
- package/lib/tests/materialized-reports/materialized-prep-time-plan.test.js +1 -2
- package/lib/tests/materialized-reports/tenant-prep-time-formatter.test.js +2 -5
- package/package.json +1 -1
|
@@ -50,17 +50,17 @@ describe('mergeMaterializedPrepTimeCounters', () => {
|
|
|
50
50
|
source.duration.sum = 21;
|
|
51
51
|
source.duration.instant_count = 1;
|
|
52
52
|
source.duration.buckets['6-10'] = 3;
|
|
53
|
-
source.
|
|
54
|
-
source.
|
|
55
|
-
source.
|
|
53
|
+
source.target.on_time_count = 2;
|
|
54
|
+
source.target.late_count = 1;
|
|
55
|
+
source.target.delta_sum = -4;
|
|
56
56
|
(0, materialized_prep_time_compile_helpers_1.mergeMaterializedPrepTimeCounters)(target, source);
|
|
57
57
|
expect(target.coverage.item_count).toBe(5);
|
|
58
58
|
expect(target.coverage.own_anchor_count).toBe(3);
|
|
59
59
|
expect(target.duration.count).toBe(3);
|
|
60
60
|
expect(target.duration.sum).toBe(21);
|
|
61
61
|
expect(target.duration.buckets['6-10']).toBe(3);
|
|
62
|
-
expect(target.
|
|
63
|
-
expect(target.
|
|
62
|
+
expect(target.target.on_time_count).toBe(2);
|
|
63
|
+
expect(target.target.delta_sum).toBe(-4);
|
|
64
64
|
});
|
|
65
65
|
it('FOLDS min instead of summing it', () => {
|
|
66
66
|
const target = (0, materialized_prep_time_classification_helpers_1.freshMaterializedPrepTimeCounters)();
|
|
@@ -218,6 +218,36 @@ describe('compileTenantPrepTimeReports', () => {
|
|
|
218
218
|
expect(rows).toHaveLength(1);
|
|
219
219
|
expect(rows[0].anchor).toBe('MEASURED');
|
|
220
220
|
});
|
|
221
|
+
it('threads the tenant default and takeaway_time into the compiled target', () => {
|
|
222
|
+
// takeaway_time arrives in MILLISECONDS; 30_000 ms = 1 minute.
|
|
223
|
+
const result = compile([order()], { tenantDefaultMinutes: 0, tenantTakeawayTimeMs: 30000 });
|
|
224
|
+
const dateEntries = result.entries.find((doc) => doc.scope_context === 'localDate');
|
|
225
|
+
const row = dateEntries.prep_time_entries['COMPLETED:POS_WALK-IN'].rows[0];
|
|
226
|
+
expect(row.target_source).toBe('TAKEAWAY_TIME');
|
|
227
|
+
expect(row.target_at?.toISOString()).toBe('2026-09-13T09:56:00.000Z');
|
|
228
|
+
expect(row.delta_minutes).toBe(13);
|
|
229
|
+
const dateReport = result.reports.find((doc) => doc.scope_context === 'localDate');
|
|
230
|
+
const counters = dateReport.prep_time_counters['COMPLETED:POS_WALK-IN'];
|
|
231
|
+
expect(counters.target.default_baseline_count).toBe(1);
|
|
232
|
+
expect(counters.target.late_count).toBe(1);
|
|
233
|
+
expect(counters.target.delta_sum).toBe(13);
|
|
234
|
+
});
|
|
235
|
+
it('threads the dine-in prep target and the tenant default into the compiled counters', () => {
|
|
236
|
+
const dineIn = order({
|
|
237
|
+
platform: 'POS_DINE-IN',
|
|
238
|
+
dinein_details: { prep_minutes: 20 },
|
|
239
|
+
});
|
|
240
|
+
const result = compile([dineIn], { tenantDefaultMinutes: 15, tenantTakeawayTimeMs: 1800000 });
|
|
241
|
+
const dateEntries = result.entries.find((doc) => doc.scope_context === 'localDate');
|
|
242
|
+
const row = dateEntries.prep_time_entries['COMPLETED:POS_DINE-IN'].rows[0];
|
|
243
|
+
expect(row.target_source).toBe('DINE_IN_PREP');
|
|
244
|
+
expect(row.target_at?.toISOString()).toBe('2026-09-13T10:15:00.000Z');
|
|
245
|
+
const dateReport = result.reports.find((doc) => doc.scope_context === 'localDate');
|
|
246
|
+
const counters = dateReport.prep_time_counters['COMPLETED:POS_DINE-IN'];
|
|
247
|
+
expect(counters.target.default_baseline_count).toBe(1);
|
|
248
|
+
expect(counters.target.on_time_count).toBe(1);
|
|
249
|
+
expect(counters.target.delta_sum).toBe(-6);
|
|
250
|
+
});
|
|
221
251
|
it('rejects malformed input without throwing', () => {
|
|
222
252
|
expect((0, materialized_prep_time_compile_helpers_1.compileTenantPrepTimeReports)(null)).toBeNull();
|
|
223
253
|
expect((0, materialized_prep_time_compile_helpers_1.compileTenantPrepTimeReports)({
|
|
@@ -86,8 +86,9 @@ describe('prep time report constants (M2)', () => {
|
|
|
86
86
|
});
|
|
87
87
|
it('labels every on-time baseline and allows NONE (decision e2)', () => {
|
|
88
88
|
expect(MATERIALIZED_REPORTS_1.ALL_MATERIALIZED_PREP_TIME_TARGETS).toEqual([
|
|
89
|
-
MATERIALIZED_REPORTS_1.MATERIALIZED_PREP_TIME_TARGET_ENUM.
|
|
89
|
+
MATERIALIZED_REPORTS_1.MATERIALIZED_PREP_TIME_TARGET_ENUM.DINE_IN_PREP,
|
|
90
90
|
MATERIALIZED_REPORTS_1.MATERIALIZED_PREP_TIME_TARGET_ENUM.TENANT_DEFAULT,
|
|
91
|
+
MATERIALIZED_REPORTS_1.MATERIALIZED_PREP_TIME_TARGET_ENUM.TAKEAWAY_TIME,
|
|
91
92
|
MATERIALIZED_REPORTS_1.MATERIALIZED_PREP_TIME_TARGET_ENUM.NONE,
|
|
92
93
|
]);
|
|
93
94
|
});
|
|
@@ -22,8 +22,7 @@ const counter = (over = {}) => {
|
|
|
22
22
|
order_count: 0,
|
|
23
23
|
},
|
|
24
24
|
duration: { min: 0, max: 0, sum: 0, count: 0, instant_count: 0, buckets },
|
|
25
|
-
|
|
26
|
-
promise_set_count: 0,
|
|
25
|
+
target: {
|
|
27
26
|
default_baseline_count: 0,
|
|
28
27
|
on_time_count: 0,
|
|
29
28
|
late_count: 0,
|
|
@@ -166,8 +165,7 @@ describe('prep time formatter - promise and late', () => {
|
|
|
166
165
|
doc({
|
|
167
166
|
prep_time_counters: {
|
|
168
167
|
[KEY]: counter({
|
|
169
|
-
|
|
170
|
-
promise_set_count: 5,
|
|
168
|
+
target: {
|
|
171
169
|
default_baseline_count: 2,
|
|
172
170
|
on_time_count: 4,
|
|
173
171
|
late_count: 3,
|
|
@@ -180,7 +178,6 @@ describe('prep time formatter - promise and late', () => {
|
|
|
180
178
|
}),
|
|
181
179
|
]);
|
|
182
180
|
const summary = result[0][0].summary;
|
|
183
|
-
expect(summary.promise_baseline_count).toBe(5);
|
|
184
181
|
expect(summary.default_baseline_count).toBe(2);
|
|
185
182
|
expect(summary.unmeasurable_count).toBe(8);
|
|
186
183
|
expect(summary.on_time_count).toBe(4);
|