@managesome/eposmatic-toolkit 0.4.14 → 0.4.16

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.
Files changed (137) hide show
  1. package/esm/helpers/materialized-reports/index.js +1 -0
  2. package/esm/helpers/materialized-reports/materialized-report-drilldown-rows.js +162 -0
  3. package/esm/helpers/reporting-contract/report-contract.js +1 -0
  4. package/esm/schemas/models/index.js +1 -1
  5. package/esm/schemas/models/materialized_report_drilldown_rows.js +155 -0
  6. package/esm/schemas/types/index.js +1 -1
  7. package/esm/schemas/types/materialized_report_drilldown_rows.js +10 -0
  8. package/lib/helpers/materialized-reports/index.d.ts +1 -0
  9. package/lib/helpers/materialized-reports/index.js +1 -0
  10. package/lib/helpers/materialized-reports/materialized-report-drilldown-rows.d.ts +40 -0
  11. package/lib/helpers/materialized-reports/materialized-report-drilldown-rows.js +169 -0
  12. package/lib/helpers/reporting-contract/report-contract.d.ts +3 -0
  13. package/lib/helpers/reporting-contract/report-contract.js +1 -0
  14. package/lib/schemas/models/brands.d.ts +6 -6
  15. package/lib/schemas/models/categories.d.ts +6 -6
  16. package/lib/schemas/models/close_dates.d.ts +3 -3
  17. package/lib/schemas/models/courses.d.ts +3 -3
  18. package/lib/schemas/models/customer_redemptions.d.ts +3 -3
  19. package/lib/schemas/models/customers.d.ts +6 -6
  20. package/lib/schemas/models/deliveries.d.ts +9 -9
  21. package/lib/schemas/models/delivery_areas.d.ts +3 -3
  22. package/lib/schemas/models/dinein_floors.d.ts +3 -3
  23. package/lib/schemas/models/dinein_tables.d.ts +6 -6
  24. package/lib/schemas/models/dinein_tables_fingerprints.d.ts +9 -9
  25. package/lib/schemas/models/discounts.d.ts +27 -27
  26. package/lib/schemas/models/expense_categories.d.ts +3 -3
  27. package/lib/schemas/models/expense_details.d.ts +12 -12
  28. package/lib/schemas/models/gift_cards.d.ts +3 -3
  29. package/lib/schemas/models/halfhalf_setup.d.ts +153 -153
  30. package/lib/schemas/models/index.d.ts +1 -1
  31. package/lib/schemas/models/index.js +1 -1
  32. package/lib/schemas/models/internal_invoices.d.ts +3 -3
  33. package/lib/schemas/models/internal_staffs.d.ts +3 -3
  34. package/lib/schemas/models/inventories.d.ts +6 -6
  35. package/lib/schemas/models/inventory_categories.d.ts +3 -3
  36. package/lib/schemas/models/inventory_transactions.d.ts +9 -9
  37. package/lib/schemas/models/item_transactions.d.ts +9 -9
  38. package/lib/schemas/models/items.d.ts +216 -216
  39. package/lib/schemas/models/marketing_fingerprints.d.ts +9 -9
  40. package/lib/schemas/models/materialized_credit_bills.d.ts +21 -21
  41. package/lib/schemas/models/materialized_report_drilldown_rows.d.ts +130 -0
  42. package/lib/schemas/models/materialized_report_drilldown_rows.js +158 -0
  43. package/lib/schemas/models/materialized_tenant_cash_entries.d.ts +9 -9
  44. package/lib/schemas/models/materialized_tenant_cash_reports.d.ts +3 -3
  45. package/lib/schemas/models/materialized_tenant_delivery_entries.d.ts +3 -3
  46. package/lib/schemas/models/materialized_tenant_delivery_reports.d.ts +3 -3
  47. package/lib/schemas/models/materialized_tenant_discount_entries.d.ts +24 -24
  48. package/lib/schemas/models/materialized_tenant_discount_reports.d.ts +3 -3
  49. package/lib/schemas/models/materialized_tenant_hourly_comparison_entries.d.ts +3 -3
  50. package/lib/schemas/models/materialized_tenant_hourly_comparison_reports.d.ts +3 -3
  51. package/lib/schemas/models/materialized_tenant_payments_comparison_entries.d.ts +3 -3
  52. package/lib/schemas/models/materialized_tenant_payments_comparison_reports.d.ts +3 -3
  53. package/lib/schemas/models/materialized_tenant_prep_time_entries.d.ts +12 -12
  54. package/lib/schemas/models/materialized_tenant_prep_time_reports.d.ts +3 -3
  55. package/lib/schemas/models/materialized_tenant_reports_iterations.d.ts +3 -3
  56. package/lib/schemas/models/materialized_tenant_sales_comparison_entries.d.ts +9 -9
  57. package/lib/schemas/models/materialized_tenant_sales_comparison_reports.d.ts +3 -3
  58. package/lib/schemas/models/materialized_tenant_sales_overview_reports.d.ts +3 -3
  59. package/lib/schemas/models/menus.d.ts +21 -21
  60. package/lib/schemas/models/modifier_extras.d.ts +3 -3
  61. package/lib/schemas/models/offers.d.ts +24 -24
  62. package/lib/schemas/models/offers_fingerprints.d.ts +9 -9
  63. package/lib/schemas/models/operational_roles.d.ts +3 -3
  64. package/lib/schemas/models/orders.d.ts +18 -18
  65. package/lib/schemas/models/printer_settings.d.ts +3 -3
  66. package/lib/schemas/models/public_holidays.d.ts +3 -3
  67. package/lib/schemas/models/reservations.d.ts +6 -6
  68. package/lib/schemas/models/reviews.d.ts +12 -12
  69. package/lib/schemas/models/riders.d.ts +3 -3
  70. package/lib/schemas/models/specials.d.ts +48 -48
  71. package/lib/schemas/models/staff_shifts.d.ts +9 -9
  72. package/lib/schemas/models/tenant-activity-logs.d.ts +3 -3
  73. package/lib/schemas/models/tenant_active_jobs.d.ts +3 -3
  74. package/lib/schemas/models/tenant_calendar.d.ts +3 -3
  75. package/lib/schemas/models/tenant_cash_drawer_sessions.d.ts +36 -36
  76. package/lib/schemas/models/tenant_cash_drawers.d.ts +3 -3
  77. package/lib/schemas/models/tenant_cash_in_hand_transactions.d.ts +9 -9
  78. package/lib/schemas/models/tenant_cash_in_out.d.ts +9 -9
  79. package/lib/schemas/models/tenant_clients.d.ts +3 -3
  80. package/lib/schemas/models/tenant_day_sessions.d.ts +36 -36
  81. package/lib/schemas/models/tenant_hr_attendance_records.d.ts +3 -3
  82. package/lib/schemas/models/tenant_hr_biometric_enrollments.d.ts +3 -3
  83. package/lib/schemas/models/tenant_hr_departments.d.ts +3 -3
  84. package/lib/schemas/models/tenant_hr_documents.d.ts +3 -3
  85. package/lib/schemas/models/tenant_hr_employees.d.ts +24 -24
  86. package/lib/schemas/models/tenant_hr_leave_requests.d.ts +6 -6
  87. package/lib/schemas/models/tenant_hr_payrolls.d.ts +3 -3
  88. package/lib/schemas/models/tenant_hr_performance_reviews.d.ts +3 -3
  89. package/lib/schemas/models/tenant_hr_policies.d.ts +3 -3
  90. package/lib/schemas/models/tenant_hr_positions.d.ts +3 -3
  91. package/lib/schemas/models/tenant_hr_shift_schedules.d.ts +3 -3
  92. package/lib/schemas/models/tenant_hr_shifts.d.ts +3 -3
  93. package/lib/schemas/models/tenant_instore_shift_sessions.d.ts +36 -36
  94. package/lib/schemas/models/tenant_instore_shifts.d.ts +3 -3
  95. package/lib/schemas/models/tenant_inventory_department_transactions.d.ts +9 -9
  96. package/lib/schemas/models/tenant_inventory_department_utilities.d.ts +6 -6
  97. package/lib/schemas/models/tenant_inventory_departments.d.ts +6 -6
  98. package/lib/schemas/models/tenant_inventory_entries.d.ts +3 -3
  99. package/lib/schemas/models/tenant_metadata.d.ts +3 -3
  100. package/lib/schemas/models/tenant_order_item_instructions.d.ts +3 -3
  101. package/lib/schemas/models/tenant_purchase_order_vendor_returns.d.ts +6 -6
  102. package/lib/schemas/models/tenant_purchase_orders.d.ts +6 -6
  103. package/lib/schemas/models/tenant_shifts.d.ts +3 -3
  104. package/lib/schemas/models/tenant_staffs.d.ts +24 -24
  105. package/lib/schemas/models/tenant_vendors.d.ts +3 -3
  106. package/lib/schemas/models/tenants.d.ts +3 -3
  107. package/lib/schemas/models/terminal_devices.d.ts +3 -3
  108. package/lib/schemas/models/tokens.d.ts +9 -9
  109. package/lib/schemas/models/void_order_items.d.ts +27 -27
  110. package/lib/schemas/models/vouchers.d.ts +3 -3
  111. package/lib/schemas/models/wallet_transactions.d.ts +9 -9
  112. package/lib/schemas/models/wallets.d.ts +3 -3
  113. package/lib/schemas/models/warehouse_categories.d.ts +3 -3
  114. package/lib/schemas/models/warehouse_communications.d.ts +3 -3
  115. package/lib/schemas/models/warehouse_inventory_transactions.d.ts +6 -6
  116. package/lib/schemas/models/warehouse_item_transactions.d.ts +6 -6
  117. package/lib/schemas/models/warehouse_items.d.ts +3 -3
  118. package/lib/schemas/models/warehouse_purchase_order_receipts.d.ts +3 -3
  119. package/lib/schemas/models/warehouse_purchase_order_rfqs.d.ts +3 -3
  120. package/lib/schemas/models/warehouse_purchase_order_vendor_returns.d.ts +3 -3
  121. package/lib/schemas/models/warehouse_purchase_orders.d.ts +3 -3
  122. package/lib/schemas/models/warehouse_sale_deliveries.d.ts +3 -3
  123. package/lib/schemas/models/warehouse_sale_invoices.d.ts +3 -3
  124. package/lib/schemas/models/warehouse_sale_order_rfqs.d.ts +3 -3
  125. package/lib/schemas/models/warehouse_sale_orders.d.ts +3 -3
  126. package/lib/schemas/models/warehouse_staffs.d.ts +3 -3
  127. package/lib/schemas/models/warehouse_void_purchase_order_items.d.ts +21 -21
  128. package/lib/schemas/models/warehouse_void_sale_order_items.d.ts +21 -21
  129. package/lib/schemas/models/warehouses.d.ts +3 -3
  130. package/lib/schemas/types/index.d.ts +1 -1
  131. package/lib/schemas/types/index.js +1 -1
  132. package/lib/schemas/types/materialized_report_drilldown_rows.d.ts +64 -0
  133. package/lib/schemas/types/materialized_report_drilldown_rows.js +13 -0
  134. package/lib/tests/materialized-reports/materialized-report-drilldown-rows.test.d.ts +1 -0
  135. package/lib/tests/materialized-reports/materialized-report-drilldown-rows.test.js +143 -0
  136. package/lib/tests/reporting-contract.test.js +7 -0
  137. package/package.json +1 -1
