@managesome/eposmatic-toolkit 0.4.5 → 0.4.8

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 (68) hide show
  1. package/esm/constants/MATERIALIZED_REPORTS.js +33 -0
  2. package/esm/constants/REPORT_CALENDAR.js +47 -0
  3. package/esm/constants/index.js +1 -0
  4. package/esm/helpers/materialized-reports/index.js +2 -0
  5. package/esm/helpers/materialized-reports/materialized-credit-bills-helpers.js +982 -0
  6. package/esm/helpers/materialized-reports/materialized-reports-read-helpers.js +1 -76
  7. package/esm/helpers/materialized-reports/materialized-reports-selection-helpers.js +716 -0
  8. package/esm/helpers/materialized-reports/tenant-sales-overview-close-day-helpers.js +327 -41
  9. package/esm/helpers/materialized-reports/tenant-sales-overview-formatter.js +72 -11
  10. package/esm/helpers/materialized-reports/tenant-sales-overview-helpers.js +118 -235
  11. package/esm/helpers/types/index.js +1 -0
  12. package/esm/schemas/models/index.js +1 -0
  13. package/esm/schemas/models/materialized_credit_bills.js +265 -0
  14. package/esm/schemas/models/materialized_tenant_reports_iterations.js +13 -0
  15. package/esm/schemas/models/materialized_tenant_sales_overview_reports.js +39 -97
  16. package/esm/schemas/types/index.js +1 -0
  17. package/esm/schemas/types/materialized_credit_bills.js +1 -0
  18. package/lib/constants/MATERIALIZED_REPORTS.d.ts +28 -2
  19. package/lib/constants/MATERIALIZED_REPORTS.js +34 -1
  20. package/lib/constants/REPORT_CALENDAR.d.ts +31 -0
  21. package/lib/constants/REPORT_CALENDAR.js +50 -0
  22. package/lib/constants/index.d.ts +1 -0
  23. package/lib/constants/index.js +1 -0
  24. package/lib/helpers/materialized-reports/index.d.ts +2 -0
  25. package/lib/helpers/materialized-reports/index.js +2 -0
  26. package/lib/helpers/materialized-reports/materialized-credit-bills-helpers.d.ts +307 -0
  27. package/lib/helpers/materialized-reports/materialized-credit-bills-helpers.js +1003 -0
  28. package/lib/helpers/materialized-reports/materialized-reports-read-helpers.d.ts +0 -30
  29. package/lib/helpers/materialized-reports/materialized-reports-read-helpers.js +0 -76
  30. package/lib/helpers/materialized-reports/materialized-reports-selection-helpers.d.ts +59 -0
  31. package/lib/helpers/materialized-reports/materialized-reports-selection-helpers.js +723 -0
  32. package/lib/helpers/materialized-reports/tenant-sales-overview-close-day-helpers.d.ts +66 -8
  33. package/lib/helpers/materialized-reports/tenant-sales-overview-close-day-helpers.js +326 -40
  34. package/lib/helpers/materialized-reports/tenant-sales-overview-formatter.d.ts +18 -2
  35. package/lib/helpers/materialized-reports/tenant-sales-overview-formatter.js +72 -11
  36. package/lib/helpers/materialized-reports/tenant-sales-overview-helpers.d.ts +46 -37
  37. package/lib/helpers/materialized-reports/tenant-sales-overview-helpers.js +119 -238
  38. package/lib/helpers/types/index.d.ts +1 -0
  39. package/lib/helpers/types/index.js +1 -0
  40. package/lib/helpers/types/materialized-reports-apis.d.ts +46 -17
  41. package/lib/helpers/types/report-calendar.d.ts +20 -0
  42. package/lib/helpers/types/report-calendar.js +2 -0
  43. package/lib/schemas/models/index.d.ts +1 -0
  44. package/lib/schemas/models/index.js +1 -0
  45. package/lib/schemas/models/materialized_credit_bills.d.ts +337 -0
  46. package/lib/schemas/models/materialized_credit_bills.js +268 -0
  47. package/lib/schemas/models/materialized_tenant_reports_iterations.d.ts +20 -6
  48. package/lib/schemas/models/materialized_tenant_reports_iterations.js +14 -1
  49. package/lib/schemas/models/materialized_tenant_sales_overview_reports.d.ts +37 -165
  50. package/lib/schemas/models/materialized_tenant_sales_overview_reports.js +40 -98
  51. package/lib/schemas/types/index.d.ts +1 -0
  52. package/lib/schemas/types/index.js +1 -0
  53. package/lib/schemas/types/materialized_credit_bills.d.ts +139 -0
  54. package/lib/schemas/types/materialized_credit_bills.js +2 -0
  55. package/lib/schemas/types/materialized_tenant_sales_overview_reports.d.ts +32 -77
  56. package/lib/tests/materialized-reports/materialized-credit-bills-helpers.test.d.ts +1 -0
  57. package/lib/tests/materialized-reports/materialized-credit-bills-helpers.test.js +715 -0
  58. package/lib/tests/materialized-reports/materialized-reports-selection-helpers.test.d.ts +1 -0
  59. package/lib/tests/materialized-reports/materialized-reports-selection-helpers.test.js +262 -0
  60. package/lib/tests/materialized-reports/materialized-tenant-reports-iterations-schema.test.js +9 -0
  61. package/lib/tests/materialized-reports/materialized-tenant-sales-overview-reports-schema.test.js +23 -24
  62. package/lib/tests/materialized-reports/tenant-sales-overview-close-day-helpers.test.js +327 -22
  63. package/lib/tests/materialized-reports/tenant-sales-overview-formatter-aggregated.test.js +27 -2
  64. package/lib/tests/materialized-reports/tenant-sales-overview-formatter.test.js +12 -27
  65. package/lib/tests/materialized-reports/tenant-sales-overview-helpers.test.js +79 -146
  66. package/package.json +1 -1
  67. package/lib/tests/materialized-reports/materialized-reports-read-helpers.test.js +0 -100
  68. /package/{lib/tests/materialized-reports/materialized-reports-read-helpers.test.d.ts → esm/helpers/types/report-calendar.js} +0 -0
