@managesome/eposmatic-toolkit 0.4.52 → 0.4.54
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 +106 -2
- package/esm/constants/enums/delivery.js +13 -0
- package/esm/helpers/materialized-reports/index.js +6 -0
- package/esm/helpers/materialized-reports/materialized-delivery-accumulator-helpers.js +8 -62
- package/esm/helpers/materialized-reports/materialized-delivery-classification-helpers.js +95 -73
- package/esm/helpers/materialized-reports/materialized-delivery-close-day-helpers.js +118 -146
- package/esm/helpers/materialized-reports/materialized-delivery-compile-helpers.js +304 -71
- package/esm/helpers/materialized-reports/materialized-delivery-entry-pages.js +307 -0
- package/esm/helpers/materialized-reports/materialized-delivery-index-migration.js +103 -0
- package/esm/helpers/materialized-reports/materialized-delivery-rows.js +109 -0
- package/esm/helpers/materialized-reports/materialized-delivery-wipe-targets.js +32 -0
- package/esm/helpers/materialized-reports/materialized-document-size.js +65 -0
- package/esm/helpers/materialized-reports/materialized-index-bootstrap.js +31 -16
- package/esm/helpers/materialized-reports/materialized-integer-contract.js +10 -1
- package/esm/helpers/materialized-reports/materialized-prep-time-close-day-helpers.js +3 -91
- package/esm/helpers/materialized-reports/materialized-tenant-delivery-geo-helpers.js +597 -0
- package/esm/helpers/materialized-reports/report-platform/definition.js +508 -0
- package/esm/helpers/materialized-reports/report-platform/index.js +4 -0
- package/esm/helpers/materialized-reports/report-platform/lifecycle/budget.js +27 -0
- package/esm/helpers/materialized-reports/report-platform/lifecycle/cap-metadata.js +12 -0
- package/esm/helpers/materialized-reports/report-platform/lifecycle/entry-pages.js +121 -0
- package/esm/helpers/materialized-reports/report-platform/lifecycle/flat-projection.js +14 -0
- package/esm/helpers/materialized-reports/report-platform/lifecycle/index.js +8 -0
- package/esm/helpers/materialized-reports/report-platform/lifecycle/iteration-row.js +10 -0
- package/esm/helpers/materialized-reports/report-platform/lifecycle/run-stats.js +42 -0
- package/esm/helpers/materialized-reports/report-platform/lifecycle/scope-refs.js +28 -0
- package/esm/helpers/materialized-reports/report-platform/lifecycle/top-n.js +24 -0
- package/esm/helpers/materialized-reports/report-platform/registry.js +23 -0
- package/esm/helpers/materialized-reports/report-platform/validate-report-registry.js +214 -0
- package/esm/helpers/materialized-reports/scope-helpers.js +98 -0
- package/esm/helpers/materialized-reports/tenant-delivery-formatter.js +70 -20
- package/esm/schemas/models/applied_order_discounts.js +103 -0
- package/esm/schemas/models/index.js +12 -10
- package/esm/schemas/models/materialized_tenant_delivery_entries.js +33 -12
- package/esm/schemas/models/materialized_tenant_delivery_geo_cells.js +83 -0
- package/esm/schemas/models/materialized_tenant_delivery_geo_scopes.js +35 -0
- package/esm/schemas/models/materialized_tenant_delivery_reports.js +10 -1
- package/esm/schemas/types/applied_order_discounts.js +1 -0
- package/esm/schemas/types/index.js +14 -12
- package/esm/schemas/types/materialized_tenant_delivery_geo_cells.js +1 -0
- package/esm/schemas/types/materialized_tenant_delivery_geo_scopes.js +1 -0
- package/lib/constants/MATERIALIZED_REPORTS.d.ts +95 -1
- package/lib/constants/MATERIALIZED_REPORTS.js +108 -4
- package/lib/constants/enums/delivery.d.ts +9 -0
- package/lib/constants/enums/delivery.js +14 -1
- package/lib/helpers/materialized-reports/index.d.ts +6 -0
- package/lib/helpers/materialized-reports/index.js +6 -0
- package/lib/helpers/materialized-reports/materialized-delivery-accumulator-helpers.js +8 -62
- package/lib/helpers/materialized-reports/materialized-delivery-classification-helpers.d.ts +36 -9
- package/lib/helpers/materialized-reports/materialized-delivery-classification-helpers.js +94 -72
- package/lib/helpers/materialized-reports/materialized-delivery-close-day-helpers.d.ts +23 -26
- package/lib/helpers/materialized-reports/materialized-delivery-close-day-helpers.js +121 -150
- package/lib/helpers/materialized-reports/materialized-delivery-compile-helpers.d.ts +44 -5
- package/lib/helpers/materialized-reports/materialized-delivery-compile-helpers.js +306 -69
- package/lib/helpers/materialized-reports/materialized-delivery-entry-pages.d.ts +128 -0
- package/lib/helpers/materialized-reports/materialized-delivery-entry-pages.js +322 -0
- package/lib/helpers/materialized-reports/materialized-delivery-index-migration.d.ts +48 -0
- package/lib/helpers/materialized-reports/materialized-delivery-index-migration.js +108 -0
- package/lib/helpers/materialized-reports/materialized-delivery-rows.d.ts +15 -0
- package/lib/helpers/materialized-reports/materialized-delivery-rows.js +115 -0
- package/lib/helpers/materialized-reports/materialized-delivery-wipe-targets.d.ts +17 -0
- package/lib/helpers/materialized-reports/materialized-delivery-wipe-targets.js +35 -0
- package/lib/helpers/materialized-reports/materialized-document-size.d.ts +47 -0
- package/lib/helpers/materialized-reports/materialized-document-size.js +73 -0
- package/lib/helpers/materialized-reports/materialized-index-bootstrap.js +28 -13
- package/lib/helpers/materialized-reports/materialized-integer-contract.js +10 -1
- package/lib/helpers/materialized-reports/materialized-prep-time-close-day-helpers.js +2 -90
- package/lib/helpers/materialized-reports/materialized-tenant-delivery-geo-helpers.d.ts +186 -0
- package/lib/helpers/materialized-reports/materialized-tenant-delivery-geo-helpers.js +620 -0
- package/lib/helpers/materialized-reports/report-platform/definition.d.ts +133 -0
- package/lib/helpers/materialized-reports/report-platform/definition.js +511 -0
- package/lib/helpers/materialized-reports/report-platform/index.d.ts +4 -0
- package/lib/helpers/materialized-reports/report-platform/index.js +20 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/budget.d.ts +8 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/budget.js +31 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/cap-metadata.d.ts +8 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/cap-metadata.js +16 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/entry-pages.d.ts +40 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/entry-pages.js +130 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/flat-projection.d.ts +22 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/flat-projection.js +17 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/index.d.ts +8 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/index.js +24 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/iteration-row.d.ts +13 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/iteration-row.js +13 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/run-stats.d.ts +20 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/run-stats.js +47 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/scope-refs.d.ts +13 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/scope-refs.js +31 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/top-n.d.ts +16 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/top-n.js +29 -0
- package/lib/helpers/materialized-reports/report-platform/registry.d.ts +13 -0
- package/lib/helpers/materialized-reports/report-platform/registry.js +31 -0
- package/lib/helpers/materialized-reports/report-platform/validate-report-registry.d.ts +20 -0
- package/lib/helpers/materialized-reports/report-platform/validate-report-registry.js +218 -0
- package/lib/helpers/materialized-reports/scope-helpers.d.ts +8 -0
- package/lib/helpers/materialized-reports/scope-helpers.js +99 -0
- package/lib/helpers/materialized-reports/tenant-delivery-formatter.d.ts +41 -0
- package/lib/helpers/materialized-reports/tenant-delivery-formatter.js +70 -20
- package/lib/helpers/order/payment-collection.d.ts +25 -0
- package/lib/helpers/order/payment-collection.js +51 -0
- package/lib/schemas/models/applied_order_discounts.d.ts +80 -0
- package/lib/schemas/models/applied_order_discounts.js +106 -0
- package/lib/schemas/models/index.d.ts +12 -10
- package/lib/schemas/models/index.js +12 -10
- package/lib/schemas/models/materialized_tenant_delivery_entries.d.ts +31 -9
- package/lib/schemas/models/materialized_tenant_delivery_entries.js +32 -11
- package/lib/schemas/models/materialized_tenant_delivery_geo_cells.d.ts +129 -0
- package/lib/schemas/models/materialized_tenant_delivery_geo_cells.js +86 -0
- package/lib/schemas/models/materialized_tenant_delivery_geo_scopes.d.ts +71 -0
- package/lib/schemas/models/materialized_tenant_delivery_geo_scopes.js +38 -0
- package/lib/schemas/models/materialized_tenant_delivery_reports.d.ts +10 -1
- package/lib/schemas/models/materialized_tenant_delivery_reports.js +10 -1
- package/lib/schemas/models/materialized_tenant_discount_sources.d.ts +15 -15
- package/lib/schemas/types/applied_order_discounts.d.ts +22 -0
- package/lib/schemas/types/applied_order_discounts.js +2 -0
- package/lib/schemas/types/index.d.ts +14 -12
- package/lib/schemas/types/index.js +14 -12
- package/lib/schemas/types/materialized_tenant_delivery_entries.d.ts +36 -4
- package/lib/schemas/types/materialized_tenant_delivery_geo_cells.d.ts +178 -0
- package/lib/schemas/types/materialized_tenant_delivery_geo_cells.js +2 -0
- package/lib/schemas/types/materialized_tenant_delivery_geo_scopes.d.ts +21 -0
- package/lib/schemas/types/materialized_tenant_delivery_geo_scopes.js +2 -0
- package/lib/schemas/types/materialized_tenant_delivery_reports.d.ts +49 -7
- package/lib/tests/materialized-reports/analytics-growth-helpers.test.d.ts +1 -0
- package/lib/tests/materialized-reports/analytics-overview-helpers.test.d.ts +1 -0
- package/lib/tests/materialized-reports/analytics-performance-helpers.test.d.ts +1 -0
- package/lib/tests/materialized-reports/characterization/delivery.characterization.test.d.ts +1 -0
- package/lib/tests/materialized-reports/characterization/delivery.characterization.test.js +229 -0
- package/lib/tests/materialized-reports/characterization/discount.characterization.test.d.ts +1 -0
- package/lib/tests/materialized-reports/characterization/discount.characterization.test.js +99 -0
- package/lib/tests/materialized-reports/characterization/fixtures.d.ts +30 -0
- package/lib/tests/materialized-reports/characterization/fixtures.js +402 -0
- package/lib/tests/materialized-reports/characterization/golden.d.ts +18 -0
- package/lib/tests/materialized-reports/characterization/golden.js +127 -0
- package/lib/tests/materialized-reports/characterization/overview.characterization.test.d.ts +1 -0
- package/lib/tests/materialized-reports/characterization/overview.characterization.test.js +69 -0
- package/lib/tests/materialized-reports/characterization/prep-time.characterization.test.d.ts +1 -0
- package/lib/tests/materialized-reports/characterization/prep-time.characterization.test.js +102 -0
- package/lib/tests/materialized-reports/materialized-delivery-accumulation.test.js +56 -19
- package/lib/tests/materialized-reports/materialized-delivery-budgets.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-delivery-budgets.test.js +91 -0
- package/lib/tests/materialized-reports/materialized-delivery-compile.test.js +271 -15
- package/lib/tests/materialized-reports/materialized-delivery-final-audit.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-delivery-final-audit.test.js +128 -0
- package/lib/tests/materialized-reports/materialized-delivery-fold.test.js +42 -5
- package/lib/tests/materialized-reports/materialized-delivery-formatter.test.js +13 -1
- package/lib/tests/materialized-reports/materialized-delivery-geo.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-delivery-geo.test.js +446 -0
- package/lib/tests/materialized-reports/materialized-delivery-plan.test.js +117 -25
- package/lib/tests/materialized-reports/materialized-delivery-practical.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-delivery-practical.test.js +344 -0
- package/lib/tests/materialized-reports/materialized-integer-contract.test.js +14 -0
- package/lib/tests/materialized-reports/materialized-tenant-sales-overview-reports-schema.test.js +1 -1
- package/lib/tests/materialized-reports/report-platform/lifecycle-primitives.test.d.ts +1 -0
- package/lib/tests/materialized-reports/report-platform/lifecycle-primitives.test.js +177 -0
- package/lib/tests/materialized-reports/report-platform/registry-conformance.test.d.ts +1 -0
- package/lib/tests/materialized-reports/report-platform/registry-conformance.test.js +214 -0
- package/lib/tests/materialized-reports/report-platform/registry-validation.test.d.ts +1 -0
- package/lib/tests/materialized-reports/report-platform/registry-validation.test.js +103 -0
- package/lib/tests/offer-item-resolution.test.js +1 -4
- package/lib/tests/payment-collection-timestamps.test.d.ts +1 -0
- package/lib/tests/payment-collection-timestamps.test.js +71 -0
- package/package.json +6 -2
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MATERIALIZED_TENANT_DELIVERY_GEO_CELLS_INDEX_OPTIONS = exports.MATERIALIZED_TENANT_DELIVERY_GEO_CELLS_COLLECTION_INDEXES = exports.MATERIALIZED_TENANT_DELIVERY_GEO_CELLS_COLLECTION_NAME = exports.MaterializedTenantDeliveryGeoCellSchema = void 0;
|
|
4
|
+
const mongoose_1 = require("mongoose");
|
|
5
|
+
const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
|
|
6
|
+
/**
|
|
7
|
+
* Mongoose schema for `materialized_tenant_delivery_geo_cells`.
|
|
8
|
+
*
|
|
9
|
+
* `location` is `Mixed` and DELIBERATELY has no default: the unknown bucket must be
|
|
10
|
+
* written WITHOUT the field, because a 2dsphere index cannot extract a geo key from
|
|
11
|
+
* `null`. A missing field is simply not indexed, which is exactly the intent - the
|
|
12
|
+
* unknown aggregate must never be plottable.
|
|
13
|
+
*
|
|
14
|
+
* `city` is nullable: an order whose joined `delivery_details` has no city still
|
|
15
|
+
* counts in the cell (the position is what the heat map plots), it just carries no
|
|
16
|
+
* label.
|
|
17
|
+
*/
|
|
18
|
+
exports.MaterializedTenantDeliveryGeoCellSchema = new mongoose_1.Schema({
|
|
19
|
+
tenant_id: { type: String, required: true },
|
|
20
|
+
brand_id: { type: String, required: true },
|
|
21
|
+
scope_context: { type: String, required: true, enum: MATERIALIZED_REPORTS_1.MATERIALIZED_DELIVERY_GEO_SCOPES },
|
|
22
|
+
scope_field: { type: String, required: true },
|
|
23
|
+
city: { type: String, default: null },
|
|
24
|
+
h3_cell: { type: String, required: true },
|
|
25
|
+
resolution: { type: Number, required: true, min: 0, max: 15 },
|
|
26
|
+
location: { type: mongoose_1.Schema.Types.Mixed, required: false },
|
|
27
|
+
/** Bounded ORDER_STATUS:PLATFORM:CITY counters; sum equals the top-level counters. */
|
|
28
|
+
by_key: { type: mongoose_1.Schema.Types.Mixed, required: false, default: null },
|
|
29
|
+
// ---- counters (integer counts; money in CENTS) ----
|
|
30
|
+
orders: { type: Number, required: true, min: 0, default: 0 },
|
|
31
|
+
app_orders: { type: Number, required: true, min: 0, default: 0 },
|
|
32
|
+
delivery_records: { type: Number, required: true, min: 0, default: 0 },
|
|
33
|
+
completed: { type: Number, required: true, min: 0, default: 0 },
|
|
34
|
+
cancelled: { type: Number, required: true, min: 0, default: 0 },
|
|
35
|
+
net_sale_amount: { type: Number, required: true, default: 0 },
|
|
36
|
+
delivery_charge_amount: { type: Number, required: true, default: 0 },
|
|
37
|
+
rider_revenue_amount: { type: Number, required: true, default: 0 },
|
|
38
|
+
schema_version: {
|
|
39
|
+
type: Number,
|
|
40
|
+
required: true,
|
|
41
|
+
immutable: true,
|
|
42
|
+
default: MATERIALIZED_REPORTS_1.MATERIALIZED_TENANT_DELIVERY_GEO_CELLS_SCHEMA_VERSION,
|
|
43
|
+
},
|
|
44
|
+
computed_at: { type: mongoose_1.Schema.Types.Date, required: true },
|
|
45
|
+
createdAt: { type: mongoose_1.Schema.Types.Date, required: true, default: () => new Date(), immutable: true },
|
|
46
|
+
updatedAt: { type: mongoose_1.Schema.Types.Date, required: true, default: () => new Date() },
|
|
47
|
+
}, { timestamps: true, versionKey: false });
|
|
48
|
+
exports.MATERIALIZED_TENANT_DELIVERY_GEO_CELLS_COLLECTION_NAME = 'materialized_tenant_delivery_geo_cells';
|
|
49
|
+
/**
|
|
50
|
+
* The indexes the heat reads/writes assume:
|
|
51
|
+
* 1. the UNIQUE cell identity (one document per tenant/scope/cell);
|
|
52
|
+
* 2. the map's read path - a scope, busiest cells first;
|
|
53
|
+
* 3. the 2dsphere index a future viewport `$geoWithin` read needs.
|
|
54
|
+
*
|
|
55
|
+
* The unknown bucket has no `location`, so it is absent from (3) by design.
|
|
56
|
+
*/
|
|
57
|
+
exports.MATERIALIZED_TENANT_DELIVERY_GEO_CELLS_COLLECTION_INDEXES = {
|
|
58
|
+
_id: { _id: 1 },
|
|
59
|
+
tenant_id__scope_context__scope_field__h3_cell: {
|
|
60
|
+
tenant_id: 1,
|
|
61
|
+
scope_context: 1,
|
|
62
|
+
scope_field: 1,
|
|
63
|
+
h3_cell: 1,
|
|
64
|
+
},
|
|
65
|
+
scope_context__scope_field__orders: {
|
|
66
|
+
scope_context: 1,
|
|
67
|
+
scope_field: 1,
|
|
68
|
+
orders: -1,
|
|
69
|
+
},
|
|
70
|
+
location__2dsphere: { location: '2dsphere' },
|
|
71
|
+
};
|
|
72
|
+
exports.MATERIALIZED_TENANT_DELIVERY_GEO_CELLS_INDEX_OPTIONS = [
|
|
73
|
+
{
|
|
74
|
+
key: { tenant_id: 1, scope_context: 1, scope_field: 1, h3_cell: 1 },
|
|
75
|
+
name: 'tenant_id__scope_context__scope_field__h3_cell',
|
|
76
|
+
unique: true,
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
key: { scope_context: 1, scope_field: 1, orders: -1 },
|
|
80
|
+
name: 'scope_context__scope_field__orders',
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
key: { location: '2dsphere' },
|
|
84
|
+
name: 'location__2dsphere',
|
|
85
|
+
},
|
|
86
|
+
];
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Schema } from 'mongoose';
|
|
2
|
+
/** Per-scope cap metadata; never one document per cell. */
|
|
3
|
+
export declare const MaterializedTenantDeliveryGeoScopeSchema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
4
|
+
timestamps: true;
|
|
5
|
+
versionKey: false;
|
|
6
|
+
}, {
|
|
7
|
+
createdAt: NativeDate;
|
|
8
|
+
updatedAt: NativeDate;
|
|
9
|
+
} & {
|
|
10
|
+
createdAt: NativeDate;
|
|
11
|
+
updatedAt: NativeDate;
|
|
12
|
+
brand_id: string;
|
|
13
|
+
tenant_id: string;
|
|
14
|
+
scope_context: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_REPORT_SCOPE_ENUM;
|
|
15
|
+
scope_field: string;
|
|
16
|
+
schema_version: number;
|
|
17
|
+
computed_at: NativeDate;
|
|
18
|
+
capped_cell_count: number;
|
|
19
|
+
capped_order_count: number;
|
|
20
|
+
}, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
|
|
21
|
+
createdAt: NativeDate;
|
|
22
|
+
updatedAt: NativeDate;
|
|
23
|
+
} & {
|
|
24
|
+
createdAt: NativeDate;
|
|
25
|
+
updatedAt: NativeDate;
|
|
26
|
+
brand_id: string;
|
|
27
|
+
tenant_id: string;
|
|
28
|
+
scope_context: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_REPORT_SCOPE_ENUM;
|
|
29
|
+
scope_field: string;
|
|
30
|
+
schema_version: number;
|
|
31
|
+
computed_at: NativeDate;
|
|
32
|
+
capped_cell_count: number;
|
|
33
|
+
capped_order_count: number;
|
|
34
|
+
}>> & import("mongoose").FlatRecord<{
|
|
35
|
+
createdAt: NativeDate;
|
|
36
|
+
updatedAt: NativeDate;
|
|
37
|
+
} & {
|
|
38
|
+
createdAt: NativeDate;
|
|
39
|
+
updatedAt: NativeDate;
|
|
40
|
+
brand_id: string;
|
|
41
|
+
tenant_id: string;
|
|
42
|
+
scope_context: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_REPORT_SCOPE_ENUM;
|
|
43
|
+
scope_field: string;
|
|
44
|
+
schema_version: number;
|
|
45
|
+
computed_at: NativeDate;
|
|
46
|
+
capped_cell_count: number;
|
|
47
|
+
capped_order_count: number;
|
|
48
|
+
}> & {
|
|
49
|
+
_id: import("mongoose").Types.ObjectId;
|
|
50
|
+
} & {
|
|
51
|
+
__v: number;
|
|
52
|
+
}>;
|
|
53
|
+
export declare const MATERIALIZED_TENANT_DELIVERY_GEO_SCOPES_COLLECTION_INDEXES: {
|
|
54
|
+
_id: {
|
|
55
|
+
_id: number;
|
|
56
|
+
};
|
|
57
|
+
tenant_id__scope_context__scope_field: {
|
|
58
|
+
tenant_id: number;
|
|
59
|
+
scope_context: number;
|
|
60
|
+
scope_field: number;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
export declare const MATERIALIZED_TENANT_DELIVERY_GEO_SCOPES_INDEX_OPTIONS: {
|
|
64
|
+
key: {
|
|
65
|
+
tenant_id: number;
|
|
66
|
+
scope_context: number;
|
|
67
|
+
scope_field: number;
|
|
68
|
+
};
|
|
69
|
+
name: string;
|
|
70
|
+
unique: boolean;
|
|
71
|
+
}[];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MATERIALIZED_TENANT_DELIVERY_GEO_SCOPES_INDEX_OPTIONS = exports.MATERIALIZED_TENANT_DELIVERY_GEO_SCOPES_COLLECTION_INDEXES = exports.MaterializedTenantDeliveryGeoScopeSchema = void 0;
|
|
4
|
+
const mongoose_1 = require("mongoose");
|
|
5
|
+
const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
|
|
6
|
+
/** Per-scope cap metadata; never one document per cell. */
|
|
7
|
+
exports.MaterializedTenantDeliveryGeoScopeSchema = new mongoose_1.Schema({
|
|
8
|
+
tenant_id: { type: String, required: true },
|
|
9
|
+
brand_id: { type: String, required: true },
|
|
10
|
+
scope_context: { type: String, required: true, enum: MATERIALIZED_REPORTS_1.MATERIALIZED_DELIVERY_GEO_SCOPES },
|
|
11
|
+
scope_field: { type: String, required: true },
|
|
12
|
+
capped_cell_count: { type: Number, required: true, min: 0, default: 0 },
|
|
13
|
+
capped_order_count: { type: Number, required: true, min: 0, default: 0 },
|
|
14
|
+
schema_version: {
|
|
15
|
+
type: Number,
|
|
16
|
+
required: true,
|
|
17
|
+
immutable: true,
|
|
18
|
+
default: MATERIALIZED_REPORTS_1.MATERIALIZED_TENANT_DELIVERY_GEO_SCOPES_SCHEMA_VERSION,
|
|
19
|
+
},
|
|
20
|
+
computed_at: { type: mongoose_1.Schema.Types.Date, required: true },
|
|
21
|
+
createdAt: { type: mongoose_1.Schema.Types.Date, required: true, default: () => new Date(), immutable: true },
|
|
22
|
+
updatedAt: { type: mongoose_1.Schema.Types.Date, required: true, default: () => new Date() },
|
|
23
|
+
}, { timestamps: true, versionKey: false });
|
|
24
|
+
exports.MATERIALIZED_TENANT_DELIVERY_GEO_SCOPES_COLLECTION_INDEXES = {
|
|
25
|
+
_id: { _id: 1 },
|
|
26
|
+
tenant_id__scope_context__scope_field: {
|
|
27
|
+
tenant_id: 1,
|
|
28
|
+
scope_context: 1,
|
|
29
|
+
scope_field: 1,
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
exports.MATERIALIZED_TENANT_DELIVERY_GEO_SCOPES_INDEX_OPTIONS = [
|
|
33
|
+
{
|
|
34
|
+
key: { tenant_id: 1, scope_context: 1, scope_field: 1 },
|
|
35
|
+
name: 'tenant_id__scope_context__scope_field',
|
|
36
|
+
unique: true,
|
|
37
|
+
},
|
|
38
|
+
];
|
|
@@ -6,7 +6,16 @@ import { Schema } from 'mongoose';
|
|
|
6
6
|
* bounded sub-documents (rider / area leaderboards with an hour heat map), which Mongoose
|
|
7
7
|
* cannot type precisely without a fixed key set - the keys ARE the data.
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* v2 - the production day-close writer.
|
|
11
|
+
*
|
|
12
|
+
* v1 was the pre-production shape. v2 splits the AREA row into the ORDER-side
|
|
13
|
+
* (`delivery_orders`, net sale, fees) and the APP-side (`delivery_records`, payout)
|
|
14
|
+
* populations, keys the demand heat on the joined ORDER's `localHour`, and fixes the
|
|
15
|
+
* refund source to the payment rows. A v1 document is still readable: the formatter
|
|
16
|
+
* falls back to the old `count` field for the record total.
|
|
17
|
+
*/
|
|
18
|
+
export declare const MATERIALIZED_TENANT_DELIVERY_REPORTS_SCHEMA_VERSION = 2;
|
|
10
19
|
export declare const MaterializedTenantDeliveryReportSchema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
11
20
|
timestamps: true;
|
|
12
21
|
versionKey: false;
|
|
@@ -11,7 +11,16 @@ const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
|
|
|
11
11
|
* bounded sub-documents (rider / area leaderboards with an hour heat map), which Mongoose
|
|
12
12
|
* cannot type precisely without a fixed key set - the keys ARE the data.
|
|
13
13
|
*/
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* v2 - the production day-close writer.
|
|
16
|
+
*
|
|
17
|
+
* v1 was the pre-production shape. v2 splits the AREA row into the ORDER-side
|
|
18
|
+
* (`delivery_orders`, net sale, fees) and the APP-side (`delivery_records`, payout)
|
|
19
|
+
* populations, keys the demand heat on the joined ORDER's `localHour`, and fixes the
|
|
20
|
+
* refund source to the payment rows. A v1 document is still readable: the formatter
|
|
21
|
+
* falls back to the old `count` field for the record total.
|
|
22
|
+
*/
|
|
23
|
+
exports.MATERIALIZED_TENANT_DELIVERY_REPORTS_SCHEMA_VERSION = 2;
|
|
15
24
|
exports.MaterializedTenantDeliveryReportSchema = new mongoose_1.Schema({
|
|
16
25
|
tenant_id: { type: String, required: true },
|
|
17
26
|
brand_id: { type: String, required: true },
|
|
@@ -24,8 +24,8 @@ declare const DiscountSourceKeyMetricsSchema: Schema<any, import("mongoose").Mod
|
|
|
24
24
|
discount_amount: number;
|
|
25
25
|
order_count: number;
|
|
26
26
|
key: string;
|
|
27
|
-
covered_amount: number;
|
|
28
27
|
row_count: number;
|
|
28
|
+
covered_amount: number;
|
|
29
29
|
free_item_count: number;
|
|
30
30
|
free_item_value: number;
|
|
31
31
|
percentage_row_count: number;
|
|
@@ -35,8 +35,8 @@ declare const DiscountSourceKeyMetricsSchema: Schema<any, import("mongoose").Mod
|
|
|
35
35
|
discount_amount: number;
|
|
36
36
|
order_count: number;
|
|
37
37
|
key: string;
|
|
38
|
-
covered_amount: number;
|
|
39
38
|
row_count: number;
|
|
39
|
+
covered_amount: number;
|
|
40
40
|
free_item_count: number;
|
|
41
41
|
free_item_value: number;
|
|
42
42
|
percentage_row_count: number;
|
|
@@ -46,8 +46,8 @@ declare const DiscountSourceKeyMetricsSchema: Schema<any, import("mongoose").Mod
|
|
|
46
46
|
discount_amount: number;
|
|
47
47
|
order_count: number;
|
|
48
48
|
key: string;
|
|
49
|
-
covered_amount: number;
|
|
50
49
|
row_count: number;
|
|
50
|
+
covered_amount: number;
|
|
51
51
|
free_item_count: number;
|
|
52
52
|
free_item_value: number;
|
|
53
53
|
percentage_row_count: number;
|
|
@@ -83,12 +83,12 @@ export declare const MaterializedTenantDiscountSourceSchema: Schema<any, import(
|
|
|
83
83
|
schema_version: number;
|
|
84
84
|
source_watermark: NativeDate;
|
|
85
85
|
computed_at: NativeDate;
|
|
86
|
+
row_count: number;
|
|
86
87
|
kind: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_ENTRY_KIND_ENUM;
|
|
87
88
|
sub_kind: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_SUB_KIND_ENUM;
|
|
88
89
|
level: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_LEVEL_ENUM;
|
|
89
90
|
complimentary_full: boolean;
|
|
90
91
|
covered_amount: number;
|
|
91
|
-
row_count: number;
|
|
92
92
|
free_item_count: number;
|
|
93
93
|
free_item_value: number;
|
|
94
94
|
percentage_row_count: number;
|
|
@@ -101,8 +101,8 @@ export declare const MaterializedTenantDiscountSourceSchema: Schema<any, import(
|
|
|
101
101
|
discount_amount: number;
|
|
102
102
|
order_count: number;
|
|
103
103
|
key: string;
|
|
104
|
-
covered_amount: number;
|
|
105
104
|
row_count: number;
|
|
105
|
+
covered_amount: number;
|
|
106
106
|
free_item_count: number;
|
|
107
107
|
free_item_value: number;
|
|
108
108
|
percentage_row_count: number;
|
|
@@ -112,8 +112,8 @@ export declare const MaterializedTenantDiscountSourceSchema: Schema<any, import(
|
|
|
112
112
|
discount_amount: number;
|
|
113
113
|
order_count: number;
|
|
114
114
|
key: string;
|
|
115
|
-
covered_amount: number;
|
|
116
115
|
row_count: number;
|
|
116
|
+
covered_amount: number;
|
|
117
117
|
free_item_count: number;
|
|
118
118
|
free_item_value: number;
|
|
119
119
|
percentage_row_count: number;
|
|
@@ -123,8 +123,8 @@ export declare const MaterializedTenantDiscountSourceSchema: Schema<any, import(
|
|
|
123
123
|
discount_amount: number;
|
|
124
124
|
order_count: number;
|
|
125
125
|
key: string;
|
|
126
|
-
covered_amount: number;
|
|
127
126
|
row_count: number;
|
|
127
|
+
covered_amount: number;
|
|
128
128
|
free_item_count: number;
|
|
129
129
|
free_item_value: number;
|
|
130
130
|
percentage_row_count: number;
|
|
@@ -152,12 +152,12 @@ export declare const MaterializedTenantDiscountSourceSchema: Schema<any, import(
|
|
|
152
152
|
schema_version: number;
|
|
153
153
|
source_watermark: NativeDate;
|
|
154
154
|
computed_at: NativeDate;
|
|
155
|
+
row_count: number;
|
|
155
156
|
kind: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_ENTRY_KIND_ENUM;
|
|
156
157
|
sub_kind: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_SUB_KIND_ENUM;
|
|
157
158
|
level: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_LEVEL_ENUM;
|
|
158
159
|
complimentary_full: boolean;
|
|
159
160
|
covered_amount: number;
|
|
160
|
-
row_count: number;
|
|
161
161
|
free_item_count: number;
|
|
162
162
|
free_item_value: number;
|
|
163
163
|
percentage_row_count: number;
|
|
@@ -170,8 +170,8 @@ export declare const MaterializedTenantDiscountSourceSchema: Schema<any, import(
|
|
|
170
170
|
discount_amount: number;
|
|
171
171
|
order_count: number;
|
|
172
172
|
key: string;
|
|
173
|
-
covered_amount: number;
|
|
174
173
|
row_count: number;
|
|
174
|
+
covered_amount: number;
|
|
175
175
|
free_item_count: number;
|
|
176
176
|
free_item_value: number;
|
|
177
177
|
percentage_row_count: number;
|
|
@@ -181,8 +181,8 @@ export declare const MaterializedTenantDiscountSourceSchema: Schema<any, import(
|
|
|
181
181
|
discount_amount: number;
|
|
182
182
|
order_count: number;
|
|
183
183
|
key: string;
|
|
184
|
-
covered_amount: number;
|
|
185
184
|
row_count: number;
|
|
185
|
+
covered_amount: number;
|
|
186
186
|
free_item_count: number;
|
|
187
187
|
free_item_value: number;
|
|
188
188
|
percentage_row_count: number;
|
|
@@ -192,8 +192,8 @@ export declare const MaterializedTenantDiscountSourceSchema: Schema<any, import(
|
|
|
192
192
|
discount_amount: number;
|
|
193
193
|
order_count: number;
|
|
194
194
|
key: string;
|
|
195
|
-
covered_amount: number;
|
|
196
195
|
row_count: number;
|
|
196
|
+
covered_amount: number;
|
|
197
197
|
free_item_count: number;
|
|
198
198
|
free_item_value: number;
|
|
199
199
|
percentage_row_count: number;
|
|
@@ -221,12 +221,12 @@ export declare const MaterializedTenantDiscountSourceSchema: Schema<any, import(
|
|
|
221
221
|
schema_version: number;
|
|
222
222
|
source_watermark: NativeDate;
|
|
223
223
|
computed_at: NativeDate;
|
|
224
|
+
row_count: number;
|
|
224
225
|
kind: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_ENTRY_KIND_ENUM;
|
|
225
226
|
sub_kind: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_SUB_KIND_ENUM;
|
|
226
227
|
level: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_DISCOUNT_LEVEL_ENUM;
|
|
227
228
|
complimentary_full: boolean;
|
|
228
229
|
covered_amount: number;
|
|
229
|
-
row_count: number;
|
|
230
230
|
free_item_count: number;
|
|
231
231
|
free_item_value: number;
|
|
232
232
|
percentage_row_count: number;
|
|
@@ -239,8 +239,8 @@ export declare const MaterializedTenantDiscountSourceSchema: Schema<any, import(
|
|
|
239
239
|
discount_amount: number;
|
|
240
240
|
order_count: number;
|
|
241
241
|
key: string;
|
|
242
|
-
covered_amount: number;
|
|
243
242
|
row_count: number;
|
|
243
|
+
covered_amount: number;
|
|
244
244
|
free_item_count: number;
|
|
245
245
|
free_item_value: number;
|
|
246
246
|
percentage_row_count: number;
|
|
@@ -250,8 +250,8 @@ export declare const MaterializedTenantDiscountSourceSchema: Schema<any, import(
|
|
|
250
250
|
discount_amount: number;
|
|
251
251
|
order_count: number;
|
|
252
252
|
key: string;
|
|
253
|
-
covered_amount: number;
|
|
254
253
|
row_count: number;
|
|
254
|
+
covered_amount: number;
|
|
255
255
|
free_item_count: number;
|
|
256
256
|
free_item_value: number;
|
|
257
257
|
percentage_row_count: number;
|
|
@@ -261,8 +261,8 @@ export declare const MaterializedTenantDiscountSourceSchema: Schema<any, import(
|
|
|
261
261
|
discount_amount: number;
|
|
262
262
|
order_count: number;
|
|
263
263
|
key: string;
|
|
264
|
-
covered_amount: number;
|
|
265
264
|
row_count: number;
|
|
265
|
+
covered_amount: number;
|
|
266
266
|
free_item_count: number;
|
|
267
267
|
free_item_value: number;
|
|
268
268
|
percentage_row_count: number;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { DISCOUNT_APPLICABILITY_ENUM, DISCOUNT_TYPE_ENUM, PLATFORMS_ENUM } from '../../constants';
|
|
2
|
+
export interface IAppliedOrderDiscount {
|
|
3
|
+
_id: string;
|
|
4
|
+
tenant_id: string;
|
|
5
|
+
order_id: string;
|
|
6
|
+
discount_id: string;
|
|
7
|
+
type: DISCOUNT_TYPE_ENUM;
|
|
8
|
+
applicability: DISCOUNT_APPLICABILITY_ENUM;
|
|
9
|
+
platform: PLATFORMS_ENUM;
|
|
10
|
+
name: string;
|
|
11
|
+
order_amount: number;
|
|
12
|
+
discount_amount: number;
|
|
13
|
+
discount_rate: number | null;
|
|
14
|
+
reason: string;
|
|
15
|
+
reference_number: string | null;
|
|
16
|
+
staff_id: string;
|
|
17
|
+
staff_phone: string;
|
|
18
|
+
staff_name: string;
|
|
19
|
+
createdAt_mins: number;
|
|
20
|
+
createdAt: Date;
|
|
21
|
+
updatedAt: Date;
|
|
22
|
+
}
|
|
@@ -31,17 +31,26 @@ export * from './item_transactions';
|
|
|
31
31
|
export * from './items';
|
|
32
32
|
export * from './marketing_fingerprints';
|
|
33
33
|
export * from './materialized_credit_bills';
|
|
34
|
-
export * from './
|
|
35
|
-
export * from './
|
|
36
|
-
export * from './materialized_tenant_discount_sources';
|
|
34
|
+
export * from './materialized_report_drilldown_rows';
|
|
35
|
+
export * from './materialized_rider_daily_reports';
|
|
37
36
|
export * from './materialized_tenant_cash_entries';
|
|
37
|
+
export * from './materialized_tenant_cash_reports';
|
|
38
38
|
export * from './materialized_tenant_delivery_entries';
|
|
39
|
+
export * from './materialized_tenant_delivery_geo_cells';
|
|
40
|
+
export * from './materialized_tenant_delivery_geo_scopes';
|
|
39
41
|
export * from './materialized_tenant_delivery_reports';
|
|
40
|
-
export * from './
|
|
41
|
-
export * from './
|
|
42
|
+
export * from './materialized_tenant_discount_entries';
|
|
43
|
+
export * from './materialized_tenant_discount_reports';
|
|
44
|
+
export * from './materialized_tenant_discount_sources';
|
|
45
|
+
export * from './materialized_tenant_hourly_comparison_entries';
|
|
46
|
+
export * from './materialized_tenant_hourly_comparison_reports';
|
|
47
|
+
export * from './materialized_tenant_payments_comparison_entries';
|
|
48
|
+
export * from './materialized_tenant_payments_comparison_reports';
|
|
42
49
|
export * from './materialized_tenant_prep_time_entries';
|
|
43
50
|
export * from './materialized_tenant_prep_time_reports';
|
|
44
51
|
export * from './materialized_tenant_reports_iterations';
|
|
52
|
+
export * from './materialized_tenant_sales_comparison_entries';
|
|
53
|
+
export * from './materialized_tenant_sales_comparison_reports';
|
|
45
54
|
export * from './materialized_tenant_sales_overview_reports';
|
|
46
55
|
export * from './menus';
|
|
47
56
|
export * from './messaging_devices';
|
|
@@ -124,10 +133,3 @@ export * from './warehouse_vendors';
|
|
|
124
133
|
export * from './warehouse_void_purchase_order_items';
|
|
125
134
|
export * from './warehouse_void_sale_order_items';
|
|
126
135
|
export * from './warehouses';
|
|
127
|
-
export * from './materialized_tenant_sales_comparison_reports';
|
|
128
|
-
export * from './materialized_tenant_sales_comparison_entries';
|
|
129
|
-
export * from './materialized_tenant_hourly_comparison_reports';
|
|
130
|
-
export * from './materialized_tenant_hourly_comparison_entries';
|
|
131
|
-
export * from './materialized_tenant_payments_comparison_reports';
|
|
132
|
-
export * from './materialized_tenant_payments_comparison_entries';
|
|
133
|
-
export * from './materialized_report_drilldown_rows';
|
|
@@ -47,17 +47,26 @@ __exportStar(require("./item_transactions"), exports);
|
|
|
47
47
|
__exportStar(require("./items"), exports);
|
|
48
48
|
__exportStar(require("./marketing_fingerprints"), exports);
|
|
49
49
|
__exportStar(require("./materialized_credit_bills"), exports);
|
|
50
|
-
__exportStar(require("./
|
|
51
|
-
__exportStar(require("./
|
|
52
|
-
__exportStar(require("./materialized_tenant_discount_sources"), exports);
|
|
50
|
+
__exportStar(require("./materialized_report_drilldown_rows"), exports);
|
|
51
|
+
__exportStar(require("./materialized_rider_daily_reports"), exports);
|
|
53
52
|
__exportStar(require("./materialized_tenant_cash_entries"), exports);
|
|
53
|
+
__exportStar(require("./materialized_tenant_cash_reports"), exports);
|
|
54
54
|
__exportStar(require("./materialized_tenant_delivery_entries"), exports);
|
|
55
|
+
__exportStar(require("./materialized_tenant_delivery_geo_cells"), exports);
|
|
56
|
+
__exportStar(require("./materialized_tenant_delivery_geo_scopes"), exports);
|
|
55
57
|
__exportStar(require("./materialized_tenant_delivery_reports"), exports);
|
|
56
|
-
__exportStar(require("./
|
|
57
|
-
__exportStar(require("./
|
|
58
|
+
__exportStar(require("./materialized_tenant_discount_entries"), exports);
|
|
59
|
+
__exportStar(require("./materialized_tenant_discount_reports"), exports);
|
|
60
|
+
__exportStar(require("./materialized_tenant_discount_sources"), exports);
|
|
61
|
+
__exportStar(require("./materialized_tenant_hourly_comparison_entries"), exports);
|
|
62
|
+
__exportStar(require("./materialized_tenant_hourly_comparison_reports"), exports);
|
|
63
|
+
__exportStar(require("./materialized_tenant_payments_comparison_entries"), exports);
|
|
64
|
+
__exportStar(require("./materialized_tenant_payments_comparison_reports"), exports);
|
|
58
65
|
__exportStar(require("./materialized_tenant_prep_time_entries"), exports);
|
|
59
66
|
__exportStar(require("./materialized_tenant_prep_time_reports"), exports);
|
|
60
67
|
__exportStar(require("./materialized_tenant_reports_iterations"), exports);
|
|
68
|
+
__exportStar(require("./materialized_tenant_sales_comparison_entries"), exports);
|
|
69
|
+
__exportStar(require("./materialized_tenant_sales_comparison_reports"), exports);
|
|
61
70
|
__exportStar(require("./materialized_tenant_sales_overview_reports"), exports);
|
|
62
71
|
__exportStar(require("./menus"), exports);
|
|
63
72
|
__exportStar(require("./messaging_devices"), exports);
|
|
@@ -140,10 +149,3 @@ __exportStar(require("./warehouse_vendors"), exports);
|
|
|
140
149
|
__exportStar(require("./warehouse_void_purchase_order_items"), exports);
|
|
141
150
|
__exportStar(require("./warehouse_void_sale_order_items"), exports);
|
|
142
151
|
__exportStar(require("./warehouses"), exports);
|
|
143
|
-
__exportStar(require("./materialized_tenant_sales_comparison_reports"), exports);
|
|
144
|
-
__exportStar(require("./materialized_tenant_sales_comparison_entries"), exports);
|
|
145
|
-
__exportStar(require("./materialized_tenant_hourly_comparison_reports"), exports);
|
|
146
|
-
__exportStar(require("./materialized_tenant_hourly_comparison_entries"), exports);
|
|
147
|
-
__exportStar(require("./materialized_tenant_payments_comparison_reports"), exports);
|
|
148
|
-
__exportStar(require("./materialized_tenant_payments_comparison_entries"), exports);
|
|
149
|
-
__exportStar(require("./materialized_report_drilldown_rows"), exports);
|
|
@@ -2,7 +2,7 @@ import { DAY_INDEX_ENUM } from '../../constants/ENUMS';
|
|
|
2
2
|
import { DELIVERY_STATUS_ENUM } from '../../constants/enums/delivery';
|
|
3
3
|
import { MATERIALIZED_REPORT_KEY_FILTER_ENUM, MATERIALIZED_REPORT_SCOPE_ENUM } from '../../constants/MATERIALIZED_REPORTS';
|
|
4
4
|
/**
|
|
5
|
-
* Types for `materialized_tenant_delivery_entries` (M4,
|
|
5
|
+
* Types for `materialized_tenant_delivery_entries` (M4, page-partitioned).
|
|
6
6
|
*
|
|
7
7
|
* The statement rows behind the delivery drill-down. The POLYLINE IS NOT STORED: a GPS
|
|
8
8
|
* trace per row would dominate the collection, so a row keeps only its POINT COUNT and a
|
|
@@ -12,6 +12,19 @@ import { MATERIALIZED_REPORT_KEY_FILTER_ENUM, MATERIALIZED_REPORT_SCOPE_ENUM } f
|
|
|
12
12
|
* `order_id` at compile time, so the read needs no second lookup and the drill-down can
|
|
13
13
|
* show what an operator recognises.
|
|
14
14
|
*
|
|
15
|
+
* ## ONE PAGE PER SOURCE DAY
|
|
16
|
+
*
|
|
17
|
+
* A document is bounded by ONE day's rows, never a month's:
|
|
18
|
+
*
|
|
19
|
+
* | scope | page |
|
|
20
|
+
* | --- | --- |
|
|
21
|
+
* | `localDate` | `'all'` |
|
|
22
|
+
* | `localWeek` / `localWeekOfYear` / `localMonth` | `<source localDate>` |
|
|
23
|
+
*
|
|
24
|
+
* There are NO quarter / semester / year entry documents. A broad details selection is
|
|
25
|
+
* served by reading the month pages it touches and filtering rows to the exact selected
|
|
26
|
+
* days.
|
|
27
|
+
*
|
|
15
28
|
* Null means UNMEASURED, never zero: `assigned_at` / `delivered_at` are null on any
|
|
16
29
|
* document written before the metrics capture, and every derived duration is null rather
|
|
17
30
|
* than 0 - reporting 0 would claim the delivery was instantaneous.
|
|
@@ -36,9 +49,18 @@ export interface IMaterializedDeliveryEntry {
|
|
|
36
49
|
/** Trace SIZE only - the polyline itself is deliberately not stored. */
|
|
37
50
|
polyline_point_count: number;
|
|
38
51
|
platform: string;
|
|
52
|
+
/** ORDER_STATUS_ENUM of the joined order (or UNKNOWN). */
|
|
53
|
+
order_status: string;
|
|
39
54
|
city: string | null;
|
|
40
55
|
state: string | null;
|
|
41
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Tenant-local source day of the row: the JOINED ORDER's `localDate`.
|
|
58
|
+
* Falls back to `delivery.localDate` only when the order is missing, and then
|
|
59
|
+
* `source_day_unattributed` is true.
|
|
60
|
+
*/
|
|
61
|
+
source_local_date: string;
|
|
62
|
+
/** True when the order was missing and the source day fell back to the delivery. */
|
|
63
|
+
source_day_unattributed: boolean;
|
|
42
64
|
/** CENTS. */
|
|
43
65
|
net_sale_amount: number;
|
|
44
66
|
collected_amount: number;
|
|
@@ -64,20 +86,30 @@ export interface IMaterializedDeliveryEntry {
|
|
|
64
86
|
created_at: Date;
|
|
65
87
|
/** Time-of-day stamp, mirroring the delivery document field. */
|
|
66
88
|
created_at_mins: number | null;
|
|
67
|
-
/**
|
|
89
|
+
/**
|
|
90
|
+
* Tenant-local stamp of the joined ORDER: `${YYYY-MM-DD} ${HH:MM}` when the
|
|
91
|
+
* order's minute is known, `${YYYY-MM-DD} ${HH}` when only the hour exists
|
|
92
|
+
* (never a synthetic `:00`), null when unresolvable.
|
|
93
|
+
*/
|
|
68
94
|
local_hour: string | null;
|
|
69
95
|
}
|
|
70
96
|
/** Per-key row section of one document. */
|
|
71
97
|
export interface IMaterializedDeliveryKeySection {
|
|
72
98
|
rows: IMaterializedDeliveryEntry[];
|
|
73
99
|
}
|
|
74
|
-
/**
|
|
100
|
+
/**
|
|
101
|
+
* One `materialized_tenant_delivery_entries` PAGE - tenant x scope context x scope
|
|
102
|
+
* value x source day. One page holds one day's rows; a month is covered by its days.
|
|
103
|
+
*/
|
|
75
104
|
export interface IMaterializedTenantDeliveryEntries {
|
|
76
105
|
_id: string;
|
|
77
106
|
tenant_id: string;
|
|
78
107
|
brand_id: string;
|
|
108
|
+
/** One of `MATERIALIZED_DELIVERY_ENTRY_SCOPES` (date / week / ISO week / month). */
|
|
79
109
|
scope_context: MATERIALIZED_REPORT_SCOPE_ENUM;
|
|
80
110
|
scope_field: string;
|
|
111
|
+
/** `'all'` for the day scope; the source `YYYY-MM-DD` for a period scope. */
|
|
112
|
+
page: string;
|
|
81
113
|
/** Denormalized weekday - set ONLY on `LOCAL_DATE` documents. */
|
|
82
114
|
day_index?: DAY_INDEX_ENUM | null;
|
|
83
115
|
sale_type_key_filters: MATERIALIZED_REPORT_KEY_FILTER_ENUM[];
|