@@ -10,13 +10,13 @@ export declare const MarketingFingerprintSchema: Schema<any, import("mongoose").
10
10
  message: string;
11
11
  _id: import("mongoose").Types.ObjectId;
12
12
  type: import("../../constants").MARKETING_TYPE_ENUM;
13
- tenant_id: string;
14
- order_id: import("mongoose").Types.ObjectId;
15
- createdAt_mins: number;
16
13
  createdAt: NativeDate;
17
14
  updatedAt: NativeDate;
18
15
  description: string;
16
+ tenant_id: string;
19
17
  customer_phone: string;
18
+ createdAt_mins: number;
19
+ order_id: import("mongoose").Types.ObjectId;
20
20
  intent: string;
21
21
  cost: number;
22
22
  image_url?: string | null | undefined;
@@ -27,13 +27,13 @@ export declare const MarketingFingerprintSchema: Schema<any, import("mongoose").
27
27
  message: string;
28
28
  _id: import("mongoose").Types.ObjectId;
29
29
  type: import("../../constants").MARKETING_TYPE_ENUM;
30
- tenant_id: string;
31
- order_id: import("mongoose").Types.ObjectId;
32
- createdAt_mins: number;
33
30
  createdAt: NativeDate;
34
31
  updatedAt: NativeDate;