@@ -1,6 +1,7 @@
1
1
  import { MATERIALIZED_REPORT_SCOPE_ENUM, MATERIALIZED_REPORT_TYPE_ENUM, REPORT_SALE_TYPE_ENUM } from '../../constants';
2
2
  import { MATERIALIZED_REPORT_KEY_FILTER_ENUM } from '../../constants/MATERIALIZED_REPORTS';
3
3
  import { IMaterializedReportOrderMetric, IMaterializedReportPaymentMetric } from '../../schemas/types/materialized_tenant_sales_overview_reports';
4
+ import { IGetMaterializedReportSelectionSpec } from './report-calendar';
4
5
  /**
5
6
  * Request body contracts for the materialized reports READ APIs
6
7
  * (operations-service, mounted at `/reports`) — shared between
@@ -33,25 +34,26 @@ export interface IGetMaterializedReportScopeGroup {
33
34
  /**
34
35
  * Shared body of the materialized reports READ APIs — every report endpoint
35
36
  * (`POST /reports/overview` today; X / Z / Riders / Items / … as they land)
36
- * takes the same shape. Build it with `buildMaterializedReportReadBody`
37
- * (toolkit) and derive the groups from a calendar selection with
38
- * `buildMaterializedReportScopeGroups` (toolkit) — never ad-hoc literals.
37
+ * takes the same shape: the TENANTS plus the CALENDAR SELECTION to serve.
39
38
  *
40
- * The scope query is a LIST of exact-value groups (`scope_groups`, minimum
41
- * length 1, one `scope_context` per group). The backend derives, per group,
42
- * the query shape (a single value is matched with direct equality, multiple
43
- * values with `$in`), folds each group inside MongoDB and answers with ONE
44
- * aggregated record per tenant — the response shape never varies.
39
+ * The client ships the selection itself (`IReportCalendarSelection` — a few
40
+ * hundred bytes regardless of range); the BACKEND decodes it into the exact
41
+ * scope values (`buildMaterializedReportScopeGroupsFromSelection`) and folds
42
+ * each scope group inside MongoDB into ONE aggregated record per tenant — the
43
+ * response shape never varies. Enumerating scope values client-side is NOT
44
+ * part of the wire contract anymore.
45
45
  */
