@managesome/eposmatic-toolkit 0.4.22 → 0.4.24
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 +83 -2
- package/esm/helpers/materialized-reports/index.js +3 -0
- package/esm/helpers/materialized-reports/materialized-discount-accumulator-helpers.js +115 -35
- package/esm/helpers/materialized-reports/materialized-discount-classification-helpers.js +39 -12
- package/esm/helpers/materialized-reports/materialized-discount-details-helpers.js +28 -0
- package/esm/helpers/materialized-reports/materialized-discount-source-helpers.js +428 -0
- package/esm/helpers/materialized-reports/tenant-discount-source-formatter.js +140 -0
- package/esm/schemas/models/index.js +1 -0
- package/esm/schemas/models/materialized_rider_daily_reports.js +0 -4
- package/esm/schemas/models/materialized_tenant_discount_entries.js +12 -0
- package/esm/schemas/models/materialized_tenant_discount_sources.js +165 -0
- package/esm/schemas/models/tenant_hr_attendance_records.js +5 -6
- package/esm/schemas/models/tenant_hr_shift_schedules.js +1 -1
- package/esm/schemas/types/index.js +1 -0
- package/esm/schemas/types/materialized_tenant_discount_sources.js +1 -0
- package/lib/constants/MATERIALIZED_REPORTS.d.ts +79 -2
- package/lib/constants/MATERIALIZED_REPORTS.js +85 -4
- package/lib/helpers/materialized-reports/index.d.ts +3 -0
- package/lib/helpers/materialized-reports/index.js +3 -0
- package/lib/helpers/materialized-reports/materialized-discount-accumulator-helpers.d.ts +30 -0
- package/lib/helpers/materialized-reports/materialized-discount-accumulator-helpers.js +116 -35
- package/lib/helpers/materialized-reports/materialized-discount-classification-helpers.d.ts +27 -4
- package/lib/helpers/materialized-reports/materialized-discount-classification-helpers.js +38 -11
- package/lib/helpers/materialized-reports/materialized-discount-details-helpers.d.ts +31 -0
- package/lib/helpers/materialized-reports/materialized-discount-details-helpers.js +31 -0
- package/lib/helpers/materialized-reports/materialized-discount-source-helpers.d.ts +73 -0
- package/lib/helpers/materialized-reports/materialized-discount-source-helpers.js +437 -0
- package/lib/helpers/materialized-reports/tenant-discount-source-formatter.d.ts +79 -0
- package/lib/helpers/materialized-reports/tenant-discount-source-formatter.js +144 -0
- package/lib/helpers/types/materialized-reports-apis.d.ts +53 -1
- package/lib/schemas/models/index.d.ts +1 -0
- package/lib/schemas/models/index.js +1 -0
- package/lib/schemas/models/materialized_rider_daily_reports.js +0 -4
- package/lib/schemas/models/materialized_tenant_discount_entries.d.ts +21 -6
- package/lib/schemas/models/materialized_tenant_discount_entries.js +12 -0
- package/lib/schemas/models/materialized_tenant_discount_sources.d.ts +331 -0
- package/lib/schemas/models/materialized_tenant_discount_sources.js +168 -0
- package/lib/schemas/models/tenant_hr_attendance_records.d.ts +3 -3
- package/lib/schemas/models/tenant_hr_attendance_records.js +5 -6
- package/lib/schemas/models/tenant_hr_shift_schedules.d.ts +3 -3
- package/lib/schemas/models/tenant_hr_shift_schedules.js +1 -1
- package/lib/schemas/types/index.d.ts +1 -0
- package/lib/schemas/types/index.js +1 -0
- package/lib/schemas/types/materialized_tenant_discount_entries.d.ts +26 -0
- package/lib/schemas/types/materialized_tenant_discount_sources.d.ts +128 -0
- package/lib/schemas/types/materialized_tenant_discount_sources.js +2 -0
- package/lib/schemas/types/tenant_hr_attendance_records.d.ts +1 -1
- package/lib/schemas/types/tenant_hr_shift_schedules.d.ts +1 -1
- package/lib/tests/materialized-reports/materialized-discount-classification.test.js +22 -2
- package/lib/tests/materialized-reports/materialized-discount-details-helpers.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-discount-details-helpers.test.js +59 -0
- package/lib/tests/materialized-reports/materialized-discount-sources.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-discount-sources.test.js +483 -0
- package/lib/tests/materialized-reports/tenant-discount-source-formatter.test.d.ts +1 -0
- package/lib/tests/materialized-reports/tenant-discount-source-formatter.test.js +203 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MATERIALIZED_REPORT_SCOPE_ENUM, MATERIALIZED_REPORT_TYPE_ENUM, REPORT_SALE_TYPE_ENUM } from '../../constants';
|
|
2
|
-
import { MATERIALIZED_DISCOUNT_ENTRY_KIND_ENUM, MATERIALIZED_DISCOUNT_LEVEL_ENUM, MATERIALIZED_DISCOUNT_SLOT_ENUM, MATERIALIZED_DISCOUNT_SUB_KIND_ENUM, MATERIALIZED_REPORT_KEY_FILTER_ENUM, SALES_COMPARISON_BASELINE_ENUM } from '../../constants/MATERIALIZED_REPORTS';
|
|
2
|
+
import { MATERIALIZED_DISCOUNT_ENTRY_KIND_ENUM, MATERIALIZED_DISCOUNT_LEVEL_ENUM, MATERIALIZED_DISCOUNT_RATE_KIND_ENUM, MATERIALIZED_DISCOUNT_SLOT_ENUM, MATERIALIZED_DISCOUNT_SOURCE_CLASS_ENUM, MATERIALIZED_DISCOUNT_SUB_KIND_ENUM, MATERIALIZED_REPORT_KEY_FILTER_ENUM, SALES_COMPARISON_BASELINE_ENUM } from '../../constants/MATERIALIZED_REPORTS';
|
|
3
3
|
import { IMaterializedDiscountOrderCounters } from '../../schemas/types/materialized_tenant_discount_reports';
|
|
4
4
|
import { IMaterializedPrepTimeCounters } from '../../schemas/types/materialized_tenant_prep_time_reports';
|
|
5
5
|
import { IMaterializedSalesComparisonCounters, IMaterializedSalesComparisonCounterRow } from '../../schemas/types/materialized_tenant_sales_comparison_reports';
|
|
@@ -221,6 +221,10 @@ export interface IMaterializedDiscountDetailsRow {
|
|
|
221
221
|
order_number: number | null;
|
|
222
222
|
item_id: string | null;
|
|
223
223
|
item_name: string | null;
|
|
224
|
+
/** The catalog item id (the id a catalog-auto discount writes). */
|
|
225
|
+
catalog_item_id?: string | null;
|
|
226
|
+
/** True when the row is the item's own catalog/special/half-half discount. */
|
|
227
|
+
catalog_auto?: boolean | null;
|
|
224
228
|
/** The MONEY this row applied, in CENTS (the raw rate rides on `rate`). */
|
|
225
229
|
amount: number;
|
|
226
230
|
rate: number | null;
|
|
@@ -229,6 +233,14 @@ export interface IMaterializedDiscountDetailsRow {
|
|
|
229
233
|
name: string | null;
|
|
230
234
|
reference_number: string | null;
|
|
231
235
|
reason: string | null;
|
|
236
|
+
/** COMPLIMENTARY rows: full vs partial (null on legacy rows). */
|
|
237
|
+
complimentary_full?: boolean | null;
|
|
238
|
+
/** COMPLIMENTARY rows: the amount this tender covered, in CENTS. */
|
|
239
|
+
covered_amount?: number | null;
|
|
240
|
+
/** COMPLIMENTARY rows: the order amount used for the full/partial test. */
|
|
241
|
+
order_amount?: number | null;
|
|
242
|
+
/** FREE_ITEM rows: the discounted item's own value, in CENTS. */
|
|
243
|
+
item_value?: number | null;
|
|
232
244
|
staff_id: string | null;
|
|
233
245
|
staff_name: string | null;
|
|
234
246
|
order_status: string;
|
|
@@ -236,6 +248,46 @@ export interface IMaterializedDiscountDetailsRow {
|
|
|
236
248
|
created_at: Date;
|
|
237
249
|
local_hour: string | null;
|
|
238
250
|
}
|
|
251
|
+
/**
|
|
252
|
+
* One folded source row of `POST /reports/discounts/sources`.
|
|
253
|
+
*
|
|
254
|
+
* This is the "By discount" table's row: one discount source at one level,
|
|
255
|
+
* summed over the DISJOINT scope groups of the selection. Amounts are CENTS.
|
|
256
|
+
* `order_count` is distinct orders within the selection; it is only meaningful
|
|
257
|
+
* because the read never folds overlapping scopes.
|
|
258
|
+
*/
|
|
259
|
+
export interface IMaterializedTenantDiscountSourceRow {
|
|
260
|
+
source_key: string;
|
|
261
|
+
source_id: string | null;
|
|
262
|
+
source_name: string;
|
|
263
|
+
source_class: MATERIALIZED_DISCOUNT_SOURCE_CLASS_ENUM;
|
|
264
|
+
kind: MATERIALIZED_DISCOUNT_ENTRY_KIND_ENUM;
|
|
265
|
+
level: MATERIALIZED_DISCOUNT_LEVEL_ENUM;
|
|
266
|
+
slot: MATERIALIZED_DISCOUNT_SLOT_ENUM | null;
|
|
267
|
+
sub_kind: MATERIALIZED_DISCOUNT_SUB_KIND_ENUM;
|
|
268
|
+
/** Average percentage rate; null for a fixed-only or mixed source. */
|
|
269
|
+
rate: number | null;
|
|
270
|
+
rate_kind: MATERIALIZED_DISCOUNT_RATE_KIND_ENUM | null;
|
|
271
|
+
order_count: number;
|
|
272
|
+
row_count: number;
|
|
273
|
+
/** Resolved discount money (CENTS). Zero for COMPLIMENTARY. */
|
|
274
|
+
discount_amount: number;
|
|
275
|
+
free_item_count: number;
|
|
276
|
+
free_item_value: number;
|
|
277
|
+
/** COMPLIMENTARY only: true = full, false = partial, null = unknown. */
|
|
278
|
+
complimentary_full: boolean | null;
|
|
279
|
+
/** COMPLIMENTARY only: tender coverage (CENTS). */
|
|
280
|
+
covered_amount: number;
|
|
281
|
+
}
|
|
282
|
+
/** One tenant's source read (`POST /reports/discounts/sources`). */
|
|
283
|
+
export interface IMaterializedTenantDiscountSourcesReport {
|
|
284
|
+
tenant_id: string;
|
|
285
|
+
brand_id: string;
|
|
286
|
+
max_updated_at: Date | null;
|
|
287
|
+
matched_documents: number;
|
|
288
|
+
sale_type_key_filters: MATERIALIZED_REPORT_KEY_FILTER_ENUM[];
|
|
289
|
+
sources: IMaterializedTenantDiscountSourceRow[];
|
|
290
|
+
}
|
|
239
291
|
/**
|
|
240
292
|
* Page cursor of the drill-down: strictly-after on
|
|
241
293
|
* `(time DESC, order_id ASC, entry_key ASC)`. `entry_key` is the row's stable
|
|
@@ -29,6 +29,7 @@ export * from './marketing_fingerprints';
|
|
|
29
29
|
export * from './materialized_credit_bills';
|
|
30
30
|
export * from './materialized_tenant_discount_entries';
|
|
31
31
|
export * from './materialized_tenant_discount_reports';
|
|
32
|
+
export * from './materialized_tenant_discount_sources';
|
|
32
33
|
export * from './materialized_tenant_cash_entries';
|
|
33
34
|
export * from './materialized_tenant_delivery_entries';
|
|
34
35
|
export * from './materialized_tenant_delivery_reports';
|
|
@@ -45,6 +45,7 @@ __exportStar(require("./marketing_fingerprints"), exports);
|
|
|
45
45
|
__exportStar(require("./materialized_credit_bills"), exports);
|
|
46
46
|
__exportStar(require("./materialized_tenant_discount_entries"), exports);
|
|
47
47
|
__exportStar(require("./materialized_tenant_discount_reports"), exports);
|
|
48
|
+
__exportStar(require("./materialized_tenant_discount_sources"), exports);
|
|
48
49
|
__exportStar(require("./materialized_tenant_cash_entries"), exports);
|
|
49
50
|
__exportStar(require("./materialized_tenant_delivery_entries"), exports);
|
|
50
51
|
__exportStar(require("./materialized_tenant_delivery_reports"), exports);
|
|
@@ -37,10 +37,6 @@ exports.MATERIALIZED_RIDER_DAILY_REPORTS_COLLECTION_INDEXES = {
|
|
|
37
37
|
_id: { _id: 1 },
|
|
38
38
|
rider_id__local_date: { rider_id: 1, local_date: 1 },
|
|
39
39
|
};
|
|
40
|
-
exports.MaterializedRiderDailyReportSchema.index(exports.MATERIALIZED_RIDER_DAILY_REPORTS_COLLECTION_INDEXES.rider_id__local_date, {
|
|
41
|
-
unique: true,
|
|
42
|
-
name: 'rider_id__local_date',
|
|
43
|
-
});
|
|
44
40
|
exports.MATERIALIZED_RIDER_DAILY_REPORTS_INDEX_OPTIONS = [
|
|
45
41
|
{
|
|
46
42
|
key: exports.MATERIALIZED_RIDER_DAILY_REPORTS_COLLECTION_INDEXES.rider_id__local_date,
|
|
@@ -33,15 +33,20 @@ declare const DiscountEntrySchema: Schema<any, import("mongoose").Model<any, any
|
|
|
33
33
|
platform: string;
|
|
34
34
|
slot: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_SLOT_ENUM | null;
|
|
35
35
|
item_id: string;
|
|
36
|
-
discount_id: string;
|
|
37
36
|
sub_kind: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_SUB_KIND_ENUM;
|
|
37
|
+
discount_id: string;
|
|
38
|
+
reference_number: string;
|
|
39
|
+
catalog_item_id: string;
|
|
40
|
+
covered_amount: number;
|
|
41
|
+
order_amount: number;
|
|
38
42
|
level: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_LEVEL_ENUM;
|
|
39
43
|
entry_key: string;
|
|
40
44
|
kind: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_ENTRY_KIND_ENUM;
|
|
45
|
+
catalog_auto: boolean;
|
|
41
46
|
item_name: string;
|
|
42
47
|
rate: number;
|
|
43
48
|
item_value: number;
|
|
44
|
-
|
|
49
|
+
complimentary_full: boolean;
|
|
45
50
|
order_taker_id: string;
|
|
46
51
|
order_taker_name: string;
|
|
47
52
|
created_at: NativeDate;
|
|
@@ -60,15 +65,20 @@ declare const DiscountEntrySchema: Schema<any, import("mongoose").Model<any, any
|
|
|
60
65
|
platform: string;
|
|
61
66
|
slot: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_SLOT_ENUM | null;
|
|
62
67
|
item_id: string;
|
|
63
|
-
discount_id: string;
|
|
64
68
|
sub_kind: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_SUB_KIND_ENUM;
|
|
69
|
+
discount_id: string;
|
|
70
|
+
reference_number: string;
|
|
71
|
+
catalog_item_id: string;
|
|
72
|
+
covered_amount: number;
|
|
73
|
+
order_amount: number;
|
|
65
74
|
level: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_LEVEL_ENUM;
|
|
66
75
|
entry_key: string;
|
|
67
76
|
kind: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_ENTRY_KIND_ENUM;
|
|
77
|
+
catalog_auto: boolean;
|
|
68
78
|
item_name: string;
|
|
69
79
|
rate: number;
|
|
70
80
|
item_value: number;
|
|
71
|
-
|
|
81
|
+
complimentary_full: boolean;
|
|
72
82
|
order_taker_id: string;
|
|
73
83
|
order_taker_name: string;
|
|
74
84
|
created_at: NativeDate;
|
|
@@ -87,15 +97,20 @@ declare const DiscountEntrySchema: Schema<any, import("mongoose").Model<any, any
|
|
|
87
97
|
platform: string;
|
|
88
98
|
slot: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_SLOT_ENUM | null;
|
|
89
99
|
item_id: string;
|
|
90
|
-
discount_id: string;
|
|
91
100
|
sub_kind: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_SUB_KIND_ENUM;
|
|
101
|
+
discount_id: string;
|
|
102
|
+
reference_number: string;
|
|
103
|
+
catalog_item_id: string;
|
|
104
|
+
covered_amount: number;
|
|
105
|
+
order_amount: number;
|
|
92
106
|
level: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_LEVEL_ENUM;
|
|
93
107
|
entry_key: string;
|
|
94
108
|
kind: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_ENTRY_KIND_ENUM;
|
|
109
|
+
catalog_auto: boolean;
|
|
95
110
|
item_name: string;
|
|
96
111
|
rate: number;
|
|
97
112
|
item_value: number;
|
|
98
|
-
|
|
113
|
+
complimentary_full: boolean;
|
|
99
114
|
order_taker_id: string;
|
|
100
115
|
order_taker_name: string;
|
|
101
116
|
created_at: NativeDate;
|
|
@@ -31,7 +31,14 @@ const DiscountEntrySchema = new mongoose_1.Schema({
|
|
|
31
31
|
entry_key: { type: String, required: true },
|
|
32
32
|
order_id: { type: String, required: true },
|
|
33
33
|
order_number: { type: Number, default: null },
|
|
34
|
+
// The ORDER ITEM's _id (part of entry_key).
|
|
34
35
|
item_id: { type: String, default: null },
|
|
36
|
+
// The CATALOG item id — the id a catalog-auto discount writes. Kept
|
|
37
|
+
// separate so a 24-hex catalog id can never be mistaken for a collection
|
|
38
|
+
// discount id after the fact.
|
|
39
|
+
catalog_item_id: { type: String, default: null },
|
|
40
|
+
// True for the item's own catalog/special/half-half auto discount.
|
|
41
|
+
catalog_auto: { type: Boolean, default: null },
|
|
35
42
|
item_name: { type: String, default: null },
|
|
36
43
|
payment_id: { type: String, default: null },
|
|
37
44
|
// Raw slot value (PERCENT for percentage rows) — NEVER money.
|
|
@@ -44,6 +51,11 @@ const DiscountEntrySchema = new mongoose_1.Schema({
|
|
|
44
51
|
name: { type: String, default: null },
|
|
45
52
|
reference_number: { type: String, default: null },
|
|
46
53
|
reason: { type: String, default: null },
|
|
54
|
+
// COMPLIMENTARY rows: full vs partial + the amount the tender covered.
|
|
55
|
+
// Null/absent on rows written before this metadata existed.
|
|
56
|
+
complimentary_full: { type: Boolean, default: null },
|
|
57
|
+
covered_amount: { type: Number, default: null },
|
|
58
|
+
order_amount: { type: Number, default: null },
|
|
47
59
|
staff_id: { type: String, default: null },
|
|
48
60
|
staff_name: { type: String, default: null },
|
|
49
61
|
order_taker_id: { type: String, default: null },
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import { Schema } from 'mongoose';
|
|
2
|
+
/**
|
|
3
|
+
* Mongoose schema for `materialized_tenant_discount_sources` — the DERIVED
|
|
4
|
+
* "by discount" projection of the discounts report (see
|
|
5
|
+
* `schemas/types/materialized_tenant_discount_sources.ts`).
|
|
6
|
+
*
|
|
7
|
+
* One document per (tenant, scope context, scope field, source key, level).
|
|
8
|
+
* The top-level metrics are the sum of `key_metrics`, which carries the
|
|
9
|
+
* `ORDER_STATUS:PLATFORM` split so the report filters stay exact.
|
|
10
|
+
*
|
|
11
|
+
* This collection is REBUILT from the post-plan entry documents in the close
|
|
12
|
+
* transaction. It has no iteration history of its own: the parent entry
|
|
13
|
+
* documents are the audit trail.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Version of the source-projection rules. Bump when the source identity,
|
|
17
|
+
* grouping or rate rule changes — historical documents must then be rebuilt
|
|
18
|
+
* with the backfill script.
|
|
19
|
+
*/
|
|
20
|
+
export declare const MATERIALIZED_TENANT_DISCOUNT_SOURCES_SCHEMA_VERSION = 1;
|
|
21
|
+
declare const DiscountSourceKeyMetricsSchema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
22
|
+
_id: false;
|
|
23
|
+
}, {
|
|
24
|
+
discount_amount: number;
|
|
25
|
+
order_count: number;
|
|
26
|
+
key: string;
|
|
27
|
+
covered_amount: number;
|
|
28
|
+
row_count: number;
|
|
29
|
+
free_item_count: number;
|
|
30
|
+
free_item_value: number;
|
|
31
|
+
percentage_row_count: number;
|
|
32
|
+
percentage_rate_sum: number;
|
|
33
|
+
fixed_row_count: number;
|
|
34
|
+
}, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
|
|
35
|
+
discount_amount: number;
|
|
36
|
+
order_count: number;
|
|
37
|
+
key: string;
|
|
38
|
+
covered_amount: number;
|
|
39
|
+
row_count: number;
|
|
40
|
+
free_item_count: number;
|
|
41
|
+
free_item_value: number;
|
|
42
|
+
percentage_row_count: number;
|
|
43
|
+
percentage_rate_sum: number;
|
|
44
|
+
fixed_row_count: number;
|
|
45
|
+
}>> & import("mongoose").FlatRecord<{
|
|
46
|
+
discount_amount: number;
|
|
47
|
+
order_count: number;
|
|
48
|
+
key: string;
|
|
49
|
+
covered_amount: number;
|
|
50
|
+
row_count: number;
|
|
51
|
+
free_item_count: number;
|
|
52
|
+
free_item_value: number;
|
|
53
|
+
percentage_row_count: number;
|
|
54
|
+
percentage_rate_sum: number;
|
|
55
|
+
fixed_row_count: number;
|
|
56
|
+
}> & {
|
|
57
|
+
_id: import("mongoose").Types.ObjectId;
|
|
58
|
+
} & {
|
|
59
|
+
__v: number;
|
|
60
|
+
}>;
|
|
61
|
+
export declare const MaterializedTenantDiscountSourceSchema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
62
|
+
timestamps: true;
|
|
63
|
+
versionKey: false;
|
|
64
|
+
minimize: false;
|
|
65
|
+
}, {
|
|
66
|
+
createdAt: NativeDate;
|
|
67
|
+
updatedAt: NativeDate;
|
|
68
|
+
} & {
|
|
69
|
+
_id: import("mongoose").Types.ObjectId;
|
|
70
|
+
createdAt: NativeDate;
|
|
71
|
+
updatedAt: NativeDate;
|
|
72
|
+
brand_id: string;
|
|
73
|
+
discount_amount: number;
|
|
74
|
+
tenant_id: string;
|
|
75
|
+
day_index: import("../../constants/ENUMS").DAY_INDEX_ENUM | null;
|
|
76
|
+
order_count: number;
|
|
77
|
+
slot: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_SLOT_ENUM | null;
|
|
78
|
+
source_id: string;
|
|
79
|
+
source_name: string;
|
|
80
|
+
scope_context: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_REPORT_SCOPE_ENUM;
|
|
81
|
+
scope_field: string;
|
|
82
|
+
sale_type_key_filters: string[];
|
|
83
|
+
schema_version: number;
|
|
84
|
+
source_watermark: NativeDate;
|
|
85
|
+
computed_at: NativeDate;
|
|
86
|
+
sub_kind: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_SUB_KIND_ENUM;
|
|
87
|
+
covered_amount: number;
|
|
88
|
+
level: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_LEVEL_ENUM;
|
|
89
|
+
kind: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_ENTRY_KIND_ENUM;
|
|
90
|
+
rate: number;
|
|
91
|
+
complimentary_full: boolean;
|
|
92
|
+
row_count: number;
|
|
93
|
+
free_item_count: number;
|
|
94
|
+
free_item_value: number;
|
|
95
|
+
percentage_row_count: number;
|
|
96
|
+
percentage_rate_sum: number;
|
|
97
|
+
fixed_row_count: number;
|
|
98
|
+
source_key: string;
|
|
99
|
+
source_class: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_SOURCE_CLASS_ENUM;
|
|
100
|
+
rate_kind: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_RATE_KIND_ENUM | null;
|
|
101
|
+
key_metrics: import("mongoose").Types.DocumentArray<{
|
|
102
|
+
discount_amount: number;
|
|
103
|
+
order_count: number;
|
|
104
|
+
key: string;
|
|
105
|
+
covered_amount: number;
|
|
106
|
+
row_count: number;
|
|
107
|
+
free_item_count: number;
|
|
108
|
+
free_item_value: number;
|
|
109
|
+
percentage_row_count: number;
|
|
110
|
+
percentage_rate_sum: number;
|
|
111
|
+
fixed_row_count: number;
|
|
112
|
+
}, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
|
|
113
|
+
discount_amount: number;
|
|
114
|
+
order_count: number;
|
|
115
|
+
key: string;
|
|
116
|
+
covered_amount: number;
|
|
117
|
+
row_count: number;
|
|
118
|
+
free_item_count: number;
|
|
119
|
+
free_item_value: number;
|
|
120
|
+
percentage_row_count: number;
|
|
121
|
+
percentage_rate_sum: number;
|
|
122
|
+
fixed_row_count: number;
|
|
123
|
+
}> & {
|
|
124
|
+
discount_amount: number;
|
|
125
|
+
order_count: number;
|
|
126
|
+
key: string;
|
|
127
|
+
covered_amount: number;
|
|
128
|
+
row_count: number;
|
|
129
|
+
free_item_count: number;
|
|
130
|
+
free_item_value: number;
|
|
131
|
+
percentage_row_count: number;
|
|
132
|
+
percentage_rate_sum: number;
|
|
133
|
+
fixed_row_count: number;
|
|
134
|
+
}>;
|
|
135
|
+
}, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
|
|
136
|
+
createdAt: NativeDate;
|
|
137
|
+
updatedAt: NativeDate;
|
|
138
|
+
} & {
|
|
139
|
+
_id: import("mongoose").Types.ObjectId;
|
|
140
|
+
createdAt: NativeDate;
|
|
141
|
+
updatedAt: NativeDate;
|
|
142
|
+
brand_id: string;
|
|
143
|
+
discount_amount: number;
|
|
144
|
+
tenant_id: string;
|
|
145
|
+
day_index: import("../../constants/ENUMS").DAY_INDEX_ENUM | null;
|
|
146
|
+
order_count: number;
|
|
147
|
+
slot: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_SLOT_ENUM | null;
|
|
148
|
+
source_id: string;
|
|
149
|
+
source_name: string;
|
|
150
|
+
scope_context: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_REPORT_SCOPE_ENUM;
|
|
151
|
+
scope_field: string;
|
|
152
|
+
sale_type_key_filters: string[];
|
|
153
|
+
schema_version: number;
|
|
154
|
+
source_watermark: NativeDate;
|
|
155
|
+
computed_at: NativeDate;
|
|
156
|
+
sub_kind: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_SUB_KIND_ENUM;
|
|
157
|
+
covered_amount: number;
|
|
158
|
+
level: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_LEVEL_ENUM;
|
|
159
|
+
kind: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_ENTRY_KIND_ENUM;
|
|
160
|
+
rate: number;
|
|
161
|
+
complimentary_full: boolean;
|
|
162
|
+
row_count: number;
|
|
163
|
+
free_item_count: number;
|
|
164
|
+
free_item_value: number;
|
|
165
|
+
percentage_row_count: number;
|
|
166
|
+
percentage_rate_sum: number;
|
|
167
|
+
fixed_row_count: number;
|
|
168
|
+
source_key: string;
|
|
169
|
+
source_class: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_SOURCE_CLASS_ENUM;
|
|
170
|
+
rate_kind: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_RATE_KIND_ENUM | null;
|
|
171
|
+
key_metrics: import("mongoose").Types.DocumentArray<{
|
|
172
|
+
discount_amount: number;
|
|
173
|
+
order_count: number;
|
|
174
|
+
key: string;
|
|
175
|
+
covered_amount: number;
|
|
176
|
+
row_count: number;
|
|
177
|
+
free_item_count: number;
|
|
178
|
+
free_item_value: number;
|
|
179
|
+
percentage_row_count: number;
|
|
180
|
+
percentage_rate_sum: number;
|
|
181
|
+
fixed_row_count: number;
|
|
182
|
+
}, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
|
|
183
|
+
discount_amount: number;
|
|
184
|
+
order_count: number;
|
|
185
|
+
key: string;
|
|
186
|
+
covered_amount: number;
|
|
187
|
+
row_count: number;
|
|
188
|
+
free_item_count: number;
|
|
189
|
+
free_item_value: number;
|
|
190
|
+
percentage_row_count: number;
|
|
191
|
+
percentage_rate_sum: number;
|
|
192
|
+
fixed_row_count: number;
|
|
193
|
+
}> & {
|
|
194
|
+
discount_amount: number;
|
|
195
|
+
order_count: number;
|
|
196
|
+
key: string;
|
|
197
|
+
covered_amount: number;
|
|
198
|
+
row_count: number;
|
|
199
|
+
free_item_count: number;
|
|
200
|
+
free_item_value: number;
|
|
201
|
+
percentage_row_count: number;
|
|
202
|
+
percentage_rate_sum: number;
|
|
203
|
+
fixed_row_count: number;
|
|
204
|
+
}>;
|
|
205
|
+
}>> & import("mongoose").FlatRecord<{
|
|
206
|
+
createdAt: NativeDate;
|
|
207
|
+
updatedAt: NativeDate;
|
|
208
|
+
} & {
|
|
209
|
+
_id: import("mongoose").Types.ObjectId;
|
|
210
|
+
createdAt: NativeDate;
|
|
211
|
+
updatedAt: NativeDate;
|
|
212
|
+
brand_id: string;
|
|
213
|
+
discount_amount: number;
|
|
214
|
+
tenant_id: string;
|
|
215
|
+
day_index: import("../../constants/ENUMS").DAY_INDEX_ENUM | null;
|
|
216
|
+
order_count: number;
|
|
217
|
+
slot: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_SLOT_ENUM | null;
|
|
218
|
+
source_id: string;
|
|
219
|
+
source_name: string;
|
|
220
|
+
scope_context: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_REPORT_SCOPE_ENUM;
|
|
221
|
+
scope_field: string;
|
|
222
|
+
sale_type_key_filters: string[];
|
|
223
|
+
schema_version: number;
|
|
224
|
+
source_watermark: NativeDate;
|
|
225
|
+
computed_at: NativeDate;
|
|
226
|
+
sub_kind: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_SUB_KIND_ENUM;
|
|
227
|
+
covered_amount: number;
|
|
228
|
+
level: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_LEVEL_ENUM;
|
|
229
|
+
kind: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_ENTRY_KIND_ENUM;
|
|
230
|
+
rate: number;
|
|
231
|
+
complimentary_full: boolean;
|
|
232
|
+
row_count: number;
|
|
233
|
+
free_item_count: number;
|
|
234
|
+
free_item_value: number;
|
|
235
|
+
percentage_row_count: number;
|
|
236
|
+
percentage_rate_sum: number;
|
|
237
|
+
fixed_row_count: number;
|
|
238
|
+
source_key: string;
|
|
239
|
+
source_class: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_SOURCE_CLASS_ENUM;
|
|
240
|
+
rate_kind: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_RATE_KIND_ENUM | null;
|
|
241
|
+
key_metrics: import("mongoose").Types.DocumentArray<{
|
|
242
|
+
discount_amount: number;
|
|
243
|
+
order_count: number;
|
|
244
|
+
key: string;
|
|
245
|
+
covered_amount: number;
|
|
246
|
+
row_count: number;
|
|
247
|
+
free_item_count: number;
|
|
248
|
+
free_item_value: number;
|
|
249
|
+
percentage_row_count: number;
|
|
250
|
+
percentage_rate_sum: number;
|
|
251
|
+
fixed_row_count: number;
|
|
252
|
+
}, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
|
|
253
|
+
discount_amount: number;
|
|
254
|
+
order_count: number;
|
|
255
|
+
key: string;
|
|
256
|
+
covered_amount: number;
|
|
257
|
+
row_count: number;
|
|
258
|
+
free_item_count: number;
|
|
259
|
+
free_item_value: number;
|
|
260
|
+
percentage_row_count: number;
|
|
261
|
+
percentage_rate_sum: number;
|
|
262
|
+
fixed_row_count: number;
|
|
263
|
+
}> & {
|
|
264
|
+
discount_amount: number;
|
|
265
|
+
order_count: number;
|
|
266
|
+
key: string;
|
|
267
|
+
covered_amount: number;
|
|
268
|
+
row_count: number;
|
|
269
|
+
free_item_count: number;
|
|
270
|
+
free_item_value: number;
|
|
271
|
+
percentage_row_count: number;
|
|
272
|
+
percentage_rate_sum: number;
|
|
273
|
+
fixed_row_count: number;
|
|
274
|
+
}>;
|
|
275
|
+
}> & Required<{
|
|
276
|
+
_id: import("mongoose").Types.ObjectId;
|
|
277
|
+
}> & {
|
|
278
|
+
__v: number;
|
|
279
|
+
}>;
|
|
280
|
+
export { DiscountSourceKeyMetricsSchema };
|
|
281
|
+
export declare const MATERIALIZED_TENANT_DISCOUNT_SOURCES_COLLECTION_NAME = "materialized_tenant_discount_sources";
|
|
282
|
+
/**
|
|
283
|
+
* Indexes for `materialized_tenant_discount_sources`.
|
|
284
|
+
*
|
|
285
|
+
* Compound keys are named by their field path (`field__field__field`), matching
|
|
286
|
+
* every other materialized collection's index constants.
|
|
287
|
+
*
|
|
288
|
+
* - `tenant_id__scope_context__scope_field__source_key__level` is the
|
|
289
|
+
* write-side upsert/delete key and the scope prefix every historical read
|
|
290
|
+
* uses.
|
|
291
|
+
* - `tenant_id__scope_context__scope_field__discount_amount` serves the
|
|
292
|
+
* "biggest source first" sort inside a scope.
|
|
293
|
+
*/
|
|
294
|
+
export declare const MATERIALIZED_TENANT_DISCOUNT_SOURCES_COLLECTION_INDEXES: {
|
|
295
|
+
_id: {
|
|
296
|
+
_id: number;
|
|
297
|
+
};
|
|
298
|
+
tenant_id__scope_context__scope_field__source_key__level: {
|
|
299
|
+
tenant_id: number;
|
|
300
|
+
scope_context: number;
|
|
301
|
+
scope_field: number;
|
|
302
|
+
source_key: number;
|
|
303
|
+
level: number;
|
|
304
|
+
};
|
|
305
|
+
tenant_id__scope_context__scope_field__discount_amount: {
|
|
306
|
+
tenant_id: number;
|
|
307
|
+
scope_context: number;
|
|
308
|
+
scope_field: number;
|
|
309
|
+
discount_amount: number;
|
|
310
|
+
};
|
|
311
|
+
};
|
|
312
|
+
export declare const MATERIALIZED_TENANT_DISCOUNT_SOURCES_INDEX_OPTIONS: ({
|
|
313
|
+
key: {
|
|
314
|
+
tenant_id: number;
|
|
315
|
+
scope_context: number;
|
|
316
|
+
scope_field: number;
|
|
317
|
+
source_key: number;
|
|
318
|
+
level: number;
|
|
319
|
+
};
|
|
320
|
+
name: string;
|
|
321
|
+
unique: boolean;
|
|
322
|
+
} | {
|
|
323
|
+
key: {
|
|
324
|
+
tenant_id: number;
|
|
325
|
+
scope_context: number;
|
|
326
|
+
scope_field: number;
|
|
327
|
+
discount_amount: number;
|
|
328
|
+
};
|
|
329
|
+
name: string;
|
|
330
|
+
unique?: undefined;
|
|
331
|
+
})[];
|