35
32
  description: string;
33
+ tenant_id: string;
36
34
  customer_phone: string;
35
+ createdAt_mins: number;
36
+ order_id: import("mongoose").Types.ObjectId;
37
37
  intent: string;
38
38
  cost: number;
39
39
  image_url?: string | null | undefined;
@@ -44,13 +44,13 @@ export declare const MarketingFingerprintSchema: Schema<any, import("mongoose").
44
44
  message: string;
45
45
  _id: import("mongoose").Types.ObjectId;
46
46
  type: import("../../constants").MARKETING_TYPE_ENUM;
47
- tenant_id: string;
48
- order_id: import("mongoose").Types.ObjectId;
49
- createdAt_mins: number;
50
47
  createdAt: NativeDate;
51
48
  updatedAt: NativeDate;
52
49
  description: string;
50
+ tenant_id: string;
53
51
  customer_phone: string;
52
+ createdAt_mins: number;
53
+ order_id: import("mongoose").Types.ObjectId;
54
54
  intent: string;
55
55
  cost: number;
56
56
  image_url?: string | null | undefined;
@@ -27,10 +27,10 @@ export declare const MaterializedTenantCreditBillsReportSchema: Schema<any, impo
27
27
  updatedAt: NativeDate;
28
28
  } & {
29
29
  _id: import("mongoose").Types.ObjectId;
30
- tenant_id: string;
31
30
  createdAt: NativeDate;
32
31
  updatedAt: NativeDate;
33
32
  brand_id: string;
33
+ tenant_id: string;
34
34
  day_index: import("../../constants/ENUMS").DAY_INDEX_ENUM | null;
35
35
  iteration: number;
36
36
  scope_context: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_REPORT_SCOPE_ENUM;
@@ -38,8 +38,8 @@ export declare const MaterializedTenantCreditBillsReportSchema: Schema<any, impo
38
38
  sale_type_key_filters: string[];
39
39
  credit_bills: Map<string, {
40
40
  issued: import("mongoose").Types.DocumentArray<{
41
- order_id: string;
42
41
  payment_id: string;
42
+ order_id: string;
43
43
  amount: number;
44
44
  issued_at: NativeDate;
45
45
  issued_local_hour: string;
@@ -49,8 +49,8 @@ export declare const MaterializedTenantCreditBillsReportSchema: Schema<any, impo
49
49
  settled_local_date: string;
50
50
  credit_note: string;
51
51
  }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
52
- order_id: string;
53
52
  payment_id: string;
53
+ order_id: string;
54
54
  amount: number;
55
55
  issued_at: NativeDate;
56
56
  issued_local_hour: string;
@@ -60,8 +60,8 @@ export declare const MaterializedTenantCreditBillsReportSchema: Schema<any, impo
60
60
  settled_local_date: string;
61
61
  credit_note: string;
62
62
  }> & {
63
- order_id: string;
64
63
  payment_id: string;
64
+ order_id: string;
65
65
  amount: number;
66
66
  issued_at: NativeDate;
67
67
  issued_local_hour: string;
@@ -72,8 +72,8 @@ export declare const MaterializedTenantCreditBillsReportSchema: Schema<any, impo
72
72
  credit_note: string;
73
73
  }>;
74
74
  received: import("mongoose").Types.DocumentArray<{
75
- order_id: string;
76
75
  payment_id: string;
76
+ order_id: string;
77
77
  amount: number;
78
78
  received_at: NativeDate;
79
79
  received_amount: number;
@@ -83,8 +83,8 @@ export declare const MaterializedTenantCreditBillsReportSchema: Schema<any, impo
83
83
  event_local_hour: string;
84
84
  issued_local_date: string;
85
85
  }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
86
- order_id: string;
87
86
  payment_id: string;
87
+ order_id: string;
88
88
  amount: number;
89
89
  received_at: NativeDate;
90
90
  received_amount: number;
@@ -94,8 +94,8 @@ export declare const MaterializedTenantCreditBillsReportSchema: Schema<any, impo
94
94
  event_local_hour: string;
95
95
  issued_local_date: string;
96
96
  }> & {
97
- order_id: string;
98
97
  payment_id: string;
98
+ order_id: string;
99
99
  amount: number;
100
100
  received_at: NativeDate;
101
101
  received_amount: number;
@@ -114,10 +114,10 @@ export declare const MaterializedTenantCreditBillsReportSchema: Schema<any, impo
114
114
  updatedAt: NativeDate;
115
115
  } & {
116
116
  _id: import("mongoose").Types.ObjectId;
117
- tenant_id: string;
118
117
  createdAt: NativeDate;
119
118
  updatedAt: NativeDate;
120
119
  brand_id: string;
120
+ tenant_id: string;
121
121
  day_index: import("../../constants/ENUMS").DAY_INDEX_ENUM | null;
122
122
  iteration: number;
123
123
  scope_context: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_REPORT_SCOPE_ENUM;
@@ -125,8 +125,8 @@ export declare const MaterializedTenantCreditBillsReportSchema: Schema<any, impo
125
125
  sale_type_key_filters: string[];
126
126
  credit_bills: Map<string, {
127
127
  issued: import("mongoose").Types.DocumentArray<{
128
- order_id: string;
129
128
  payment_id: string;
129
+ order_id: string;
130
130
  amount: number;
131
131
  issued_at: NativeDate;
132
132
  issued_local_hour: string;
@@ -136,8 +136,8 @@ export declare const MaterializedTenantCreditBillsReportSchema: Schema<any, impo
136
136
  settled_local_date: string;
137
137
  credit_note: string;
138
138
  }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
139
- order_id: string;
140
139
  payment_id: string;
140
+ order_id: string;
141
141
  amount: number;
142
142
  issued_at: NativeDate;
143
143
  issued_local_hour: string;
@@ -147,8 +147,8 @@ export declare const MaterializedTenantCreditBillsReportSchema: Schema<any, impo
147
147
  settled_local_date: string;
148
148
  credit_note: string;
149
149
  }> & {
150
- order_id: string;
151
150
  payment_id: string;
151
+ order_id: string;
152
152
  amount: number;
153
153
  issued_at: NativeDate;
154
154
  issued_local_hour: string;
@@ -159,8 +159,8 @@ export declare const MaterializedTenantCreditBillsReportSchema: Schema<any, impo
159
159
  credit_note: string;
160
160
  }>;
161
161
  received: import("mongoose").Types.DocumentArray<{
162
- order_id: string;
163
162
  payment_id: string;
163
+ order_id: string;
164
164
  amount: number;
165
165
  received_at: NativeDate;
166
166
  received_amount: number;
@@ -170,8 +170,8 @@ export declare const MaterializedTenantCreditBillsReportSchema: Schema<any, impo
170
170
  event_local_hour: string;
171
171
  issued_local_date: string;
172
172
  }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
173
- order_id: string;
174
173
  payment_id: string;
174
+ order_id: string;
175
175
  amount: number;
176
176
  received_at: NativeDate;
177
177
  received_amount: number;
@@ -181,8 +181,8 @@ export declare const MaterializedTenantCreditBillsReportSchema: Schema<any, impo
181
181
  event_local_hour: string;
182
182
  issued_local_date: string;
183
183
  }> & {
184
- order_id: string;
185
184
  payment_id: string;
185
+ order_id: string;
186
186
  amount: number;
187
187
  received_at: NativeDate;
188
188
  received_amount: number;
@@ -201,10 +201,10 @@ export declare const MaterializedTenantCreditBillsReportSchema: Schema<any, impo
201
201
  updatedAt: NativeDate;
202
202
  } & {
203
203
  _id: import("mongoose").Types.ObjectId;
204
- tenant_id: string;
205
204
  createdAt: NativeDate;
206
205
  updatedAt: NativeDate;
207
206
  brand_id: string;
207
+ tenant_id: string;
208
208
  day_index: import("../../constants/ENUMS").DAY_INDEX_ENUM | null;
209
209
  iteration: number;
210
210
  scope_context: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_REPORT_SCOPE_ENUM;
@@ -212,8 +212,8 @@ export declare const MaterializedTenantCreditBillsReportSchema: Schema<any, impo
212
212
  sale_type_key_filters: string[];
213
213
  credit_bills: Map<string, {
214
214
  issued: import("mongoose").Types.DocumentArray<{
215
- order_id: string;
216
215
  payment_id: string;
216
+ order_id: string;
217
217
  amount: number;
218
218
  issued_at: NativeDate;
219
219
  issued_local_hour: string;
@@ -223,8 +223,8 @@ export declare const MaterializedTenantCreditBillsReportSchema: Schema<any, impo
223
223
  settled_local_date: string;
224
224
  credit_note: string;
225
225
  }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
226
- order_id: string;
227
226
  payment_id: string;
227
+ order_id: string;
228
228
  amount: number;
229
229
  issued_at: NativeDate;
230
230
  issued_local_hour: string;
@@ -234,8 +234,8 @@ export declare const MaterializedTenantCreditBillsReportSchema: Schema<any, impo
234
234
  settled_local_date: string;
235
235
  credit_note: string;
236
236
  }> & {
237
- order_id: string;
238
237
  payment_id: string;
238
+ order_id: string;
239
239
  amount: number;
240
240
  issued_at: NativeDate;
241
241
  issued_local_hour: string;
@@ -246,8 +246,8 @@ export declare const MaterializedTenantCreditBillsReportSchema: Schema<any, impo
246
246
  credit_note: string;
247
247
  }>;
248
248
  received: import("mongoose").Types.DocumentArray<{
249
- order_id: string;
250
249
  payment_id: string;
250
+ order_id: string;
251
251
  amount: number;
252
252
  received_at: NativeDate;
253
253
  received_amount: number;
@@ -257,8 +257,8 @@ export declare const MaterializedTenantCreditBillsReportSchema: Schema<any, impo
257
257
  event_local_hour: string;
258
258
  issued_local_date: string;
259
259
  }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
260
- order_id: string;
261
260
  payment_id: string;
261
+ order_id: string;
262
262
  amount: number;
263
263
  received_at: NativeDate;
264
264
  received_amount: number;
@@ -268,8 +268,8 @@ export declare const MaterializedTenantCreditBillsReportSchema: Schema<any, impo
268
268
  event_local_hour: string;
269
269
  issued_local_date: string;
270
270
  }> & {
271
- order_id: string;
272
271
  payment_id: string;
272
+ order_id: string;
273
273
  amount: number;
274
274
  received_at: NativeDate;
275
275
  received_amount: number;
@@ -0,0 +1,130 @@
1
+ import { Schema } from 'mongoose';
2
+ import { MATERIALIZED_REPORT_TYPE_ENUM } from '../../constants/MATERIALIZED_REPORTS';
3
+ import { IMaterializedReportDrilldownRow, IMaterializedReportDrilldownScope } from '../types/materialized_report_drilldown_rows';
4
+ /**
5
+ * FLAT drill-down rows and their scope metadata (see the type module).
6
+ *
7
+ * These are READ projections of the nested `*_entries` documents. The writer
8
+ * replaces all rows for one `(tenant, report_type, scope_context, scope_field)`
9
+ * scope after that scope's entry document is written; re-closing a day is
10
+ * therefore idempotent, and a stale scope can be deleted by identity.
11
+ */
12
+ export declare const MATERIALIZED_REPORT_DRILLDOWN_ROWS_SCHEMA_VERSION = 1;
13
+ export declare const MATERIALIZED_REPORT_DRILLDOWN_ROWS_COLLECTION_NAME = "materialized_report_drilldown_rows";
14
+ export declare const MATERIALIZED_REPORT_DRILLDOWN_SCOPES_COLLECTION_NAME = "materialized_report_drilldown_scopes";
15
+ export declare const MaterializedReportDrilldownRowSchema: Schema<IMaterializedReportDrilldownRow, import("mongoose").Model<IMaterializedReportDrilldownRow, any, any, any, import("mongoose").Document<unknown, any, IMaterializedReportDrilldownRow> & IMaterializedReportDrilldownRow & Required<{
16
+ _id: string;
17
+ }> & {
18
+ __v: number;
19
+ }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, IMaterializedReportDrilldownRow, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<IMaterializedReportDrilldownRow>> & import("mongoose").FlatRecord<IMaterializedReportDrilldownRow> & Required<{
20
+ _id: string;
21
+ }> & {
22
+ __v: number;
23
+ }>;
24
+ export declare const MaterializedReportDrilldownScopeSchema: Schema<IMaterializedReportDrilldownScope, import("mongoose").Model<IMaterializedReportDrilldownScope, any, any, any, import("mongoose").Document<unknown, any, IMaterializedReportDrilldownScope> & IMaterializedReportDrilldownScope & Required<{
25
+ _id: string;
26
+ }> & {
27
+ __v: number;
28
+ }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, IMaterializedReportDrilldownScope, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<IMaterializedReportDrilldownScope>> & import("mongoose").FlatRecord<IMaterializedReportDrilldownScope> & Required<{
29
+ _id: string;
30
+ }> & {
31
+ __v: number;
32
+ }>;
33
+ /**
34
+ * Index keys consumed by the flat reader.
35
+ *
36
+ * `identity` is the write-side upsert/delete key. The two read indexes cover
37
+ * the two cursor orders the reports already expose:
38
+ * - ascending tie-break: discounts/prep/sales/hourly/payments;
39
+ * - descending tie-break: cash/delivery.
40
+ */
41
+ export declare const MATERIALIZED_REPORT_DRILLDOWN_ROWS_COLLECTION_INDEXES: {
42
+ readonly _id: {
43
+ readonly _id: 1;
44
+ };
45
+ readonly identity: {
46
+ readonly tenant_id: 1;
47
+ readonly report_type: 1;
48
+ readonly scope_context: 1;
49
+ readonly scope_field: 1;
50
+ readonly order_id: 1;
51
+ readonly cursor_id: 1;
52
+ };
53
+ readonly read_asc: {
54
+ readonly tenant_id: 1;
55
+ readonly report_type: 1;
56
+ readonly scope_context: 1;
57
+ readonly scope_field: 1;
58
+ readonly time: -1;
59
+ readonly order_id: 1;
60
+ readonly cursor_id: 1;
61
+ };
62
+ readonly read_desc: {
63
+ readonly tenant_id: 1;
64
+ readonly report_type: 1;
65
+ readonly scope_context: 1;
66
+ readonly scope_field: 1;
67
+ readonly time: -1;
68
+ readonly cursor_id: -1;
69
+ };
70
+ };
71
+ export declare const MATERIALIZED_REPORT_DRILLDOWN_ROWS_INDEX_OPTIONS: ({
72
+ key: {
73
+ readonly tenant_id: 1;
74
+ readonly report_type: 1;
75
+ readonly scope_context: 1;
76
+ readonly scope_field: 1;
77
+ readonly order_id: 1;
78
+ readonly cursor_id: 1;
79
+ };
80
+ name: string;
81
+ unique: boolean;
82
+ } | {
83
+ key: {
84
+ readonly tenant_id: 1;
85
+ readonly report_type: 1;
86
+ readonly scope_context: 1;
87
+ readonly scope_field: 1;
88
+ readonly time: -1;
89
+ readonly order_id: 1;
90
+ readonly cursor_id: 1;
91
+ };
92
+ name: string;
93
+ unique?: undefined;
94
+ } | {
95
+ key: {
96
+ readonly tenant_id: 1;
97
+ readonly report_type: 1;
98
+ readonly scope_context: 1;
99
+ readonly scope_field: 1;
100
+ readonly time: -1;
101
+ readonly cursor_id: -1;
102
+ };
103
+ name: string;
104
+ unique?: undefined;
105
+ })[];
106
+ export declare const MATERIALIZED_REPORT_DRILLDOWN_SCOPES_COLLECTION_INDEXES: {
107
+ readonly _id: {
108
+ readonly _id: 1;
109
+ };
110
+ readonly identity: {
111
+ readonly tenant_id: 1;
112
+ readonly report_type: 1;
113
+ readonly scope_context: 1;
114
+ readonly scope_field: 1;
115
+ };
116
+ };
117
+ export declare const MATERIALIZED_REPORT_DRILLDOWN_SCOPES_INDEX_OPTIONS: {
118
+ key: {
119
+ readonly tenant_id: 1;
120
+ readonly report_type: 1;
121
+ readonly scope_context: 1;
122
+ readonly scope_field: 1;
123
+ };
124
+ name: string;
125
+ unique: boolean;
126
+ }[];
127
+ /** The report-type values the flat reader accepts. */
128
+ export declare const ALL_DRILLDOWN_REPORT_TYPE_VALUES: import("../types/materialized_report_drilldown_rows").TDrilldownReportType[];
129
+ /** Kept explicit so the JSON/demo upload can validate a file's report type. */
130
+ export declare const DRILLDOWN_REPORT_TYPE_BY_ENTRY_COLLECTION: Record<string, MATERIALIZED_REPORT_TYPE_ENUM>;
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DRILLDOWN_REPORT_TYPE_BY_ENTRY_COLLECTION = exports.ALL_DRILLDOWN_REPORT_TYPE_VALUES = exports.MATERIALIZED_REPORT_DRILLDOWN_SCOPES_INDEX_OPTIONS = exports.MATERIALIZED_REPORT_DRILLDOWN_SCOPES_COLLECTION_INDEXES = exports.MATERIALIZED_REPORT_DRILLDOWN_ROWS_INDEX_OPTIONS = exports.MATERIALIZED_REPORT_DRILLDOWN_ROWS_COLLECTION_INDEXES = exports.MaterializedReportDrilldownScopeSchema = exports.MaterializedReportDrilldownRowSchema = exports.MATERIALIZED_REPORT_DRILLDOWN_SCOPES_COLLECTION_NAME = exports.MATERIALIZED_REPORT_DRILLDOWN_ROWS_COLLECTION_NAME = exports.MATERIALIZED_REPORT_DRILLDOWN_ROWS_SCHEMA_VERSION = void 0;
4
+ const mongoose_1 = require("mongoose");
5
+ const ENUMS_1 = require("../../constants/ENUMS");
6
+ const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
7
+ const materialized_report_drilldown_rows_1 = require("../types/materialized_report_drilldown_rows");
8
+ /**
9
+ * FLAT drill-down rows and their scope metadata (see the type module).
10
+ *
11
+ * These are READ projections of the nested `*_entries` documents. The writer
12
+ * replaces all rows for one `(tenant, report_type, scope_context, scope_field)`
13
+ * scope after that scope's entry document is written; re-closing a day is
14
+ * therefore idempotent, and a stale scope can be deleted by identity.
15
+ */
16
+ exports.MATERIALIZED_REPORT_DRILLDOWN_ROWS_SCHEMA_VERSION = 1;
17
+ exports.MATERIALIZED_REPORT_DRILLDOWN_ROWS_COLLECTION_NAME = 'materialized_report_drilldown_rows';
18
+ exports.MATERIALIZED_REPORT_DRILLDOWN_SCOPES_COLLECTION_NAME = 'materialized_report_drilldown_scopes';
19
+ const ReportTypeEnum = materialized_report_drilldown_rows_1.ALL_DRILLDOWN_REPORT_TYPES;
20
+ exports.MaterializedReportDrilldownRowSchema = new mongoose_1.Schema({
21
+ tenant_id: { type: String, required: true, immutable: true },
22
+ brand_id: { type: String, required: true },
23
+ report_type: {
24
+ type: String,
25
+ required: true,
26
+ immutable: true,
27
+ enum: ReportTypeEnum,
28
+ },
29
+ scope_context: {
30
+ type: String,
31
+ required: true,
32
+ immutable: true,
33
+ enum: MATERIALIZED_REPORTS_1.ALL_MATERIALIZED_REPORT_SCOPES,
34
+ },
35
+ scope_field: { type: String, required: true, immutable: true },
36
+ day_index: { type: String, default: null, enum: [...ENUMS_1.ALL_DAY_INDEX, null] },
37
+ key: { type: String, required: true },
38
+ // Cash rows are drawer-ledger rows and have no order id; the field is
39
+ // still present (empty) because it is part of the identity/cursor tuple.
40
+ order_id: { type: String, default: '' },
41
+ cursor_id: { type: String, required: true },
42
+ time: { type: mongoose_1.Schema.Types.Date, required: true },
43
+ // The original row is polymorphic across reports; the report_type
44
+ // discriminator says which shape it is.
45
+ data: { type: mongoose_1.Schema.Types.Mixed, required: true },
46
+ schema_version: {
47
+ type: Number,
48
+ required: true,
49
+ immutable: true,
50
+ default: exports.MATERIALIZED_REPORT_DRILLDOWN_ROWS_SCHEMA_VERSION,
51
+ },
52
+ computed_at: { type: mongoose_1.Schema.Types.Date, required: true },
53
+ }, { timestamps: true, versionKey: false, minimize: false });
54
+ exports.MaterializedReportDrilldownScopeSchema = new mongoose_1.Schema({
55
+ tenant_id: { type: String, required: true, immutable: true },
56
+ brand_id: { type: String, required: true },
57
+ report_type: {
58
+ type: String,
59
+ required: true,
60
+ immutable: true,
61
+ enum: ReportTypeEnum,
62
+ },
63
+ scope_context: {
64
+ type: String,
65
+ required: true,
66
+ immutable: true,
67
+ enum: MATERIALIZED_REPORTS_1.ALL_MATERIALIZED_REPORT_SCOPES,
68
+ },
69
+ scope_field: { type: String, required: true, immutable: true },
70
+ row_count: { type: Number, required: true, min: 0, default: 0 },
71
+ off_app_order_count: { type: Number, required: true, min: 0, default: 0 },
72
+ schema_version: {
73
+ type: Number,
74
+ required: true,
75
+ immutable: true,
76
+ default: exports.MATERIALIZED_REPORT_DRILLDOWN_ROWS_SCHEMA_VERSION,
77
+ },
78
+ computed_at: { type: mongoose_1.Schema.Types.Date, required: true },
79
+ }, { timestamps: true, versionKey: false, minimize: false });
80
+ /**
81
+ * Index keys consumed by the flat reader.
82
+ *
83
+ * `identity` is the write-side upsert/delete key. The two read indexes cover
84
+ * the two cursor orders the reports already expose:
85
+ * - ascending tie-break: discounts/prep/sales/hourly/payments;
86
+ * - descending tie-break: cash/delivery.
87
+ */
88
+ exports.MATERIALIZED_REPORT_DRILLDOWN_ROWS_COLLECTION_INDEXES = {
89
+ _id: { _id: 1 },
90
+ identity: {
91
+ tenant_id: 1,
92
+ report_type: 1,
93
+ scope_context: 1,
94
+ scope_field: 1,
95
+ order_id: 1,
96
+ cursor_id: 1,
97
+ },
98
+ read_asc: {
99
+ tenant_id: 1,
100
+ report_type: 1,
101
+ scope_context: 1,
102
+ scope_field: 1,
103
+ time: -1,
104
+ order_id: 1,
105
+ cursor_id: 1,
106
+ },
107
+ read_desc: {
108
+ tenant_id: 1,
109
+ report_type: 1,
110
+ scope_context: 1,
111
+ scope_field: 1,
112
+ time: -1,
113
+ cursor_id: -1,
114
+ },
115
+ };
116
+ exports.MATERIALIZED_REPORT_DRILLDOWN_ROWS_INDEX_OPTIONS = [
117
+ {
118
+ key: exports.MATERIALIZED_REPORT_DRILLDOWN_ROWS_COLLECTION_INDEXES.identity,
119
+ name: 'tenant_id__report_type__scope__order_id__cursor_id',
120
+ unique: true,
121
+ },
122
+ {
123
+ key: exports.MATERIALIZED_REPORT_DRILLDOWN_ROWS_COLLECTION_INDEXES.read_asc,
124
+ name: 'tenant_id__report_type__scope__time_desc__order_id__cursor_id',
125
+ },
126
+ {
127
+ key: exports.MATERIALIZED_REPORT_DRILLDOWN_ROWS_COLLECTION_INDEXES.read_desc,
128
+ name: 'tenant_id__report_type__scope__time_desc__cursor_id_desc',
129
+ },
130
+ ];
131
+ exports.MATERIALIZED_REPORT_DRILLDOWN_SCOPES_COLLECTION_INDEXES = {
132
+ _id: { _id: 1 },
133
+ identity: {
134
+ tenant_id: 1,
135
+ report_type: 1,
136
+ scope_context: 1,
137
+ scope_field: 1,
138
+ },
139
+ };
140
+ exports.MATERIALIZED_REPORT_DRILLDOWN_SCOPES_INDEX_OPTIONS = [
141
+ {
142
+ key: exports.MATERIALIZED_REPORT_DRILLDOWN_SCOPES_COLLECTION_INDEXES.identity,
143
+ name: 'tenant_id__report_type__scope',
144
+ unique: true,
145
+ },
146
+ ];
147
+ /** The report-type values the flat reader accepts. */
148
+ exports.ALL_DRILLDOWN_REPORT_TYPE_VALUES = materialized_report_drilldown_rows_1.ALL_DRILLDOWN_REPORT_TYPES;
149
+ /** Kept explicit so the JSON/demo upload can validate a file's report type. */
150
+ exports.DRILLDOWN_REPORT_TYPE_BY_ENTRY_COLLECTION = {
151
+ materialized_tenant_discount_entries: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_TYPE_ENUM.TENANT_DISCOUNT_ENTRIES,
152
+ materialized_tenant_prep_time_entries: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_TYPE_ENUM.TENANT_PREP_TIME_ENTRIES,
153
+ materialized_tenant_cash_in_out_entries: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_TYPE_ENUM.TENANT_CASH_ENTRIES,
154
+ materialized_tenant_delivery_entries: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_TYPE_ENUM.TENANT_DELIVERY_ENTRIES,
155
+ materialized_tenant_sales_comparison_entries: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_TYPE_ENUM.TENANT_SALES_COMPARISON_ENTRIES,
156
+ materialized_tenant_hourly_comparison_entries: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_TYPE_ENUM.TENANT_HOURLY_COMPARISON_ENTRIES,
157
+ materialized_tenant_payments_comparison_entries: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_TYPE_ENUM.TENANT_PAYMENTS_COMPARISON_ENTRIES,
158
+ };
@@ -16,12 +16,12 @@ declare const CashEntrySchema: Schema<any, import("mongoose").Model<any, any, an
16
16
  _id: false;
17
17
  }, {
18
18
  type: import("../../constants/ENUMS").CASH_IN_OUT_TYPE_ENUM;
19
- staff_id: string;
20
- staff_name: string;
21
19
  note: string;
22
20
  ref_type: import("../../constants/ENUMS").CASH_IN_OUT_REF_ENUM;
23
21
  ref_id: string;
24
22
  amount: number;
23
+ staff_id: string;
24
+ staff_name: string;
25
25
  day_id: string;
26
26
  drawer_id: string;
27
27
  drawer_name: string;
@@ -40,12 +40,12 @@ declare const CashEntrySchema: Schema<any, import("mongoose").Model<any, any, an
40
40
  is_system_adjustment: boolean;
41
41
  }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