46
46
  export interface IGetMaterializedReportBody {
47
47
  /** One or more tenant ids to read (minimum length 1). */
48
48
  tenants: string[];
49
49
  /**
50
- * One or more scope groups (minimum length 1). Groups may use DIFFERENT
51
- * scope contexts (a span read mixes `localHour` boundary labels with full
52
- * `localDate` / period values); their scopes must not overlap.
50
+ * The committed calendar selection to serve. `spec_version` pins the
51
+ * selection model version (`MATERIALIZED_REPORT_SELECTION_SPEC_VERSION`) —
52
+ * the read API rejects unknown versions with a 400, so rolling deploys
53
+ * (old client → new backend) fail loudly instead of decoding a stale
54
+ * shape.
53
55
  */
54
- scope_groups: IGetMaterializedReportScopeGroup[];
56
+ selection: IGetMaterializedReportSelectionSpec;
55
57
  }
56
58
  /**
57
59
  * Body of `POST /reports/overview` — materialized sales overview
@@ -106,11 +108,30 @@ export interface IMaterializedTenantSalesOverviewAggregatedKeyMetrics {
106
108
  issued: {
107
109
  count: number;
108
110
  amount: number;
111
+ /** Fully settled BY THE SELECTION END (range-pure — see `computeMaterializedCreditBillTotals`). */
109
112
  settled_count: number;
113
+ /** Σ `amount` of those bills. */
110
114
  settled_amount: number;
115
+ /** Issued-in-selection bills NOT fully settled by the selection end. */
116
+ outstanding_count: number;
117
+ /** Per-bill `max(0, amount − received_at_issue − Σ in-selection deltas)` — owed at the selection end. */
118
+ outstanding_amount: number;
119
+ /** Today's state: issued-in-selection bills whose CURRENT cumulative is below `amount`. */
120
+ outstanding_now_count: number;
121
+ /** Per-bill `max(0, amount − received_now)` — owed now. */
122
+ outstanding_now_amount: number;
123
+ /**
124
+ * Money in hand AT ISSUE (Σ `received_at_issue` of issued-in-selection
125
+ * bills): same-day settled credit + prepaid partials. Added to
126
+ * `received.amount` for the Amount Collected KPI (N4).
127
+ */
128
+ collected_at_issue_count: number;
129
+ collected_at_issue_amount: number;
111
130
  };
112
131
  received: {
132
+ /** Distinct bills with a receipt event in the selection. */
113
133
  count: number;
134
+ /** Money received IN the selection (Σ `received_delta`). */
114
135
  amount: number;
115
136
  };
116
137
  };
