@managesome/eposmatic-toolkit 0.4.60 → 0.4.61
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 +177 -4
- package/esm/helpers/materialized-reports/index.js +7 -0
- package/esm/helpers/materialized-reports/materialized-day-readiness.js +2 -2
- package/esm/helpers/materialized-reports/materialized-dinein-accumulator-helpers.js +557 -0
- package/esm/helpers/materialized-reports/materialized-dinein-classification-helpers.js +447 -0
- package/esm/helpers/materialized-reports/materialized-dinein-close-day-helpers.js +372 -0
- package/esm/helpers/materialized-reports/materialized-dinein-compile-helpers.js +500 -0
- package/esm/helpers/materialized-reports/materialized-dinein-entry-pages.js +218 -0
- package/esm/helpers/materialized-reports/materialized-dinein-key-helpers.js +87 -0
- package/esm/helpers/materialized-reports/materialized-index-bootstrap.js +4 -0
- package/esm/helpers/materialized-reports/materialized-report-drilldown-rows.js +8 -0
- package/esm/helpers/materialized-reports/report-platform/definition.js +93 -1
- package/esm/helpers/materialized-reports/tenant-dinein-formatter.js +240 -0
- package/esm/helpers/reporting-contract/report-contract.js +3 -0
- package/esm/schemas/models/index.js +2 -0
- package/esm/schemas/models/materialized_tenant_dinein_entries.js +57 -0
- package/esm/schemas/models/materialized_tenant_dinein_reports.js +73 -0
- package/esm/schemas/types/index.js +2 -0
- package/esm/schemas/types/materialized_report_drilldown_rows.js +1 -0
- package/esm/schemas/types/materialized_tenant_dinein_entries.js +1 -0
- package/esm/schemas/types/materialized_tenant_dinein_reports.js +6 -0
- package/lib/constants/MATERIALIZED_REPORTS.d.ts +160 -4
- package/lib/constants/MATERIALIZED_REPORTS.js +178 -5
- package/lib/helpers/materialized-reports/index.d.ts +7 -0
- package/lib/helpers/materialized-reports/index.js +7 -0
- package/lib/helpers/materialized-reports/materialized-day-readiness.d.ts +1 -1
- package/lib/helpers/materialized-reports/materialized-day-readiness.js +2 -2
- package/lib/helpers/materialized-reports/materialized-dinein-accumulator-helpers.d.ts +67 -0
- package/lib/helpers/materialized-reports/materialized-dinein-accumulator-helpers.js +582 -0
- package/lib/helpers/materialized-reports/materialized-dinein-classification-helpers.d.ts +245 -0
- package/lib/helpers/materialized-reports/materialized-dinein-classification-helpers.js +469 -0
- package/lib/helpers/materialized-reports/materialized-dinein-close-day-helpers.d.ts +110 -0
- package/lib/helpers/materialized-reports/materialized-dinein-close-day-helpers.js +384 -0
- package/lib/helpers/materialized-reports/materialized-dinein-compile-helpers.d.ts +73 -0
- package/lib/helpers/materialized-reports/materialized-dinein-compile-helpers.js +504 -0
- package/lib/helpers/materialized-reports/materialized-dinein-entry-pages.d.ts +69 -0
- package/lib/helpers/materialized-reports/materialized-dinein-entry-pages.js +231 -0
- package/lib/helpers/materialized-reports/materialized-dinein-key-helpers.d.ts +44 -0
- package/lib/helpers/materialized-reports/materialized-dinein-key-helpers.js +96 -0
- package/lib/helpers/materialized-reports/materialized-index-bootstrap.js +4 -0
- package/lib/helpers/materialized-reports/materialized-report-drilldown-rows.js +8 -0
- package/lib/helpers/materialized-reports/report-platform/definition.js +92 -0
- package/lib/helpers/materialized-reports/tenant-dinein-formatter.d.ts +225 -0
- package/lib/helpers/materialized-reports/tenant-dinein-formatter.js +243 -0
- package/lib/helpers/reporting-contract/report-contract.d.ts +1 -0
- package/lib/helpers/reporting-contract/report-contract.js +3 -0
- package/lib/schemas/models/index.d.ts +2 -0
- package/lib/schemas/models/index.js +2 -0
- package/lib/schemas/models/materialized_tenant_day_readiness.d.ts +3 -3
- package/lib/schemas/models/materialized_tenant_dinein_entries.d.ts +100 -0
- package/lib/schemas/models/materialized_tenant_dinein_entries.js +60 -0
- package/lib/schemas/models/materialized_tenant_dinein_reports.d.ts +111 -0
- package/lib/schemas/models/materialized_tenant_dinein_reports.js +76 -0
- package/lib/schemas/types/index.d.ts +2 -0
- package/lib/schemas/types/index.js +2 -0
- package/lib/schemas/types/materialized_report_drilldown_rows.d.ts +1 -1
- package/lib/schemas/types/materialized_report_drilldown_rows.js +1 -0
- package/lib/schemas/types/materialized_tenant_dinein_entries.d.ts +127 -0
- package/lib/schemas/types/materialized_tenant_dinein_entries.js +2 -0
- package/lib/schemas/types/materialized_tenant_dinein_reports.d.ts +326 -0
- package/lib/schemas/types/materialized_tenant_dinein_reports.js +9 -0
- package/lib/tests/materialized-reports/dinein-fixtures.d.ts +29 -0
- package/lib/tests/materialized-reports/dinein-fixtures.js +130 -0
- package/lib/tests/materialized-reports/materialized-day-readiness.test.js +3 -2
- package/lib/tests/materialized-reports/materialized-dinein-compile.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-dinein-compile.test.js +807 -0
- package/lib/tests/materialized-reports/materialized-dinein-plan.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-dinein-plan.test.js +419 -0
- package/lib/tests/materialized-reports/materialized-tenant-dinein-schema.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-tenant-dinein-schema.test.js +185 -0
- package/lib/tests/materialized-reports/report-platform/registry-conformance.test.js +15 -2
- package/lib/tests/materialized-reports/tenant-dinein-formatter.test.d.ts +1 -0
- package/lib/tests/materialized-reports/tenant-dinein-formatter.test.js +299 -0
- package/package.json +1 -1
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import { DAY_INDEX_ENUM } from '../../constants/ENUMS';
|
|
2
|
+
import { MATERIALIZED_REPORT_KEY_FILTER_ENUM, MATERIALIZED_REPORT_SCOPE_ENUM } from '../../constants/MATERIALIZED_REPORTS';
|
|
3
|
+
/**
|
|
4
|
+
* Types for `materialized_tenant_dinein_reports`.
|
|
5
|
+
*
|
|
6
|
+
* ## What is counted
|
|
7
|
+
*
|
|
8
|
+
* Dine-in `orders` (`dinein_details != null`) for the order's OWN `localDate`.
|
|
9
|
+
* Split CHILDREN plus non-split dine-in orders are the collectable checks; the
|
|
10
|
+
* auto-deleted split PARENT contributes no sale and no order count. It is read
|
|
11
|
+
* only for rating/review discovery (a guest rates the visit once, and the rating
|
|
12
|
+
* may have been written on the parent before the split).
|
|
13
|
+
*
|
|
14
|
+
* ## Sales already include the service charge
|
|
15
|
+
*
|
|
16
|
+
* `amount_earned` is the net amount the store earned and already contains the
|
|
17
|
+
* service charge. `service_charge_amount` is therefore a COMPONENT of `sales`,
|
|
18
|
+
* published for the page — adding it to `sales` again would double-count it.
|
|
19
|
+
*
|
|
20
|
+
* ## Covers come from the TABLE-CLOSE fingerprint
|
|
21
|
+
*
|
|
22
|
+
* `covers` is the joined `dinein_tables_fingerprints.num_of_guests` of the
|
|
23
|
+
* check's settling session (the newest fingerprint of that check), never the
|
|
24
|
+
* order or split-child `num_of_guests`. A check that never got a fingerprint has
|
|
25
|
+
* no covers (never invented) and is reported as a coverage gap.
|
|
26
|
+
*
|
|
27
|
+
* ## Table sessions and occupancy
|
|
28
|
+
*
|
|
29
|
+
* One fingerprint is ONE table session:
|
|
30
|
+
* - start = `order.dinein_details.start_time`, falling back to `order.createdAt`
|
|
31
|
+
* when it is missing (counted separately in `fallback_occupancy_sessions`);
|
|
32
|
+
* - end = `fingerprint.createdAt` (the table close);
|
|
33
|
+
* - `occupancy_minutes_sum` is the seated time of the sessions that have a
|
|
34
|
+
* usable start AND end. A fingerprint with no end, or a negative duration, is
|
|
35
|
+
* skipped and reported as a coverage gap — never fabricated as 0.
|
|
36
|
+
*
|
|
37
|
+
* ## `tables_served` is a DAY-grain distinct count
|
|
38
|
+
*
|
|
39
|
+
* It is the number of DISTINCT tables served in the document's own scope. Folding
|
|
40
|
+
* day documents ADDS them, so at a period grain the stored counter is a
|
|
41
|
+
* "table-days" figure; the formatter exposes `tables_served_distinct` derived
|
|
42
|
+
* from the `by_table` keys, which is the true distinct count for the period.
|
|
43
|
+
*
|
|
44
|
+
* ## Courses have no call history
|
|
45
|
+
*
|
|
46
|
+
* `dinein_details.courses[].called` is the CURRENT state written by the
|
|
47
|
+
* receipt/cart layer; `has_already_been_called` is not stored on the order. The
|
|
48
|
+
* report therefore counts assigned / currently-called / currently-on-hold
|
|
49
|
+
* courses and stores NO call timestamp and NO call history.
|
|
50
|
+
*
|
|
51
|
+
* ## Money units
|
|
52
|
+
*
|
|
53
|
+
* Every money leaf is an integer number of CENTS (the source order amounts are
|
|
54
|
+
* already integer cents), every duration is integer MINUTES, and every derived
|
|
55
|
+
* average/rate is computed by the formatter and never stored.
|
|
56
|
+
*/
|
|
57
|
+
/** One row of the bounded `by_table` map. */
|
|
58
|
+
export interface IMaterializedDineinTableRow {
|
|
59
|
+
table_id: string;
|
|
60
|
+
table_name: string;
|
|
61
|
+
floor_id: string;
|
|
62
|
+
/** Checks whose `dinein_details.table_id` is this table (one attribution per check). */
|
|
63
|
+
orders: number;
|
|
64
|
+
/** Fingerprint sessions at this table (a moved check adds a session to each table). */
|
|
65
|
+
sessions: number;
|
|
66
|
+
/** Covers of the checks settled at this table (one attribution per check). */
|
|
67
|
+
covers: number;
|
|
68
|
+
/** Seated minutes of the sessions at this table. */
|
|
69
|
+
occupancy_minutes: number;
|
|
70
|
+
/** `amount_earned` of the checks settled at this table. */
|
|
71
|
+
sales: number;
|
|
72
|
+
}
|
|
73
|
+
/** One row of the bounded `by_floor` map. */
|
|
74
|
+
export interface IMaterializedDineinFloorRow {
|
|
75
|
+
floor_id: string;
|
|
76
|
+
/** Checks settled on this floor (one attribution per check). */
|
|
77
|
+
orders: number;
|
|
78
|
+
sessions: number;
|
|
79
|
+
covers: number;
|
|
80
|
+
occupancy_minutes: number;
|
|
81
|
+
sales: number;
|
|
82
|
+
}
|
|
83
|
+
/** One row of the bounded `by_course` map. */
|
|
84
|
+
export interface IMaterializedDineinCourseRow {
|
|
85
|
+
course_id: string;
|
|
86
|
+
name: string;
|
|
87
|
+
assigned: number;
|
|
88
|
+
called: number;
|
|
89
|
+
on_hold: number;
|
|
90
|
+
items: number;
|
|
91
|
+
}
|
|
92
|
+
/** One row of the `by_origin` map. */
|
|
93
|
+
export interface IMaterializedDineinOriginRow {
|
|
94
|
+
orders: number;
|
|
95
|
+
sales: number;
|
|
96
|
+
covers: number;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* One row of `by_status` / `by_platform`.
|
|
100
|
+
*
|
|
101
|
+
* The canonical shape is RICH: a breakdown is rendered with checks, covers and
|
|
102
|
+
* sales side by side, so a count-only map would force the page to re-query.
|
|
103
|
+
* These maps are additive and fold normally across days.
|
|
104
|
+
*/
|
|
105
|
+
export interface IMaterializedDineinBreakdownRow {
|
|
106
|
+
orders: number;
|
|
107
|
+
covers: number;
|
|
108
|
+
sales: number;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* One hour bucket of the reservation chart.
|
|
112
|
+
*
|
|
113
|
+
* Reservations have NO order link, so they never enter `dinein_counters` (which
|
|
114
|
+
* is keyed by `<ORDER_STATUS>:<PLATFORM>`) and never enter its `by_hour`. The
|
|
115
|
+
* reservation chart is folded from THIS map.
|
|
116
|
+
*/
|
|
117
|
+
export interface IMaterializedDineinReservationHourRow {
|
|
118
|
+
reservations: number;
|
|
119
|
+
reservation_covers: number;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* One bounded UPCOMING RESERVATION row.
|
|
123
|
+
*
|
|
124
|
+
* Privacy: the source holds a customer name/phone/email; this row carries NONE
|
|
125
|
+
* of them. `guest_label` is already masked by the writer (initials, or
|
|
126
|
+
* `Guest`), so the frontend has nothing to redact.
|
|
127
|
+
*/
|
|
128
|
+
export interface IMaterializedDineinUpcomingReservation {
|
|
129
|
+
reservation_id: string;
|
|
130
|
+
/** Server-masked display label — never a full customer name. */
|
|
131
|
+
guest_label: string;
|
|
132
|
+
/** ISO-8601 instant of the reservation slot. */
|
|
133
|
+
reservation_time: string;
|
|
134
|
+
/** Tenant-local hour (`0`..`23`) of the slot. */
|
|
135
|
+
local_hour: number;
|
|
136
|
+
party_size: number;
|
|
137
|
+
status: string;
|
|
138
|
+
/** `POS` | `WEB` | `APP` | … — the reservation source, or `UNKNOWN`. */
|
|
139
|
+
source: string;
|
|
140
|
+
/** `reservation_time - createdAt` minutes; null when it cannot be measured. */
|
|
141
|
+
lead_minutes: number | null;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* One bounded MOST-EDITED-CHECK row.
|
|
145
|
+
*
|
|
146
|
+
* `edits` is `iterations.length`; additions/removals are the line deltas from
|
|
147
|
+
* oldest -> current. No customer or review data is carried.
|
|
148
|
+
*/
|
|
149
|
+
export interface IMaterializedDineinTopEditedCheck {
|
|
150
|
+
order_id: string;
|
|
151
|
+
order_number: number | null;
|
|
152
|
+
table_id: string;
|
|
153
|
+
table_name: string;
|
|
154
|
+
floor_id: string;
|
|
155
|
+
edits: number;
|
|
156
|
+
item_additions: number;
|
|
157
|
+
item_removals: number;
|
|
158
|
+
covers: number;
|
|
159
|
+
/** `amount_earned` (cents). */
|
|
160
|
+
sales: number;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* One hour bucket of the sales/covers-by-hour chart. All three values are for
|
|
164
|
+
* the ORDER's tenant-local hour; an order without a usable local hour is not
|
|
165
|
+
* bucketed (never an invented hour) and still counts in the totals.
|
|
166
|
+
*/
|
|
167
|
+
export interface IMaterializedDineinHourRow {
|
|
168
|
+
orders: number;
|
|
169
|
+
sales: number;
|
|
170
|
+
covers: number;
|
|
171
|
+
}
|
|
172
|
+
/** One row of the `by_payment_type` map (collected amount, net of refunds). */
|
|
173
|
+
export interface IMaterializedDineinPaymentRow {
|
|
174
|
+
amount: number;
|
|
175
|
+
orders: number;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* The dine-in counters of ONE `<ORDER_STATUS>:<PLATFORM>` key.
|
|
179
|
+
*
|
|
180
|
+
* Every field is an integer. Averages / rates / shares are NOT stored.
|
|
181
|
+
*/
|
|
182
|
+
export interface IMaterializedDineinCounters {
|
|
183
|
+
orders: number;
|
|
184
|
+
completed_orders: number;
|
|
185
|
+
cancelled_orders: number;
|
|
186
|
+
covers: number;
|
|
187
|
+
items: number;
|
|
188
|
+
sales: number;
|
|
189
|
+
discounts: number;
|
|
190
|
+
tax: number;
|
|
191
|
+
tips: number;
|
|
192
|
+
service_charge_amount: number;
|
|
193
|
+
service_charge_taxable_amount: number;
|
|
194
|
+
surcharge_amount: number;
|
|
195
|
+
refunds: number;
|
|
196
|
+
tables_served: number;
|
|
197
|
+
table_sessions: number;
|
|
198
|
+
occupancy_minutes_sum: number;
|
|
199
|
+
/** Sessions measured from the REAL seated start (`dinein_details.start_time`). */
|
|
200
|
+
occupancy_sessions: number;
|
|
201
|
+
/** Sessions whose start had to fall back to `order.createdAt`. */
|
|
202
|
+
fallback_occupancy_sessions: number;
|
|
203
|
+
split_parents: number;
|
|
204
|
+
split_children: number;
|
|
205
|
+
/** Parent + child checks of every observed split group. */
|
|
206
|
+
split_checks: number;
|
|
207
|
+
split_sales: number;
|
|
208
|
+
/** Child counts by the parent's `split_type` (`UNKNOWN` when absent). */
|
|
209
|
+
split_type_counts: Record<string, number>;
|
|
210
|
+
offline_orders: number;
|
|
211
|
+
offline_sales: number;
|
|
212
|
+
/** Σ `by_origin[*].orders` — every counted check has an explicit origin bucket. */
|
|
213
|
+
origin_orders: number;
|
|
214
|
+
origin_sales: number;
|
|
215
|
+
origin_covers: number;
|
|
216
|
+
service_charge_orders: number;
|
|
217
|
+
service_charge_percentage_orders: number;
|
|
218
|
+
service_charge_fixed_orders: number;
|
|
219
|
+
service_charge_original_price_orders: number;
|
|
220
|
+
/** Checks by applied rate key: `<PCT|FIXED>:<rate>`. */
|
|
221
|
+
service_charge_rate_counts: Record<string, number>;
|
|
222
|
+
edited_orders: number;
|
|
223
|
+
total_edits: number;
|
|
224
|
+
item_additions: number;
|
|
225
|
+
item_removals: number;
|
|
226
|
+
net_item_change: number;
|
|
227
|
+
courses_assigned: number;
|
|
228
|
+
courses_called: number;
|
|
229
|
+
courses_on_hold: number;
|
|
230
|
+
course_items: number;
|
|
231
|
+
by_course: Record<string, IMaterializedDineinCourseRow>;
|
|
232
|
+
card_amount: number;
|
|
233
|
+
cash_amount: number;
|
|
234
|
+
other_amount: number;
|
|
235
|
+
card_orders: number;
|
|
236
|
+
cash_orders: number;
|
|
237
|
+
split_tender_orders: number;
|
|
238
|
+
by_payment_type: Record<string, IMaterializedDineinPaymentRow>;
|
|
239
|
+
rated_orders: number;
|
|
240
|
+
rating_sum: number;
|
|
241
|
+
rating_1: number;
|
|
242
|
+
rating_2: number;
|
|
243
|
+
rating_3: number;
|
|
244
|
+
rating_4: number;
|
|
245
|
+
rating_5: number;
|
|
246
|
+
review_count: number;
|
|
247
|
+
/** Sales / covers / checks by the ORDER's tenant-local hour (`"0"`..`"23"`). */
|
|
248
|
+
by_hour: Record<string, IMaterializedDineinHourRow>;
|
|
249
|
+
/** RICH breakdown: checks + covers + sales (cents) per order status. */
|
|
250
|
+
by_status: Record<string, IMaterializedDineinBreakdownRow>;
|
|
251
|
+
/** RICH breakdown: checks + covers + sales (cents) per platform. */
|
|
252
|
+
by_platform: Record<string, IMaterializedDineinBreakdownRow>;
|
|
253
|
+
by_origin: Record<string, IMaterializedDineinOriginRow>;
|
|
254
|
+
by_table: Record<string, IMaterializedDineinTableRow>;
|
|
255
|
+
by_floor: Record<string, IMaterializedDineinFloorRow>;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Reservation counters — a DOCUMENT-level block, never a key-level one.
|
|
259
|
+
*
|
|
260
|
+
* A reservation carries no order, so it cannot be attributed to an
|
|
261
|
+
* `<ORDER_STATUS>:<PLATFORM>` key. Keeping it at document level means an
|
|
262
|
+
* order-status/platform filter can never drop the reservation totals.
|
|
263
|
+
*
|
|
264
|
+
* There is no seated / no-show state in the reservation model, so the report
|
|
265
|
+
* publishes NO conversion / seated rate / no-show rate.
|
|
266
|
+
*/
|
|
267
|
+
export interface IMaterializedDineinReservationCounters {
|
|
268
|
+
reservations: number;
|
|
269
|
+
reservation_covers: number;
|
|
270
|
+
reservation_confirmed: number;
|
|
271
|
+
reservation_pending: number;
|
|
272
|
+
reservation_cancelled: number;
|
|
273
|
+
/** Σ (`reservation_time` − `createdAt`) minutes of reservations with a usable lead. */
|
|
274
|
+
reservation_lead_minutes_sum: number;
|
|
275
|
+
reservation_lead_count: number;
|
|
276
|
+
/** Σ `reservation_duration` minutes. */
|
|
277
|
+
reservation_duration_minutes_sum: number;
|
|
278
|
+
reservation_duration_count: number;
|
|
279
|
+
/**
|
|
280
|
+
* Booked covers by the reservation's TENANT-LOCAL hour: `"0"`..`"23"`, all
|
|
281
|
+
* initialized. It is never derived from order hours.
|
|
282
|
+
*/
|
|
283
|
+
by_hour: Record<string, IMaterializedDineinReservationHourRow>;
|
|
284
|
+
}
|
|
285
|
+
/** The declared key dimensions, in grammar order. */
|
|
286
|
+
export type TDineinKeyFilters = [
|
|
287
|
+
MATERIALIZED_REPORT_KEY_FILTER_ENUM.ORDER_STATUS,
|
|
288
|
+
MATERIALIZED_REPORT_KEY_FILTER_ENUM.PLATFORM
|
|
289
|
+
];
|
|
290
|
+
/** One counter row (`key` + its counters) — the shape the read aggregation folds. */
|
|
291
|
+
export interface IMaterializedDineinCounterRow {
|
|
292
|
+
key: string;
|
|
293
|
+
counters: IMaterializedDineinCounters;
|
|
294
|
+
}
|
|
295
|
+
/** One `materialized_tenant_dinein_reports` document (counters only). */
|
|
296
|
+
export interface IMaterializedTenantDineinReport {
|
|
297
|
+
_id: string;
|
|
298
|
+
tenant_id: string;
|
|
299
|
+
brand_id: string;
|
|
300
|
+
scope_context: MATERIALIZED_REPORT_SCOPE_ENUM;
|
|
301
|
+
scope_field: string;
|
|
302
|
+
/** Denormalized weekday — set on the DAY document, null on every period. */
|
|
303
|
+
day_index: DAY_INDEX_ENUM | null;
|
|
304
|
+
/** The dimensions the key encodes, in grammar order. */
|
|
305
|
+
sale_type_key_filters: TDineinKeyFilters;
|
|
306
|
+
/** Keyed by `<ORDER_STATUS>:<PLATFORM>`. */
|
|
307
|
+
dinein_counters: Record<string, IMaterializedDineinCounters>;
|
|
308
|
+
/** Reservation block — day-level, independent of the order key. */
|
|
309
|
+
reservation_counters: IMaterializedDineinReservationCounters;
|
|
310
|
+
/**
|
|
311
|
+
* Bounded, masked upcoming-reservation snapshot. A DAY document holds that
|
|
312
|
+
* day's top-N; a PERIOD document holds the re-ranked union of its days.
|
|
313
|
+
*/
|
|
314
|
+
upcoming_reservations?: IMaterializedDineinUpcomingReservation[] | null;
|
|
315
|
+
/** Bounded most-edited-check snapshot, merged the same way. */
|
|
316
|
+
top_edited_checks?: IMaterializedDineinTopEditedCheck[] | null;
|
|
317
|
+
/** Shared materialized-envelope field (structural version of THIS document). */
|
|
318
|
+
iteration?: number;
|
|
319
|
+
schema_version: number;
|
|
320
|
+
source_watermark: Date;
|
|
321
|
+
computed_at: Date;
|
|
322
|
+
createdAt: Date;
|
|
323
|
+
updatedAt: Date;
|
|
324
|
+
}
|
|
325
|
+
/** The default key-filter declaration of a dinein document. */
|
|
326
|
+
export declare const MATERIALIZED_DINEIN_REPORT_KEY_FILTERS: TDineinKeyFilters;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MATERIALIZED_DINEIN_REPORT_KEY_FILTERS = void 0;
|
|
4
|
+
const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
|
|
5
|
+
/** The default key-filter declaration of a dinein document. */
|
|
6
|
+
exports.MATERIALIZED_DINEIN_REPORT_KEY_FILTERS = [
|
|
7
|
+
MATERIALIZED_REPORTS_1.DINEIN_KEY_FILTERS[0],
|
|
8
|
+
MATERIALIZED_REPORTS_1.DINEIN_KEY_FILTERS[1],
|
|
9
|
+
];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { IDineinFingerprintSource, IDineinOrderSource, IDineinReservationSource } from '../../helpers/materialized-reports/materialized-dinein-classification-helpers';
|
|
2
|
+
import { IDineinDayCompileInput } from '../../helpers/materialized-reports/materialized-dinein-compile-helpers';
|
|
3
|
+
/**
|
|
4
|
+
* Shared fixtures for the Dinein suite.
|
|
5
|
+
*
|
|
6
|
+
* All money is integer CENTS, all durations are integer MINUTES, and the local
|
|
7
|
+
* times are explicit — a test that needs `localHour` sets it, so the compiler is
|
|
8
|
+
* never fed a server-clock guess.
|
|
9
|
+
*/
|
|
10
|
+
export declare const DINEIN_TENANT = "tenant-dinein";
|
|
11
|
+
export declare const DINEIN_BRAND = "brand-dinein";
|
|
12
|
+
export declare const DINEIN_DAY = "2026-10-01";
|
|
13
|
+
export type IOrderOverrides = Partial<IDineinOrderSource> & {
|
|
14
|
+
_id?: string;
|
|
15
|
+
};
|
|
16
|
+
/** A complete, valid non-split dine-in check. */
|
|
17
|
+
export declare function dineinOrder(overrides?: IOrderOverrides): IDineinOrderSource;
|
|
18
|
+
/** A table-close fingerprint joined to `orderId`. */
|
|
19
|
+
export declare function dineinFingerprint(orderId: string, overrides?: Partial<IDineinFingerprintSource>): IDineinFingerprintSource;
|
|
20
|
+
/** A reservation for the day. */
|
|
21
|
+
export declare function dineinReservation(overrides?: Partial<IDineinReservationSource>): IDineinReservationSource;
|
|
22
|
+
/** Compiles a day with the suite's tenant/brand/day defaults. */
|
|
23
|
+
export declare function compileDay(overrides?: Partial<IDineinDayCompileInput>): import("../../helpers/materialized-reports/materialized-dinein-compile-helpers").IDineinDayCompileResult | null;
|
|
24
|
+
/** The single counters block of a compiled day (fails loudly when absent). */
|
|
25
|
+
export declare function countersOfDay(result: ReturnType<typeof compileDay>, key: string): import("../..").IMaterializedDineinCounters;
|
|
26
|
+
/** The single entry page of one scope. */
|
|
27
|
+
export declare function entryPageOfDay(result: ReturnType<typeof compileDay>, scope: string): import("../..").IMaterializedTenantDineinEntry | undefined;
|
|
28
|
+
/** Every entry row of the DAY page (the period pages store the same rows). */
|
|
29
|
+
export declare function entryRowsOfDay(result: ReturnType<typeof compileDay>): any[];
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DINEIN_DAY = exports.DINEIN_BRAND = exports.DINEIN_TENANT = void 0;
|
|
4
|
+
exports.dineinOrder = dineinOrder;
|
|
5
|
+
exports.dineinFingerprint = dineinFingerprint;
|
|
6
|
+
exports.dineinReservation = dineinReservation;
|
|
7
|
+
exports.compileDay = compileDay;
|
|
8
|
+
exports.countersOfDay = countersOfDay;
|
|
9
|
+
exports.entryPageOfDay = entryPageOfDay;
|
|
10
|
+
exports.entryRowsOfDay = entryRowsOfDay;
|
|
11
|
+
const materialized_dinein_compile_helpers_1 = require("../../helpers/materialized-reports/materialized-dinein-compile-helpers");
|
|
12
|
+
/**
|
|
13
|
+
* Shared fixtures for the Dinein suite.
|
|
14
|
+
*
|
|
15
|
+
* All money is integer CENTS, all durations are integer MINUTES, and the local
|
|
16
|
+
* times are explicit — a test that needs `localHour` sets it, so the compiler is
|
|
17
|
+
* never fed a server-clock guess.
|
|
18
|
+
*/
|
|
19
|
+
exports.DINEIN_TENANT = 'tenant-dinein';
|
|
20
|
+
exports.DINEIN_BRAND = 'brand-dinein';
|
|
21
|
+
exports.DINEIN_DAY = '2026-10-01';
|
|
22
|
+
let sequence = 0;
|
|
23
|
+
const nextId = (prefix) => prefix + '-' + String((sequence += 1)).padStart(4, '0');
|
|
24
|
+
/** A complete, valid non-split dine-in check. */
|
|
25
|
+
function dineinOrder(overrides = {}) {
|
|
26
|
+
const id = overrides._id ?? nextId('order');
|
|
27
|
+
return {
|
|
28
|
+
_id: id,
|
|
29
|
+
tenant_id: exports.DINEIN_TENANT,
|
|
30
|
+
order_number: 2418,
|
|
31
|
+
localDate: exports.DINEIN_DAY,
|
|
32
|
+
localHour: 18,
|
|
33
|
+
platform: 'POS_DINE-IN',
|
|
34
|
+
order_status: 'COMPLETED',
|
|
35
|
+
createdAt: '2026-10-01T13:00:00.000Z',
|
|
36
|
+
updatedAt: '2026-10-01T13:35:00.000Z',
|
|
37
|
+
is_deleted: false,
|
|
38
|
+
delete_reason: null,
|
|
39
|
+
split_parent_id: null,
|
|
40
|
+
split_child_ids: null,
|
|
41
|
+
split_type: null,
|
|
42
|
+
synced_offline: false,
|
|
43
|
+
rating: null,
|
|
44
|
+
review: null,
|
|
45
|
+
amount_earned: 21400,
|
|
46
|
+
tip_amount: 0,
|
|
47
|
+
tax_amount: 1400,
|
|
48
|
+
total_discount_applied: 0,
|
|
49
|
+
surcharge_amount: 0,
|
|
50
|
+
service_fee: null,
|
|
51
|
+
service_fee_amount: 0,
|
|
52
|
+
is_service_fee_percentage: false,
|
|
53
|
+
is_service_fee_taxable: false,
|
|
54
|
+
apply_service_fee_on_original_price: false,
|
|
55
|
+
categories: [{ items: [{ _id: 'line-a', item_id: 'item-a', quantity: 2 }] }],
|
|
56
|
+
payments: [],
|
|
57
|
+
iterations: [],
|
|
58
|
+
dinein_details: {
|
|
59
|
+
table_id: 'table-t04',
|
|
60
|
+
table_name: 'T-04',
|
|
61
|
+
floor_id: 'floor-main',
|
|
62
|
+
start_time: '2026-10-01T13:00:00.000Z',
|
|
63
|
+
courses: null,
|
|
64
|
+
},
|
|
65
|
+
consumer: { phone: '' },
|
|
66
|
+
staff_details: null,
|
|
67
|
+
order_taker_details: null,
|
|
68
|
+
...overrides,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/** A table-close fingerprint joined to `orderId`. */
|
|
72
|
+
function dineinFingerprint(orderId, overrides = {}) {
|
|
73
|
+
return {
|
|
74
|
+
_id: overrides._id ?? nextId('fingerprint'),
|
|
75
|
+
tenant_id: exports.DINEIN_TENANT,
|
|
76
|
+
order_id: orderId,
|
|
77
|
+
table_id: 'table-t04',
|
|
78
|
+
name: 'T-04',
|
|
79
|
+
dinein_floor_id: 'floor-main',
|
|
80
|
+
num_of_guests: 4,
|
|
81
|
+
createdAt: '2026-10-01T13:35:00.000Z',
|
|
82
|
+
updatedAt: '2026-10-01T13:35:00.000Z',
|
|
83
|
+
...overrides,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/** A reservation for the day. */
|
|
87
|
+
function dineinReservation(overrides = {}) {
|
|
88
|
+
return {
|
|
89
|
+
_id: overrides._id ?? nextId('reservation'),
|
|
90
|
+
tenant_id: exports.DINEIN_TENANT,
|
|
91
|
+
reservation_time: '2026-10-01T18:30:00.000Z',
|
|
92
|
+
reservation_duration: 90,
|
|
93
|
+
num_of_guests: 4,
|
|
94
|
+
reservation_status: 'CONFIRMED',
|
|
95
|
+
createdAt: '2026-10-01T08:30:00.000Z',
|
|
96
|
+
updatedAt: '2026-10-01T08:30:00.000Z',
|
|
97
|
+
source_local_date: exports.DINEIN_DAY,
|
|
98
|
+
...overrides,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/** Compiles a day with the suite's tenant/brand/day defaults. */
|
|
102
|
+
function compileDay(overrides = {}) {
|
|
103
|
+
return (0, materialized_dinein_compile_helpers_1.compileTenantDineinReports)({
|
|
104
|
+
tenantId: exports.DINEIN_TENANT,
|
|
105
|
+
brandId: exports.DINEIN_BRAND,
|
|
106
|
+
localDate: exports.DINEIN_DAY,
|
|
107
|
+
computedAt: new Date('2026-10-01T23:00:00.000Z'),
|
|
108
|
+
...overrides,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
/** The single counters block of a compiled day (fails loudly when absent). */
|
|
112
|
+
function countersOfDay(result, key) {
|
|
113
|
+
const counters = result?.reports?.[0]?.dinein_counters?.[key];
|
|
114
|
+
if (counters == null)
|
|
115
|
+
throw new Error('missing counter block for key ' + key);
|
|
116
|
+
return counters;
|
|
117
|
+
}
|
|
118
|
+
/** The single entry page of one scope. */
|
|
119
|
+
function entryPageOfDay(result, scope) {
|
|
120
|
+
return (result?.entries ?? []).find((entry) => String(entry.scope_context) === scope);
|
|
121
|
+
}
|
|
122
|
+
/** Every entry row of the DAY page (the period pages store the same rows). */
|
|
123
|
+
function entryRowsOfDay(result) {
|
|
124
|
+
const day = entryPageOfDay(result, 'localDate');
|
|
125
|
+
const rows = [];
|
|
126
|
+
for (const section of Object.values(day?.dinein_entries ?? {})) {
|
|
127
|
+
rows.push(...(section.rows ?? []));
|
|
128
|
+
}
|
|
129
|
+
return rows;
|
|
130
|
+
}
|
|
@@ -12,13 +12,14 @@ const record = (over = {}) => ({
|
|
|
12
12
|
...over,
|
|
13
13
|
});
|
|
14
14
|
describe('materialized day readiness contract', () => {
|
|
15
|
-
it('covers exactly the
|
|
15
|
+
it('covers exactly the six production writers', () => {
|
|
16
16
|
expect([...MATERIALIZED_REPORTS_1.MATERIALIZED_READINESS_REPORT_KEYS].sort()).toEqual([
|
|
17
17
|
report_contract_1.REPORT_KEY_ENUM.OVERVIEW,
|
|
18
18
|
report_contract_1.REPORT_KEY_ENUM.DISCOUNTS,
|
|
19
19
|
report_contract_1.REPORT_KEY_ENUM.PREP_TIME,
|
|
20
20
|
report_contract_1.REPORT_KEY_ENUM.DELIVERY,
|
|
21
21
|
report_contract_1.REPORT_KEY_ENUM.DIALER,
|
|
22
|
+
report_contract_1.REPORT_KEY_ENUM.DINEIN,
|
|
22
23
|
].sort());
|
|
23
24
|
for (const key of MATERIALIZED_REPORTS_1.MATERIALIZED_READINESS_REPORT_KEYS) {
|
|
24
25
|
expect((0, materialized_day_readiness_1.isMaterializedReadinessReportKey)(key)).toBe(true);
|
|
@@ -59,6 +60,6 @@ describe('materialized day readiness contract', () => {
|
|
|
59
60
|
status: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_READINESS_STATUS_ENUM.COMMITTED,
|
|
60
61
|
runId: 'run-1',
|
|
61
62
|
committedAt: new Date(),
|
|
62
|
-
})).toThrow(/outside the
|
|
63
|
+
})).toThrow(/outside the six report readiness contract/);
|
|
63
64
|
});
|
|
64
65
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|