42
42
  type: import("../../constants/ENUMS").CASH_IN_OUT_TYPE_ENUM;
43
- staff_id: string;
44
- staff_name: string;
45
43
  note: string;
46
44
  ref_type: import("../../constants/ENUMS").CASH_IN_OUT_REF_ENUM;
47
45
  ref_id: string;
48
46
  amount: number;
47
+ staff_id: string;
48
+ staff_name: string;
49
49
  day_id: string;
50
50
  drawer_id: string;
51
51
  drawer_name: string;
@@ -64,12 +64,12 @@ declare const CashEntrySchema: Schema<any, import("mongoose").Model<any, any, an
64
64
  is_system_adjustment: boolean;
65
65
  }>> & import("mongoose").FlatRecord<{
66
66
  type: import("../../constants/ENUMS").CASH_IN_OUT_TYPE_ENUM;
67
- staff_id: string;
68
- staff_name: string;
69
67
  note: string;
70
68
  ref_type: import("../../constants/ENUMS").CASH_IN_OUT_REF_ENUM;
71
69
  ref_id: string;
72
70
  amount: number;
71
+ staff_id: string;
72
+ staff_name: string;
73
73
  day_id: string;
74
74
  drawer_id: string;
75
75
  drawer_name: string;
@@ -100,10 +100,10 @@ export declare const MaterializedTenantCashEntriesSchema: Schema<any, import("mo
100
100
  createdAt: NativeDate;
101
101
  updatedAt: NativeDate;
102
102
  } & {
103
- tenant_id: string;
104
103
  createdAt: NativeDate;
105
104
  updatedAt: NativeDate;
106
105
  brand_id: string;
106
+ tenant_id: string;
107
107
  day_index: import("../../constants/ENUMS").DAY_INDEX_ENUM | null;
108
108
  iteration: number;
109
109
  scope_context: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_REPORT_SCOPE_ENUM;
@@ -117,10 +117,10 @@ export declare const MaterializedTenantCashEntriesSchema: Schema<any, import("mo
117
117
  createdAt: NativeDate;
118
118
  updatedAt: NativeDate;
119
119
  } & {
120
- tenant_id: string;
121
120
  createdAt: NativeDate;
122
121
  updatedAt: NativeDate;
123
122
  brand_id: string;
123
+ tenant_id: string;
124
124
  day_index: import("../../constants/ENUMS").DAY_INDEX_ENUM | null;
125
125
  iteration: number;
126
126
  scope_context: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_REPORT_SCOPE_ENUM;
@@ -134,10 +134,10 @@ export declare const MaterializedTenantCashEntriesSchema: Schema<any, import("mo
134
134
  createdAt: NativeDate;
135
135
  updatedAt: NativeDate;
136
136
  } & {
137
- tenant_id: string;
138
137
  createdAt: NativeDate;
139
138
  updatedAt: NativeDate;
140
139
  brand_id: string;
140
+ tenant_id: string;
141
141
  day_index: import("../../constants/ENUMS").DAY_INDEX_ENUM | null;
142
142
  iteration: number;
143
143
  scope_context: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_REPORT_SCOPE_ENUM;
@@ -27,10 +27,10 @@ export declare const MaterializedTenantCashReportSchema: Schema<any, import("mon
27
27
  createdAt: NativeDate;
28
28
  updatedAt: NativeDate;
29
29
  } & {
30
- tenant_id: string;
31
30
  createdAt: NativeDate;
32
31
  updatedAt: NativeDate;
33
32
  brand_id: string;
33
+ tenant_id: string;
34
34
  day_index: import("../../constants/ENUMS").DAY_INDEX_ENUM | null;
35
35
  iteration: number;
36
36
  scope_context: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_REPORT_SCOPE_ENUM;
@@ -45,10 +45,10 @@ export declare const MaterializedTenantCashReportSchema: Schema<any, import("mon
45
45
  createdAt: NativeDate;
46
46
  updatedAt: NativeDate;
47
47
  } & {
48
- tenant_id: string;
49
48
  createdAt: NativeDate;
50
49
  updatedAt: NativeDate;
51
50
  brand_id: string;
51
+ tenant_id: string;
52
52
  day_index: import("../../constants/ENUMS").DAY_INDEX_ENUM | null;
53
53
  iteration: number;
54
54
  scope_context: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_REPORT_SCOPE_ENUM;
@@ -63,10 +63,10 @@ export declare const MaterializedTenantCashReportSchema: Schema<any, import("mon
63
63
  createdAt: NativeDate;
64
64
  updatedAt: NativeDate;
65
65
  } & {
66
- tenant_id: string;
67
66
  createdAt: NativeDate;
68
67
  updatedAt: NativeDate;
69
68
  brand_id: string;
69
+ tenant_id: string;
70
70
  day_index: import("../../constants/ENUMS").DAY_INDEX_ENUM | null;
71
71
  iteration: number;
72
72
  scope_context: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_REPORT_SCOPE_ENUM;