@@ -126,15 +147,23 @@ export interface IMaterializedTenantSalesOverviewAggregatedKeyMetrics {
126
147
  * still apply its platform / order-status filters client-side on a single
127
148
  * record — via `getFormattedTenantSalesOverviewAggregatedReporting`.
128
149
  *
129
- * NOT part of the stored schema: carries no `_id`, `iteration`,
130
- * `schema_version`, `source_watermark`, `computed_at` or timestamps — only
131
- * the report values plus the read context (`matched_documents` and the
132
- * `scope_field` span) useful for debugging. No `scope_context`: a span read
133
- * mixes several.
150
+ * NOT part of the stored schema: carries no `_id`, `schema_version`,
151
+ * `source_watermark` or `computed_at` — the report values, the read context,
152
+ * plus the freshness STAMPS of the folded documents (`max_iteration` /
153
+ * `max_updated_at`), because past documents MUTATE (settlement patches,
154
+ * re-closes) and consumers must be able to show "as of" and key caches.
155
+ * No `scope_context`: a span read mixes several.
134
156
  */
135
157
  export interface IMaterializedTenantSalesOverviewAggregatedReport {
136
158
  tenant_id: string;
137
159
  brand_id: string;
160
+ /**
161
+ * Freshness of the folded data: the max `iteration` across the matched
162
+ * documents and their newest `updatedAt` — the response has no other
163
+ * version marker.
164
+ */
165
+ max_iteration: number;
166
+ max_updated_at: Date | null;
138
167
  /**
139
168
  * How many stored scope documents were folded into this record — an EXACT
140
169
  * count, independent of the key map (documents with disjoint key sets
@@ -0,0 +1,20 @@
1
+ import { DAY_INDEX_ENUM } from '../../constants/ENUMS';
2
+ import { CALENDAR_MODE_ENUM, CALENDAR_VIEW_MODE_ENUM } from '../../constants/REPORT_CALENDAR';
3
+ export interface IReportCalendarSelection {
4
+ mode: CALENDAR_MODE_ENUM;
5
+ view: CALENDAR_VIEW_MODE_ENUM;
6
+ rangeStart: string | null;
7
+ rangeEnd: string | null;
8
+ selectedDates: string[];
9
+ timeStart: string | null;
10
+ timeEnd: string | null;
11
+ selectedPeriods: string[];
12
+ weekdays: DAY_INDEX_ENUM[];
13
+ }
14
+ /**
15
+ * A read body's `selection` — the calendar selection plus the spec version
16
+ * the request was built against (`MATERIALIZED_REPORT_SELECTION_SPEC_VERSION`).
17
+ */
18
+ export interface IGetMaterializedReportSelectionSpec extends IReportCalendarSelection {
19
+ spec_version: number;
20
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -27,6 +27,7 @@ export * from './inventory_transactions';
27
27
  export * from './item_transactions';
28
28
  export * from './items';
29
29
  export * from './marketing_fingerprints';
30
+ export * from './materialized_credit_bills';
30
31
  export * from './materialized_tenant_reports_iterations';
31
32
  export * from './materialized_tenant_sales_overview_reports';
32
33
  export * from './menus';
@@ -43,6 +43,7 @@ __exportStar(require("./inventory_transactions"), exports);
43
43
  __exportStar(require("./item_transactions"), exports);
44
44
  __exportStar(require("./items"), exports);
45
45
  __exportStar(require("./marketing_fingerprints"), exports);
46
+ __exportStar(require("./materialized_credit_bills"), exports);
46
47
  __exportStar(require("./materialized_tenant_reports_iterations"), exports);
47
48
  __exportStar(require("./materialized_tenant_sales_overview_reports"), exports);
48
49
  __exportStar(require("./menus"), exports);
@@ -0,0 +1,337 @@
1
+ import { Schema } from 'mongoose';
2
+ /**
3
+ * Mongoose schema for `materialized_tenant_credit_bills` — the SHARED
4
+ * credit-bill ledger of the materialized reports (see `MATERIALIZED_REPORTS.md`).
5
+ *
6
+ * ONE document per (tenant, scope context, scope value), scopes CAPPED AT
7
+ * `LOCAL_MONTH` (`MATERIALIZED_CREDIT_BILLS_SCOPES`) so a document can never
8
+ * grow unboundedly: a month bounds its bill volume by construction. Each
9
+ * document carries a per-key `credit_bills` map of slim `issued` / `received`
10
+ * entries (ids + credit facts — the order document stays the single source of
11
+ * the sale). See the type module `schemas/types/materialized_credit_bills.ts`
12
+ * for the entry contract. Amounts are CENTS; reads pin `schema_version`.
13
+ */
14
+ /**
15
+ * Version of the credit-entry rules of this collection. Bump when entry
16
+ * semantics change (e.g. signed REFUND / WRITE_OFF deltas) — historical
17
+ * documents must then be re-materialized. PRE-RELEASE: the collection has no
18
+ * live tenants/consumers yet, so every change so far folds into version `1`.
19
+ */
20
+ export declare const MATERIALIZED_CREDIT_BILLS_SCHEMA_VERSION = 1;
21
+ export declare const MaterializedTenantCreditBillsReportSchema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
22
+ timestamps: true;
23
+ versionKey: false;
24
+ minimize: false;
25
+ }, {
26
+ createdAt: NativeDate;
27
+ updatedAt: NativeDate;
28
+ } & {
29
+ _id: import("mongoose").Types.ObjectId;
30
+ tenant_id: string;
31
+ createdAt: NativeDate;
32
+ updatedAt: NativeDate;
33
+ brand_id: string;
34
+ day_index: import("../../constants/ENUMS").DAY_INDEX_ENUM;
35
+ iteration: number;
36
+ scope_context: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_REPORT_SCOPE_ENUM;
37
+ scope_field: string;
38
+ sale_type_key_filters: string[];
39
+ credit_bills: Map<string, {
40
+ issued: import("mongoose").Types.DocumentArray<{
41
+ order_id: string;
42
+ payment_id: string;
43
+ amount: number;
44
+ issued_at: NativeDate;
45
+ issued_local_hour: string;
46
+ received_at_issue: number;
47
+ received_amount: number;
48
+ settled_at: NativeDate;
49
+ settled_local_date: string;
50
+ credit_note: string;
51
+ }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
52
+ order_id: string;
53
+ payment_id: string;
54
+ amount: number;
55
+ issued_at: NativeDate;
56
+ issued_local_hour: string;
57
+ received_at_issue: number;
58
+ received_amount: number;
59
+ settled_at: NativeDate;
60
+ settled_local_date: string;
61
+ credit_note: string;
62
+ }> & {
63
+ order_id: string;
64
+ payment_id: string;
65
+ amount: number;
66
+ issued_at: NativeDate;
67
+ issued_local_hour: string;
68
+ received_at_issue: number;
69
+ received_amount: number;
70
+ settled_at: NativeDate;
71
+ settled_local_date: string;
72
+ credit_note: string;
73
+ }>;
74
+ received: import("mongoose").Types.DocumentArray<{
75
+ order_id: string;
76
+ payment_id: string;
77
+ amount: number;
78
+ received_at: NativeDate;
79
+ received_amount: number;
80
+ credit_note: string;
81
+ event_local_date: string;
82
+ received_delta: number;
83
+ event_local_hour: string;
84
+ issued_local_date: string;
85
+ }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
86
+ order_id: string;
87
+ payment_id: string;
88
+ amount: number;
89
+ received_at: NativeDate;
90
+ received_amount: number;
91
+ credit_note: string;
92
+ event_local_date: string;
93
+ received_delta: number;
94
+ event_local_hour: string;
95
+ issued_local_date: string;
96
+ }> & {
97
+ order_id: string;
98
+ payment_id: string;
99
+ amount: number;
100
+ received_at: NativeDate;
101
+ received_amount: number;
102
+ credit_note: string;
103
+ event_local_date: string;
104
+ received_delta: number;
105
+ event_local_hour: string;
106
+ issued_local_date: string;
107
+ }>;
108
+ }>;
109
+ schema_version: number;
110
+ source_watermark: NativeDate;
111
+ computed_at: NativeDate;
112
+ }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
113
+ createdAt: NativeDate;
114
+ updatedAt: NativeDate;
115
+ } & {
116
+ _id: import("mongoose").Types.ObjectId;
117
+ tenant_id: string;
118
+ createdAt: NativeDate;
119
+ updatedAt: NativeDate;
120
+ brand_id: string;
121
+ day_index: import("../../constants/ENUMS").DAY_INDEX_ENUM;
122
+ iteration: number;
123
+ scope_context: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_REPORT_SCOPE_ENUM;
124
+ scope_field: string;
125
+ sale_type_key_filters: string[];
126
+ credit_bills: Map<string, {
127
+ issued: import("mongoose").Types.DocumentArray<{
128
+ order_id: string;
129
+ payment_id: string;
130
+ amount: number;
131
+ issued_at: NativeDate;
132
+ issued_local_hour: string;
133
+ received_at_issue: number;
134
+ received_amount: number;
135
+ settled_at: NativeDate;
136
+ settled_local_date: string;
137
+ credit_note: string;
138
+ }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
139
+ order_id: string;
140
+ payment_id: string;
141
+ amount: number;
142
+ issued_at: NativeDate;
143
+ issued_local_hour: string;
144
+ received_at_issue: number;
145
+ received_amount: number;
146
+ settled_at: NativeDate;
147
+ settled_local_date: string;
148
+ credit_note: string;
149
+ }> & {
150
+ order_id: string;
151
+ payment_id: string;
152
+ amount: number;
153
+ issued_at: NativeDate;
154
+ issued_local_hour: string;
155
+ received_at_issue: number;
156
+ received_amount: number;
157
+ settled_at: NativeDate;
158
+ settled_local_date: string;
159
+ credit_note: string;
160
+ }>;
161
+ received: import("mongoose").Types.DocumentArray<{
162
+ order_id: string;
163
+ payment_id: string;
164
+ amount: number;
165
+ received_at: NativeDate;
166
+ received_amount: number;
167
+ credit_note: string;
168
+ event_local_date: string;
169
+ received_delta: number;
170
+ event_local_hour: string;
171
+ issued_local_date: string;
172
+ }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
173
+ order_id: string;
174
+ payment_id: string;
175
+ amount: number;
176
+ received_at: NativeDate;
177
+ received_amount: number;
178
+ credit_note: string;
179
+ event_local_date: string;
180
+ received_delta: number;
181
+ event_local_hour: string;
182
+ issued_local_date: string;
183
+ }> & {
184
+ order_id: string;
185
+ payment_id: string;
186
+ amount: number;
187
+ received_at: NativeDate;
188
+ received_amount: number;
189
+ credit_note: string;
190
+ event_local_date: string;
191
+ received_delta: number;
192
+ event_local_hour: string;
193
+ issued_local_date: string;
194
+ }>;
195
+ }>;
196
+ schema_version: number;
197
+ source_watermark: NativeDate;
198
+ computed_at: NativeDate;
199
+ }>> & import("mongoose").FlatRecord<{
200
+ createdAt: NativeDate;
201
+ updatedAt: NativeDate;
202
+ } & {
203
+ _id: import("mongoose").Types.ObjectId;
204
+ tenant_id: string;
205
+ createdAt: NativeDate;
206
+ updatedAt: NativeDate;
207
+ brand_id: string;
208
+ day_index: import("../../constants/ENUMS").DAY_INDEX_ENUM;
209
+ iteration: number;
210
+ scope_context: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_REPORT_SCOPE_ENUM;
211
+ scope_field: string;
212
+ sale_type_key_filters: string[];
213
+ credit_bills: Map<string, {
214
+ issued: import("mongoose").Types.DocumentArray<{
215
+ order_id: string;
216
+ payment_id: string;
217
+ amount: number;
218
+ issued_at: NativeDate;
219
+ issued_local_hour: string;
220
+ received_at_issue: number;
221
+ received_amount: number;
222
+ settled_at: NativeDate;
223
+ settled_local_date: string;
224
+ credit_note: string;
225
+ }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
226
+ order_id: string;
227
+ payment_id: string;
228
+ amount: number;
229
+ issued_at: NativeDate;
230
+ issued_local_hour: string;
231
+ received_at_issue: number;
232
+ received_amount: number;
233
+ settled_at: NativeDate;
234
+ settled_local_date: string;
235
+ credit_note: string;
236
+ }> & {
237
+ order_id: string;
238
+ payment_id: string;
239
+ amount: number;
240
+ issued_at: NativeDate;
241
+ issued_local_hour: string;
242
+ received_at_issue: number;
243
+ received_amount: number;
244
+ settled_at: NativeDate;
245
+ settled_local_date: string;
246
+ credit_note: string;
247
+ }>;
248
+ received: import("mongoose").Types.DocumentArray<{
249
+ order_id: string;
250
+ payment_id: string;
251
+ amount: number;
252
+ received_at: NativeDate;
253
+ received_amount: number;
254
+ credit_note: string;
255
+ event_local_date: string;
256
+ received_delta: number;
257
+ event_local_hour: string;
258
+ issued_local_date: string;
259
+ }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
260
+ order_id: string;
261
+ payment_id: string;
262
+ amount: number;
263
+ received_at: NativeDate;
264
+ received_amount: number;
265
+ credit_note: string;
266
+ event_local_date: string;
267
+ received_delta: number;
268
+ event_local_hour: string;
269
+ issued_local_date: string;
270
+ }> & {
271
+ order_id: string;
272
+ payment_id: string;
273
+ amount: number;
274
+ received_at: NativeDate;
275
+ received_amount: number;
276
+ credit_note: string;
277
+ event_local_date: string;
278
+ received_delta: number;
279
+ event_local_hour: string;
280
+ issued_local_date: string;
281
+ }>;
282
+ }>;
283
+ schema_version: number;
284
+ source_watermark: NativeDate;
285
+ computed_at: NativeDate;
286
+ }> & Required<{
287
+ _id: import("mongoose").Types.ObjectId;
288
+ }> & {
289
+ __v: number;
290
+ }>;
291
+ export declare const MATERIALIZED_TENANT_CREDIT_BILLS_COLLECTION_NAME = "materialized_tenant_credit_bills";
292
+ /**
293
+ * Describes the indexes for `materialized_tenant_credit_bills`. Values are
294
+ * Mongo key patterns that can be passed straight to `.hint()`.
295
+ *
296
+ * ONE compound index carries the whole read story (plus `_id`) — same shape
297
+ * as the other materialized collections:
298
+ * `tenant_id__scope_context__scope_field__day_index` — UNIQUE:
299
+ * - identity — one document per (tenant, scope context, scope value);
300
+ * `day_index` is a deterministic function of `scope_field` (null for period
301
+ * scopes), so including it keeps the uniqueness exactly on that identity;
302
+ * - the drill-down read — the `{ tenant_id, scope_context, scope_field }`
303
+ * prefix serves exact and ranged scope-field queries (covering-set
304
+ * resolution) for single tenants and `$in` tenant lists.
305
+ *
306
+ * There are NO `brand_id` indexes: brand-level reads always pass the brand's
307
+ * explicit tenant list (`tenant_id: { $in }`).
308
+ */
309
+ export declare const MATERIALIZED_TENANT_CREDIT_BILLS_COLLECTION_INDEXES: {
310
+ _id: {
311
+ _id: number;
312
+ };
313
+ tenant_id__scope_context__scope_field__day_index: {
314
+ tenant_id: number;
315
+ scope_context: number;
316
+ scope_field: number;
317
+ day_index: number;
318
+ };
319
+ };
320
+ /**
321
+ * Index OPTIONS the materializer must CREATE — the identity index is a UNIQUE
322
+ * business invariant (one document per tenant × scope context × scope value;
323
+ * the close-day writes upsert against it and silently degrade without it),
324
+ * so it must be created with `unique: true`. The key patterns above are what
325
+ * the read `.hint()` consumes; these options are what creation must apply.
326
+ * The materializer boot should assert them (`listIndexes`, fail closed).
327
+ */
328
+ export declare const MATERIALIZED_TENANT_CREDIT_BILLS_INDEX_OPTIONS: {
329
+ key: {
330
+ tenant_id: number;
331
+ scope_context: number;
332
+ scope_field: number;
333
+ day_index: number;
334
+ };
335
+ name: string;
336
+ unique: boolean;
337
+ }[];