@managesome/eposmatic-toolkit 0.4.62 → 0.4.63
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_SCHEMA_VERSIONS.js +17 -0
- package/esm/constants/WORKER_ENDPOINTS.js +2 -2
- package/esm/helpers/materialized-reports/index.js +3 -0
- package/esm/helpers/materialized-reports/materialized-credit-bills-helpers.js +3 -3
- package/esm/helpers/materialized-reports/materialized-delivery-close-day-helpers.js +5 -5
- package/esm/helpers/materialized-reports/materialized-delivery-compile-helpers.js +2 -2
- package/esm/helpers/materialized-reports/materialized-dialer-close-day-helpers.js +5 -5
- package/esm/helpers/materialized-reports/materialized-dialer-compile-helpers.js +2 -2
- package/esm/helpers/materialized-reports/materialized-dinein-close-day-helpers.js +5 -5
- package/esm/helpers/materialized-reports/materialized-dinein-compile-helpers.js +2 -2
- package/esm/helpers/materialized-reports/materialized-discount-compile-helpers.js +3 -3
- package/esm/helpers/materialized-reports/materialized-document-size.js +2 -2
- package/esm/helpers/materialized-reports/materialized-prep-time-close-day-helpers.js +3 -3
- package/esm/helpers/materialized-reports/materialized-prep-time-compile-helpers.js +3 -3
- package/esm/helpers/materialized-reports/report-compile.js +38 -0
- package/esm/helpers/materialized-reports/tenant-sales-overview-bson.js +27 -0
- package/esm/helpers/materialized-reports/tenant-sales-overview-helpers.js +3 -22
- package/esm/schemas/models/materialized_credit_bills.js +2 -1
- package/esm/schemas/models/materialized_tenant_delivery_entries.js +2 -1
- package/esm/schemas/models/materialized_tenant_delivery_reports.js +2 -1
- package/esm/schemas/models/materialized_tenant_dialer_entries.js +2 -1
- package/esm/schemas/models/materialized_tenant_dialer_reports.js +2 -1
- package/esm/schemas/models/materialized_tenant_dinein_entries.js +2 -1
- package/esm/schemas/models/materialized_tenant_dinein_reports.js +2 -1
- package/esm/schemas/models/materialized_tenant_sales_overview_reports.js +2 -1
- package/lib/constants/MATERIALIZED_SCHEMA_VERSIONS.d.ts +17 -0
- package/lib/constants/MATERIALIZED_SCHEMA_VERSIONS.js +20 -0
- package/lib/constants/WORKER_ENDPOINTS.d.ts +0 -2
- package/lib/constants/WORKER_ENDPOINTS.js +2 -2
- package/lib/helpers/materialized-reports/index.d.ts +2 -0
- package/lib/helpers/materialized-reports/index.js +26 -0
- package/lib/helpers/materialized-reports/materialized-credit-bills-helpers.js +4 -4
- package/lib/helpers/materialized-reports/materialized-delivery-close-day-helpers.js +6 -6
- package/lib/helpers/materialized-reports/materialized-delivery-compile-helpers.js +4 -4
- package/lib/helpers/materialized-reports/materialized-dialer-close-day-helpers.js +6 -6
- package/lib/helpers/materialized-reports/materialized-dialer-compile-helpers.js +6 -6
- package/lib/helpers/materialized-reports/materialized-dinein-close-day-helpers.js +6 -6
- package/lib/helpers/materialized-reports/materialized-dinein-compile-helpers.js +6 -6
- package/lib/helpers/materialized-reports/materialized-discount-compile-helpers.js +3 -3
- package/lib/helpers/materialized-reports/materialized-document-size.js +2 -5
- package/lib/helpers/materialized-reports/materialized-prep-time-close-day-helpers.js +3 -3
- package/lib/helpers/materialized-reports/materialized-prep-time-compile-helpers.js +3 -3
- package/lib/helpers/materialized-reports/report-compile.d.ts +38 -0
- package/lib/helpers/materialized-reports/report-compile.js +87 -0
- package/lib/helpers/materialized-reports/tenant-sales-overview-bson.d.ts +12 -0
- package/lib/helpers/materialized-reports/tenant-sales-overview-bson.js +33 -0
- package/lib/helpers/materialized-reports/tenant-sales-overview-helpers.d.ts +1 -12
- package/lib/helpers/materialized-reports/tenant-sales-overview-helpers.js +4 -24
- package/lib/schemas/models/materialized_credit_bills.d.ts +29 -46
- package/lib/schemas/models/materialized_credit_bills.js +3 -2
- package/lib/schemas/models/materialized_tenant_cash_entries.d.ts +9 -9
- package/lib/schemas/models/materialized_tenant_cash_reports.d.ts +9 -9
- package/lib/schemas/models/materialized_tenant_delivery_entries.d.ts +11 -10
- package/lib/schemas/models/materialized_tenant_delivery_entries.js +3 -2
- package/lib/schemas/models/materialized_tenant_delivery_geo_cells.d.ts +9 -9
- package/lib/schemas/models/materialized_tenant_delivery_geo_scopes.d.ts +6 -6
- package/lib/schemas/models/materialized_tenant_delivery_reports.d.ts +11 -10
- package/lib/schemas/models/materialized_tenant_delivery_reports.js +3 -2
- package/lib/schemas/models/materialized_tenant_dialer_entries.d.ts +8 -7
- package/lib/schemas/models/materialized_tenant_dialer_entries.js +3 -2
- package/lib/schemas/models/materialized_tenant_dialer_reports.d.ts +11 -10
- package/lib/schemas/models/materialized_tenant_dialer_reports.js +3 -2
- package/lib/schemas/models/materialized_tenant_dinein_entries.d.ts +8 -7
- package/lib/schemas/models/materialized_tenant_dinein_entries.js +3 -2
- package/lib/schemas/models/materialized_tenant_dinein_reports.d.ts +11 -10
- package/lib/schemas/models/materialized_tenant_dinein_reports.js +3 -2
- package/lib/schemas/models/materialized_tenant_discount_entries.d.ts +9 -9
- package/lib/schemas/models/materialized_tenant_discount_reports.d.ts +9 -9
- package/lib/schemas/models/materialized_tenant_discount_sources.d.ts +9 -9
- package/lib/schemas/models/materialized_tenant_hourly_comparison_entries.d.ts +9 -9
- package/lib/schemas/models/materialized_tenant_hourly_comparison_reports.d.ts +9 -9
- package/lib/schemas/models/materialized_tenant_payments_comparison_entries.d.ts +9 -9
- package/lib/schemas/models/materialized_tenant_payments_comparison_reports.d.ts +9 -9
- package/lib/schemas/models/materialized_tenant_prep_time_entries.d.ts +9 -9
- package/lib/schemas/models/materialized_tenant_prep_time_reports.d.ts +9 -9
- package/lib/schemas/models/materialized_tenant_sales_comparison_entries.d.ts +9 -9
- package/lib/schemas/models/materialized_tenant_sales_comparison_reports.d.ts +9 -9
- package/lib/schemas/models/materialized_tenant_sales_overview_reports.d.ts +11 -35
- package/lib/schemas/models/materialized_tenant_sales_overview_reports.js +3 -2
- package/lib/tests/materialized-reports/tenant-sales-overview-close-day-helpers.test.js +2 -1
- package/lib/tests/materialized-reports/tenant-sales-overview-helpers.test.js +5 -4
- package/lib/tests/reporting-contract/no-live-transport.test.js +106 -0
- package/package.json +2 -1
- package/lib/helpers/order/payment-collection.d.ts +0 -25
- package/lib/helpers/order/payment-collection.js +0 -51
- package/lib/schemas/models/applied_order_discounts.d.ts +0 -80
- package/lib/schemas/models/applied_order_discounts.js +0 -106
- package/lib/schemas/types/applied_order_discounts.d.ts +0 -22
- package/lib/schemas/types/applied_order_discounts.js +0 -2
- package/lib/tests/materialized-reports/analytics-overview-helpers.test.d.ts +0 -1
- package/lib/tests/materialized-reports/analytics-performance-helpers.test.d.ts +0 -1
- package/lib/tests/payment-collection-timestamps.test.d.ts +0 -1
- package/lib/tests/payment-collection-timestamps.test.js +0 -71
- /package/lib/tests/{materialized-reports/analytics-growth-helpers.test.d.ts → reporting-contract/no-live-transport.test.d.ts} +0 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PURE materialized-report schema versions.
|
|
3
|
+
*
|
|
4
|
+
* The close-day plans stamp these versions on the documents they build, so the
|
|
5
|
+
* COMPILE graph must be able to read them without importing a mongoose schema
|
|
6
|
+
* model (the schema files re-export these constants for their existing API).
|
|
7
|
+
*
|
|
8
|
+
* Keep this module dependency-free: it is imported by the worker compile path.
|
|
9
|
+
*/
|
|
10
|
+
export const MATERIALIZED_CREDIT_BILLS_SCHEMA_VERSION = 1;
|
|
11
|
+
export const MATERIALIZED_TENANT_DELIVERY_ENTRIES_SCHEMA_VERSION = 1;
|
|
12
|
+
export const MATERIALIZED_TENANT_DELIVERY_REPORTS_SCHEMA_VERSION = 1;
|
|
13
|
+
export const MATERIALIZED_TENANT_DIALER_ENTRIES_SCHEMA_VERSION = 1;
|
|
14
|
+
export const MATERIALIZED_TENANT_DIALER_REPORTS_SCHEMA_VERSION = 1;
|
|
15
|
+
export const MATERIALIZED_TENANT_DINEIN_ENTRIES_SCHEMA_VERSION = 1;
|
|
16
|
+
export const MATERIALIZED_TENANT_DINEIN_REPORTS_SCHEMA_VERSION = 1;
|
|
17
|
+
export const MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_SCHEMA_VERSION = 1;
|
|
@@ -31,8 +31,8 @@ export const WORKER_ENDPOINTS = {
|
|
|
31
31
|
REMOVE_DINEIN_TABLE: '/remove-dinein-table',
|
|
32
32
|
// ========================>> Modifiers / Catalog <<======================= //
|
|
33
33
|
UPDATE_MODIFIER_NAME_IN_ITEMS: '/update-modifier-name-in-items',
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
// The two catalog reads that used to live here (items-using-modifier and
|
|
35
|
+
// audit-item-modifiers) are OWNED by items-service now and run locally.
|
|
36
36
|
// ========================>> Payment (SwitchPay) <<======================= //
|
|
37
37
|
PROCESS_SWITCHPAY_PAYMENT_FOR_ORDER: '/process-switchpay-payment-for-order',
|
|
38
38
|
COMMIT_SWITCHPAY_PAYMENT_FOR_ORDER: '/commit-switchpay-payment-for-order',
|
|
@@ -69,4 +69,7 @@ export * from './tenant-dinein-formatter';
|
|
|
69
69
|
export * from './tenant-prep-time-formatter';
|
|
70
70
|
export * from './tenant-sales-overview-formatter';
|
|
71
71
|
export * from './tenant-sales-overview-helpers';
|
|
72
|
+
export * from './tenant-sales-overview-bson';
|
|
72
73
|
export * from './report-platform';
|
|
74
|
+
// Worker-only PURE compile surface (also importable via the deep lib path).
|
|
75
|
+
export * as reportCompile from './report-compile';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ObjectID from 'bson-objectid';
|
|
2
2
|
import { PAYMENT_TYPE_ENUM, REPORT_SALE_TYPE_ENUM } from '../../constants';
|
|
3
3
|
import { ALL_MATERIALIZED_REPORT_SCOPES, MATERIALIZED_REPORT_CREDIT_BILL_EVENT_TYPE_ENUM, MATERIALIZED_REPORT_SCOPE_ENUM, SALES_OVERVIEW_KEY_FILTERS, } from '../../constants/MATERIALIZED_REPORTS';
|
|
4
|
-
import { MATERIALIZED_CREDIT_BILLS_SCHEMA_VERSION } from '../../
|
|
4
|
+
import { MATERIALIZED_CREDIT_BILLS_SCHEMA_VERSION } from '../../constants/MATERIALIZED_SCHEMA_VERSIONS';
|
|
5
5
|
import { getLocalDocumentFields, getLocalFieldsFromLocalDate } from '../utils/time-helpers';
|
|
6
6
|
import { buildMaterializedReportKey } from './key-helpers';
|
|
7
7
|
import { materializedDayInputSignatureChanged } from './materialized-day-input-signature';
|
|
@@ -521,7 +521,7 @@ export function buildMaterializedCreditBillDayReports(input) {
|
|
|
521
521
|
return [];
|
|
522
522
|
const sourceWatermark = watermark ?? computedAt;
|
|
523
523
|
const makeDoc = (scopeContext, scopeField, sections) => ({
|
|
524
|
-
_id: new
|
|
524
|
+
_id: new ObjectID().toHexString(),
|
|
525
525
|
tenant_id: tenantId,
|
|
526
526
|
brand_id: brandId,
|
|
527
527
|
scope_context: scopeContext,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ObjectID from 'bson-objectid';
|
|
2
2
|
import { DELIVERY_KEY_FILTERS, MATERIALIZED_DELIVERY_ENTRY_MAX_BSON_BYTES, MATERIALIZED_DELIVERY_REPORT_MAX_BSON_BYTES, MATERIALIZED_DELIVERY_REPORT_SCOPES, MATERIALIZED_REPORT_SCOPE_ENUM, MATERIALIZED_REPORT_TYPE_ENUM, } from '../../constants/MATERIALIZED_REPORTS';
|
|
3
|
-
import { MATERIALIZED_TENANT_DELIVERY_REPORTS_SCHEMA_VERSION } from '../../
|
|
3
|
+
import { MATERIALIZED_TENANT_DELIVERY_REPORTS_SCHEMA_VERSION } from '../../constants/MATERIALIZED_SCHEMA_VERSIONS';
|
|
4
4
|
import { mergeMaterializedDeliveryCounters } from './materialized-delivery-accumulator-helpers';
|
|
5
5
|
import { freshDeliveryCounters } from './materialized-delivery-classification-helpers';
|
|
6
6
|
import { pruneDocumentDeliveryAreas, pruneDocumentDeliveryRiders } from './materialized-delivery-compile-helpers';
|
|
@@ -154,7 +154,7 @@ export function buildTenantDeliveryCloseDayPlan(input) {
|
|
|
154
154
|
const existing = storedReportsByScope.get(deliveryScopeKey(compiledDateDoc));
|
|
155
155
|
const next = {
|
|
156
156
|
...compiledDateDoc,
|
|
157
|
-
_id: existing?._id ?? new
|
|
157
|
+
_id: existing?._id ?? new ObjectID().toHexString(),
|
|
158
158
|
iteration: Number(existing?.iteration ?? 0) + 1,
|
|
159
159
|
};
|
|
160
160
|
if (force || needsMaterializedDeliveryReportWrite(existing, next))
|
|
@@ -236,7 +236,7 @@ export function buildTenantDeliveryCloseDayPlan(input) {
|
|
|
236
236
|
counterRows.push({ key, counters: folded[key] });
|
|
237
237
|
}
|
|
238
238
|
const report = {
|
|
239
|
-
_id: existing?._id ?? new
|
|
239
|
+
_id: existing?._id ?? new ObjectID().toHexString(),
|
|
240
240
|
tenant_id: tenantId,
|
|
241
241
|
brand_id: existing?.brand_id ?? compiledDateDoc?.brand_id ?? '',
|
|
242
242
|
scope_context: scope,
|
|
@@ -275,7 +275,7 @@ export function buildTenantDeliveryCloseDayPlan(input) {
|
|
|
275
275
|
const existing = storedEntriesByPage.get(key) ?? null;
|
|
276
276
|
const next = {
|
|
277
277
|
...compiled,
|
|
278
|
-
_id: existing?._id ?? new
|
|
278
|
+
_id: existing?._id ?? new ObjectID().toHexString(),
|
|
279
279
|
iteration: Number(existing?.iteration ?? 0) + 1,
|
|
280
280
|
};
|
|
281
281
|
if (existing == null || force || needsMaterializedDeliveryEntriesWrite(existing, next)) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ALL_DAY_INDEX } from '../../constants/ENUMS';
|
|
2
2
|
import { DELIVERY_KEY_FILTERS, MATERIALIZED_DELIVERY_AREA_LIMIT, MATERIALIZED_DELIVERY_ENTRY_MAX_BSON_BYTES, MATERIALIZED_DELIVERY_ENTRY_SCOPES, MATERIALIZED_DELIVERY_OTHER_TOKEN, MATERIALIZED_DELIVERY_REPORT_MAX_BSON_BYTES, MATERIALIZED_DELIVERY_RIDER_LIMIT, MATERIALIZED_REPORT_SCOPE_ENUM, } from '../../constants/MATERIALIZED_REPORTS';
|
|
3
3
|
import { DELIVERY_STATUS_ENUM, RIDER_EARNINGS_STATUS_ENUM } from '../../constants/enums/delivery';
|
|
4
|
-
import { MATERIALIZED_TENANT_DELIVERY_ENTRIES_SCHEMA_VERSION } from '../../
|
|
5
|
-
import { MATERIALIZED_TENANT_DELIVERY_REPORTS_SCHEMA_VERSION } from '../../
|
|
4
|
+
import { MATERIALIZED_TENANT_DELIVERY_ENTRIES_SCHEMA_VERSION } from '../../constants/MATERIALIZED_SCHEMA_VERSIONS';
|
|
5
|
+
import { MATERIALIZED_TENANT_DELIVERY_REPORTS_SCHEMA_VERSION } from '../../constants/MATERIALIZED_SCHEMA_VERSIONS';
|
|
6
6
|
import { mergeMaterializedDeliveryCounters } from './materialized-delivery-accumulator-helpers';
|
|
7
7
|
import { addDelivery, addDeliveryOrder, buildMaterializedDeliveryKey, DELIVERY_UNKNOWN_TOKEN, finalizeDeliveryAccumulator, freshDeliveryAccumulator, freshDeliveryCounters, isDeliveryOrder, MATERIALIZED_DELIVERY_KEY_SEPARATOR, parseMaterializedDeliveryKey, } from './materialized-delivery-classification-helpers';
|
|
8
8
|
import { deliveryEntryPageOf, splitMaterializedDeliveryEntryPage } from './materialized-delivery-entry-pages';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ObjectID from 'bson-objectid';
|
|
2
2
|
import { DIALER_KEY_FILTERS, MATERIALIZED_DIALER_ENTRY_MAX_BSON_BYTES, MATERIALIZED_DIALER_REPORT_MAX_BSON_BYTES, MATERIALIZED_DIALER_REPORT_SCOPES, MATERIALIZED_REPORT_SCOPE_ENUM, MATERIALIZED_REPORT_TYPE_ENUM, } from '../../constants/MATERIALIZED_REPORTS';
|
|
3
|
-
import { MATERIALIZED_TENANT_DIALER_REPORTS_SCHEMA_VERSION } from '../../
|
|
3
|
+
import { MATERIALIZED_TENANT_DIALER_REPORTS_SCHEMA_VERSION } from '../../constants/MATERIALIZED_SCHEMA_VERSIONS';
|
|
4
4
|
import { freshDialerCounters, mergeDialerCounters } from './materialized-dialer-accumulator-helpers';
|
|
5
5
|
import { dialerEntryPageOf, materializedDialerEntryPageKey } from './materialized-dialer-entry-pages';
|
|
6
6
|
import { assertMaterializedDocumentSize } from './materialized-document-size';
|
|
@@ -154,7 +154,7 @@ export function buildTenantDialerCloseDayPlan(input) {
|
|
|
154
154
|
const existing = storedReportsByScope.get(dialerScopeKey(compiledDateDoc));
|
|
155
155
|
const next = {
|
|
156
156
|
...compiledDateDoc,
|
|
157
|
-
_id: existing?._id ?? new
|
|
157
|
+
_id: existing?._id ?? new ObjectID().toHexString(),
|
|
158
158
|
iteration: Number(existing?.iteration ?? 0) + 1,
|
|
159
159
|
};
|
|
160
160
|
if (force || needsMaterializedDialerReportWrite(existing, next))
|
|
@@ -227,7 +227,7 @@ export function buildTenantDialerCloseDayPlan(input) {
|
|
|
227
227
|
for (const key of keys)
|
|
228
228
|
counters[key] = folded[key];
|
|
229
229
|
const report = {
|
|
230
|
-
_id: existing?._id ?? new
|
|
230
|
+
_id: existing?._id ?? new ObjectID().toHexString(),
|
|
231
231
|
tenant_id: tenantId,
|
|
232
232
|
brand_id: existing?.brand_id ?? compiledDateDoc?.brand_id ?? '',
|
|
233
233
|
scope_context: scope,
|
|
@@ -259,7 +259,7 @@ export function buildTenantDialerCloseDayPlan(input) {
|
|
|
259
259
|
const existing = storedEntriesByPage.get(key) ?? null;
|
|
260
260
|
const next = {
|
|
261
261
|
...compiled,
|
|
262
|
-
_id: existing?._id ?? new
|
|
262
|
+
_id: existing?._id ?? new ObjectID().toHexString(),
|
|
263
263
|
iteration: Number(existing?.iteration ?? 0) + 1,
|
|
264
264
|
};
|
|
265
265
|
if (existing == null || force || needsMaterializedDialerEntriesWrite(existing, next)) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MATERIALIZED_DIALER_ENTRY_MAX_BSON_BYTES, MATERIALIZED_DIALER_ENTRY_SCOPES, MATERIALIZED_DIALER_REPORT_MAX_BSON_BYTES, MATERIALIZED_REPORT_SCOPE_ENUM, } from '../../constants/MATERIALIZED_REPORTS';
|
|
2
|
-
import { MATERIALIZED_TENANT_DIALER_ENTRIES_SCHEMA_VERSION } from '../../
|
|
3
|
-
import { MATERIALIZED_TENANT_DIALER_REPORTS_SCHEMA_VERSION as REPORT_SCHEMA_VERSION } from '../../
|
|
2
|
+
import { MATERIALIZED_TENANT_DIALER_ENTRIES_SCHEMA_VERSION } from '../../constants/MATERIALIZED_SCHEMA_VERSIONS';
|
|
3
|
+
import { MATERIALIZED_TENANT_DIALER_REPORTS_SCHEMA_VERSION as REPORT_SCHEMA_VERSION } from '../../constants/MATERIALIZED_SCHEMA_VERSIONS';
|
|
4
4
|
import { MATERIALIZED_DIALER_REPORT_KEY_FILTERS, } from '../../schemas/types/materialized_tenant_dialer_reports';
|
|
5
5
|
import { addDialerEvent, dialerHourKey, freshDialerCounters } from './materialized-dialer-accumulator-helpers';
|
|
6
6
|
import { dialerEntryPageOf, splitMaterializedDialerEntryPage } from './materialized-dialer-entry-pages';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ObjectID from 'bson-objectid';
|
|
2
2
|
import { DINEIN_KEY_FILTERS, MATERIALIZED_DINEIN_COURSE_LIMIT, MATERIALIZED_DINEIN_ENTRY_MAX_BSON_BYTES, MATERIALIZED_DINEIN_FLOOR_LIMIT, MATERIALIZED_DINEIN_REPORT_MAX_BSON_BYTES, MATERIALIZED_DINEIN_REPORT_SCOPES, MATERIALIZED_DINEIN_SERVICE_CHARGE_RATE_LIMIT, MATERIALIZED_DINEIN_TABLE_LIMIT, MATERIALIZED_DINEIN_TOP_EDITED_CHECK_LIMIT, MATERIALIZED_DINEIN_UPCOMING_RESERVATION_LIMIT, MATERIALIZED_REPORT_SCOPE_ENUM, MATERIALIZED_REPORT_TYPE_ENUM, } from '../../constants/MATERIALIZED_REPORTS';
|
|
3
|
-
import { MATERIALIZED_TENANT_DINEIN_REPORTS_SCHEMA_VERSION } from '../../
|
|
3
|
+
import { MATERIALIZED_TENANT_DINEIN_REPORTS_SCHEMA_VERSION } from '../../constants/MATERIALIZED_SCHEMA_VERSIONS';
|
|
4
4
|
import { freshMaterializedDineinCounters, freshMaterializedDineinReservationCounters, mergeMaterializedDineinCounters, mergeMaterializedDineinReservationCounters, mergeMaterializedDineinTopEditedChecks, mergeMaterializedDineinUpcomingReservations, pruneDocumentDineinMaps, } from './materialized-dinein-accumulator-helpers';
|
|
5
5
|
import { assertMaterializedDocumentSize } from './materialized-document-size';
|
|
6
6
|
import { dineinEntryPageOf, materializedDineinEntryPageKey } from './materialized-dinein-entry-pages';
|
|
@@ -171,7 +171,7 @@ export function buildTenantDineinCloseDayPlan(input) {
|
|
|
171
171
|
const existing = storedReportsByScope.get(dineinScopeKey(compiledDateDoc));
|
|
172
172
|
const next = {
|
|
173
173
|
...compiledDateDoc,
|
|
174
|
-
_id: existing?._id ?? new
|
|
174
|
+
_id: existing?._id ?? new ObjectID().toHexString(),
|
|
175
175
|
iteration: Number(existing?.iteration ?? 0) + 1,
|
|
176
176
|
};
|
|
177
177
|
if (force || needsMaterializedDineinReportWrite(existing, next))
|
|
@@ -259,7 +259,7 @@ export function buildTenantDineinCloseDayPlan(input) {
|
|
|
259
259
|
for (const key of keys)
|
|
260
260
|
counters[key] = folded.counters[key];
|
|
261
261
|
const report = {
|
|
262
|
-
_id: existing?._id ?? new
|
|
262
|
+
_id: existing?._id ?? new ObjectID().toHexString(),
|
|
263
263
|
tenant_id: tenantId,
|
|
264
264
|
brand_id: existing?.brand_id ?? compiledDateDoc?.brand_id ?? '',
|
|
265
265
|
scope_context: scope,
|
|
@@ -297,7 +297,7 @@ export function buildTenantDineinCloseDayPlan(input) {
|
|
|
297
297
|
const existing = storedEntriesByPage.get(key) ?? null;
|
|
298
298
|
const next = {
|
|
299
299
|
...compiled,
|
|
300
|
-
_id: existing?._id ?? new
|
|
300
|
+
_id: existing?._id ?? new ObjectID().toHexString(),
|
|
301
301
|
iteration: Number(existing?.iteration ?? 0) + 1,
|
|
302
302
|
};
|
|
303
303
|
if (existing == null || force || needsMaterializedDineinEntriesWrite(existing, next)) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MATERIALIZED_DINEIN_ENTRY_SCOPES, MATERIALIZED_DINEIN_ENTRY_MAX_BSON_BYTES, MATERIALIZED_DINEIN_HOUR_KEYS, MATERIALIZED_DINEIN_REPORT_MAX_BSON_BYTES, MATERIALIZED_DINEIN_TOP_EDITED_CHECK_LIMIT, MATERIALIZED_DINEIN_UNKNOWN_TOKEN, MATERIALIZED_DINEIN_UPCOMING_RESERVATION_LIMIT, MATERIALIZED_REPORT_SCOPE_ENUM, } from '../../constants/MATERIALIZED_REPORTS';
|
|
2
|
-
import { MATERIALIZED_TENANT_DINEIN_ENTRIES_SCHEMA_VERSION } from '../../
|
|
3
|
-
import { MATERIALIZED_TENANT_DINEIN_REPORTS_SCHEMA_VERSION } from '../../
|
|
2
|
+
import { MATERIALIZED_TENANT_DINEIN_ENTRIES_SCHEMA_VERSION } from '../../constants/MATERIALIZED_SCHEMA_VERSIONS';
|
|
3
|
+
import { MATERIALIZED_TENANT_DINEIN_REPORTS_SCHEMA_VERSION } from '../../constants/MATERIALIZED_SCHEMA_VERSIONS';
|
|
4
4
|
import { MATERIALIZED_DINEIN_REPORT_KEY_FILTERS, } from '../../schemas/types/materialized_tenant_dinein_reports';
|
|
5
5
|
import { freshMaterializedDineinCounters, freshMaterializedDineinReservationCounters, mergeMaterializedDineinTopEditedChecks, mergeMaterializedDineinUpcomingReservations, pruneDocumentDineinMaps, } from './materialized-dinein-accumulator-helpers';
|
|
6
6
|
import { addDineinOrderToCounters, classifyMaterializedDineinOrigin, freshDineinCoverage, isDeletedSplitParent, isDineinOrder, itemLineDelta, itemQuantityOf, splitRoleOf, toDineinDate as toDate, toDineinInt as num, validRatingOf, } from './materialized-dinein-classification-helpers';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ObjectID from 'bson-objectid';
|
|
2
2
|
import { MATERIALIZED_DISCOUNT_ENTRY_PAGE_ALL, MATERIALIZED_DISCOUNT_REPORT_SCOPES, MATERIALIZED_REPORT_KEY_FILTER_ENUM, MATERIALIZED_REPORT_SCOPE_ENUM, } from '../../constants/MATERIALIZED_REPORTS';
|
|
3
3
|
import { accumulateOrderDiscounts, toDiscountHourLabel, } from './materialized-discount-accumulator-helpers';
|
|
4
4
|
import { createEmptyDiscountOrderCounters } from './materialized-discount-classification-helpers';
|
|
@@ -156,7 +156,7 @@ export function compileTenantDiscountReports(input) {
|
|
|
156
156
|
const docWatermark = watermark ?? sourceWatermark;
|
|
157
157
|
const isDateScoped = scope === MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_DATE || scope === MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_HOUR;
|
|
158
158
|
reports.push({
|
|
159
|
-
_id: new
|
|
159
|
+
_id: new ObjectID().toHexString(),
|
|
160
160
|
tenant_id: tenantId,
|
|
161
161
|
brand_id: brandId,
|
|
162
162
|
scope_context: scope,
|
|
@@ -179,7 +179,7 @@ export function compileTenantDiscountReports(input) {
|
|
|
179
179
|
// Entries documents exist only when there is at least one row.
|
|
180
180
|
if (Object.keys(entrySections).length > 0) {
|
|
181
181
|
entriesDocs.push({
|
|
182
|
-
_id: new
|
|
182
|
+
_id: new ObjectID().toHexString(),
|
|
183
183
|
tenant_id: tenantId,
|
|
184
184
|
brand_id: brandId,
|
|
185
185
|
scope_context: scope,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { calculateObjectSize } from 'bson';
|
|
2
2
|
/**
|
|
3
3
|
* The BSON SIZE BUDGET of a materialized report/entry/geo document.
|
|
4
4
|
*
|
|
@@ -31,7 +31,7 @@ import mongoose from 'mongoose';
|
|
|
31
31
|
export function materializedDocumentBsonBytes(document) {
|
|
32
32
|
if (document == null)
|
|
33
33
|
return 0;
|
|
34
|
-
return
|
|
34
|
+
return calculateObjectSize(document);
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
37
|
* Throws when ONE document exceeds its budget.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ObjectID from 'bson-objectid';
|
|
2
2
|
import { MATERIALIZED_PREP_TIME_ITEM_SCOPES, MATERIALIZED_PREP_TIME_REPORT_SCOPES, MATERIALIZED_REPORT_SCOPE_ENUM, MATERIALIZED_REPORT_TYPE_ENUM, } from '../../constants/MATERIALIZED_REPORTS';
|
|
3
3
|
import { freshMaterializedPrepTimeCounters } from './materialized-prep-time-classification-helpers';
|
|
4
4
|
import { mergeMaterializedPrepTimeCounters } from './materialized-prep-time-compile-helpers';
|
|
@@ -359,7 +359,7 @@ export function buildTenantPrepTimeCloseDayPlan(input) {
|
|
|
359
359
|
const report = {
|
|
360
360
|
// A period document created by the fold gets a fresh id; an existing one keeps
|
|
361
361
|
// its identity so the upsert targets the same row.
|
|
362
|
-
_id: existingDoc?._id ?? new
|
|
362
|
+
_id: existingDoc?._id ?? new ObjectID().toHexString(),
|
|
363
363
|
tenant_id: tenantId,
|
|
364
364
|
brand_id: existingDoc?.brand_id ?? reports[0]?.brand_id ?? '',
|
|
365
365
|
scope_context: scope,
|
|
@@ -470,7 +470,7 @@ export function buildTenantPrepTimeCloseDayPlan(input) {
|
|
|
470
470
|
}
|
|
471
471
|
}
|
|
472
472
|
const report = {
|
|
473
|
-
_id: existingDoc?._id ?? new
|
|
473
|
+
_id: existingDoc?._id ?? new ObjectID().toHexString(),
|
|
474
474
|
tenant_id: tenantId,
|
|
475
475
|
brand_id: existingDoc?.brand_id ?? entries[0]?.brand_id ?? '',
|
|
476
476
|
scope_context: scope,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ObjectID from 'bson-objectid';
|
|
2
2
|
import { MATERIALIZED_PREP_TIME_ITEM_SCOPES, MATERIALIZED_PREP_TIME_REPORT_SCOPES, MATERIALIZED_REPORT_SCOPE_ENUM, PREP_TIME_KEY_FILTERS, } from '../../constants/MATERIALIZED_REPORTS';
|
|
3
3
|
import { accumulateOrderPrepTime, freshMaterializedPrepTimeCounters, } from './materialized-prep-time-classification-helpers';
|
|
4
4
|
import { getDayIndexFromLocalDate, getMaterializedPeriodScopeFields } from './scope-helpers';
|
|
@@ -169,7 +169,7 @@ export function compileTenantPrepTimeReports(input) {
|
|
|
169
169
|
const docWatermark = watermark ?? sourceWatermark;
|
|
170
170
|
const isDateScoped = scopeContext === MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_DATE;
|
|
171
171
|
reports.push({
|
|
172
|
-
_id: new
|
|
172
|
+
_id: new ObjectID().toHexString(),
|
|
173
173
|
tenant_id: tenantId,
|
|
174
174
|
brand_id: brandId,
|
|
175
175
|
scope_context: scopeContext,
|
|
@@ -187,7 +187,7 @@ export function compileTenantPrepTimeReports(input) {
|
|
|
187
187
|
});
|
|
188
188
|
if (itemScopes.has(scopeContext) && Object.keys(entrySections).length > 0) {
|
|
189
189
|
entries.push({
|
|
190
|
-
_id: new
|
|
190
|
+
_id: new ObjectID().toHexString(),
|
|
191
191
|
tenant_id: tenantId,
|
|
192
192
|
brand_id: brandId,
|
|
193
193
|
scope_context: scopeContext,
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PURE materialized-report COMPILE entrypoint.
|
|
3
|
+
*
|
|
4
|
+
* This module is the workers-service Piscina worker's toolkit surface. Its
|
|
5
|
+
* transitive import graph contains NO mongoose, NO schema model, NO DB
|
|
6
|
+
* initializer and NO model registration: every close-day plan/compile helper
|
|
7
|
+
* was moved to pure modules (schema-version constants live in
|
|
8
|
+
* `constants/MATERIALIZED_SCHEMA_VERSIONS`, ObjectIds are generated with
|
|
9
|
+
* `bson-objectid`, document size uses the `bson` calculator).
|
|
10
|
+
*
|
|
11
|
+
* Import the ROOT toolkit barrel for the service-facing API; import THIS module
|
|
12
|
+
* (or its built `lib/helpers/materialized-reports/report-compile.js` path) from
|
|
13
|
+
* a worker.
|
|
14
|
+
*/
|
|
15
|
+
export { MATERIALIZED_DINEIN_ORIGIN_ENUM, MATERIALIZED_DINEIN_REPORT_SCOPES, MATERIALIZED_DINEIN_SPLIT_PARENT_DELETE_REASON, MATERIALIZED_DINEIN_UNKNOWN_TOKEN, MATERIALIZED_PREP_TIME_ITEM_SCOPES, MATERIALIZED_PREP_TIME_REPORT_SCOPES, MATERIALIZED_REPORT_SCOPE_ENUM, } from '../../constants/MATERIALIZED_REPORTS';
|
|
16
|
+
export { MATERIALIZED_CREDIT_BILLS_SCHEMA_VERSION, MATERIALIZED_TENANT_DINEIN_ENTRIES_SCHEMA_VERSION, MATERIALIZED_TENANT_DINEIN_REPORTS_SCHEMA_VERSION, } from '../../constants/MATERIALIZED_SCHEMA_VERSIONS';
|
|
17
|
+
export { SALES_OVERVIEW_KEY_FILTERS } from '../../constants/MATERIALIZED_REPORTS';
|
|
18
|
+
export { REPORT_SALE_TYPE_ENUM } from '../../constants/ANALYTICS';
|
|
19
|
+
export { compileTenantPrepTimeReports } from './materialized-prep-time-compile-helpers';
|
|
20
|
+
export { buildTenantPrepTimeCloseDayPlan, getMaterializedPrepTimePeriodDayScopeFields, getMaterializedPrepTimeReportPeriodDayScopeFields, } from './materialized-prep-time-close-day-helpers';
|
|
21
|
+
export { compileTenantDiscountReports } from './materialized-discount-compile-helpers';
|
|
22
|
+
export { buildTenantDiscountCloseDayPlan } from './materialized-discount-close-day-helpers';
|
|
23
|
+
export { compileTenantDeliveryReports } from './materialized-delivery-compile-helpers';
|
|
24
|
+
export { buildTenantDeliveryCloseDayPlan } from './materialized-delivery-close-day-helpers';
|
|
25
|
+
export { compileTenantDeliveryGeoCellsWithStats } from './materialized-tenant-delivery-geo-helpers';
|
|
26
|
+
export { compileTenantDialerReports } from './materialized-dialer-compile-helpers';
|
|
27
|
+
export { buildTenantDialerCloseDayPlan } from './materialized-dialer-close-day-helpers';
|
|
28
|
+
export { compileTenantDineinReports } from './materialized-dinein-compile-helpers';
|
|
29
|
+
export { buildTenantDineinCloseDayPlan, foldMaterializedDineinPeriodCounters, } from './materialized-dinein-close-day-helpers';
|
|
30
|
+
export { pruneDocumentDineinMaps } from './materialized-dinein-accumulator-helpers';
|
|
31
|
+
export { dineinKeyPassesFilters } from './materialized-dinein-key-helpers';
|
|
32
|
+
export { mergeMaterializedDineinEntryPages } from './materialized-dinein-entry-pages';
|
|
33
|
+
export { getMaterializedPeriodScopeFields, parseMaterializedLocalDate } from './scope-helpers';
|
|
34
|
+
export { REPORT_KEY_ENUM, REPORT_MODE_ENUM, buildReportDetailsResponse, buildReportMeta, buildReportResponse, } from '../reporting-contract/report-contract';
|
|
35
|
+
export { convertOrdersToMaterializedTenantSalesOverviewReports, sumMaterializedTenantSalesOverviewReports, } from './tenant-sales-overview-helpers';
|
|
36
|
+
export { buildTenantSalesOverviewCloseDayPlan } from './tenant-sales-overview-close-day-helpers';
|
|
37
|
+
export { applyCreditResolutionToReportDocuments, buildMaterializedCreditBillSelectionFromScopeGroups, computeMaterializedCreditBillTotalsFromReportsByKey, getMaterializedCreditBillScopeRefsForDay, getMaterializedCreditBillScopeRefsForIssue, resolveCreditBillDay, } from './materialized-credit-bills-helpers';
|
|
38
|
+
export { normalizeOverviewAggregatedShape } from '../reporting-contract/overview-contract';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import mongoose from 'mongoose';
|
|
2
|
+
import { MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_COLLECTION_NAME, MaterializedTenantSalesOverviewReportSchema, } from '../../schemas/models/materialized_tenant_sales_overview_reports';
|
|
3
|
+
/**
|
|
4
|
+
* MAIN-THREAD-ONLY Overview persistence adapter.
|
|
5
|
+
*
|
|
6
|
+
* Deliberately SPLIT from `tenant-sales-overview-helpers.ts`: the compile
|
|
7
|
+
* helpers must stay mongoose-free for the workers-service Piscina compile
|
|
8
|
+
* graph, while the BSON casting step needs the mongoose schema. Importing this
|
|
9
|
+
* file is the ONLY way to pull mongoose into the Overview compile path — and
|
|
10
|
+
* the worker never imports it.
|
|
11
|
+
*/
|
|
12
|
+
function getMaterializedTenantSalesOverviewReportModel() {
|
|
13
|
+
return (mongoose.models[MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_COLLECTION_NAME] ??
|
|
14
|
+
mongoose.model(MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_COLLECTION_NAME, MaterializedTenantSalesOverviewReportSchema, MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_COLLECTION_NAME));
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Casts a JSON materialized report through the collection's mongoose schema,
|
|
18
|
+
* returning a hydrated document ready to be saved / bulk-written (the
|
|
19
|
+
* `sale_type_metrics` plain object becomes a `Map`, date strings become
|
|
20
|
+
* `Date` instances, etc.).
|
|
21
|
+
*
|
|
22
|
+
* The document is NOT validated here — `save()` / `Model.validate()` still
|
|
23
|
+
* runs the schema validators.
|
|
24
|
+
*/
|
|
25
|
+
export function convertMaterializedTenantSalesOverviewReportJsonToBson(report) {
|
|
26
|
+
return new (getMaterializedTenantSalesOverviewReportModel())(report);
|
|
27
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ObjectID from 'bson-objectid';
|
|
2
|
+
import { MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_SCHEMA_VERSION } from '../../constants/MATERIALIZED_SCHEMA_VERSIONS';
|
|
2
3
|
import { PAYMENT_STATUS_ENUM, PAYMENT_TYPE_ENUM, REPORT_SALE_TYPE_ENUM } from '../../constants';
|
|
3
4
|
import { MATERIALIZED_REPORT_SCOPE_ENUM, MATERIALIZED_REPORT_SCOPES_WITH_DAY_INDEX, SALES_OVERVIEW_KEY_FILTERS, } from '../../constants/MATERIALIZED_REPORTS';
|
|
4
|
-
import { MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_COLLECTION_NAME, MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_SCHEMA_VERSION, MaterializedTenantSalesOverviewReportSchema, } from '../../schemas/models/materialized_tenant_sales_overview_reports';
|
|
5
5
|
import { buildMaterializedReportKey } from './key-helpers';
|
|
6
6
|
import { buildMaterializedDayInputSignature, } from './materialized-day-input-signature';
|
|
7
7
|
import { buildCreditBillEventCandidatesFromOrder, buildCreditBillIssuedCandidatesFromOrder, isMaterializedCreditBillPayment, resolveOrderLocalHour, resolveReceivedLocalHour, } from './materialized-credit-bills-helpers';
|
|
@@ -328,7 +328,7 @@ const createEmptyReportDocument = (args) => {
|
|
|
328
328
|
? getDayIndexFromLocalDate(scopeField.split(' ')[0])
|
|
329
329
|
: null;
|
|
330
330
|
return {
|
|
331
|
-
_id: new
|
|
331
|
+
_id: new ObjectID().toHexString(),
|
|
332
332
|
tenant_id: tenantId,
|
|
333
333
|
brand_id: brandId,
|
|
334
334
|
scope_context: scopeContext,
|
|
@@ -533,25 +533,6 @@ export function convertOrdersToMaterializedTenantSalesOverviewReports(localDate,
|
|
|
533
533
|
return { materializedReports, credit_bill_issues: creditBillIssues, credit_bill_events: creditEventCandidates };
|
|
534
534
|
}
|
|
535
535
|
/* ------------------------------------------------------------------------ */
|
|
536
|
-
/* 2. JSON → BSON (mongoose document) */
|
|
537
|
-
/* ------------------------------------------------------------------------ */
|
|
538
|
-
function getMaterializedTenantSalesOverviewReportModel() {
|
|
539
|
-
return (mongoose.models[MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_COLLECTION_NAME] ??
|
|
540
|
-
mongoose.model(MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_COLLECTION_NAME, MaterializedTenantSalesOverviewReportSchema, MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_COLLECTION_NAME));
|
|
541
|
-
}
|
|
542
|
-
/**
|
|
543
|
-
* Casts a JSON materialized report through the collection's mongoose schema,
|
|
544
|
-
* returning a hydrated document ready to be saved / bulk-written (the
|
|
545
|
-
* `sale_type_metrics` plain object becomes a `Map`, date strings become
|
|
546
|
-
* `Date` instances, etc.).
|
|
547
|
-
*
|
|
548
|
-
* The document is NOT validated here — `save()` / `Model.validate()` still
|
|
549
|
-
* runs the schema validators.
|
|
550
|
-
*/
|
|
551
|
-
export function convertMaterializedTenantSalesOverviewReportJsonToBson(report) {
|
|
552
|
-
return new (getMaterializedTenantSalesOverviewReportModel())(report);
|
|
553
|
-
}
|
|
554
|
-
/* ------------------------------------------------------------------------ */
|
|
555
536
|
/* 3. Summing documents (period accumulation) */
|
|
556
537
|
/* ------------------------------------------------------------------------ */
|
|
557
538
|
const sumOrderMetrics = (target, source) => {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { MATERIALIZED_CREDIT_BILLS_SCHEMA_VERSION } from '../../constants/MATERIALIZED_SCHEMA_VERSIONS';
|
|
2
|
+
export { MATERIALIZED_CREDIT_BILLS_SCHEMA_VERSION };
|
|
1
3
|
import { Schema } from 'mongoose';
|
|
2
4
|
import { ALL_DAY_INDEX } from '../../constants/ENUMS';
|
|
3
5
|
import { ALL_MATERIALIZED_REPORT_KEY_FILTERS, MATERIALIZED_CREDIT_BILLS_SCOPES, SALES_OVERVIEW_KEY_FILTERS, } from '../../constants/MATERIALIZED_REPORTS';
|
|
@@ -19,7 +21,6 @@ import { ALL_MATERIALIZED_REPORT_KEY_FILTERS, MATERIALIZED_CREDIT_BILLS_SCOPES,
|
|
|
19
21
|
* documents must then be re-materialized. PRE-RELEASE: the collection has no
|
|
20
22
|
* live tenants/consumers yet, so every change so far folds into version `1`.
|
|
21
23
|
*/
|
|
22
|
-
export const MATERIALIZED_CREDIT_BILLS_SCHEMA_VERSION = 1;
|
|
23
24
|
const CreditBillIssuedEntrySchema = new Schema({
|
|
24
25
|
order_id: {
|
|
25
26
|
type: String,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { MATERIALIZED_TENANT_DELIVERY_ENTRIES_SCHEMA_VERSION } from '../../constants/MATERIALIZED_SCHEMA_VERSIONS';
|
|
2
|
+
export { MATERIALIZED_TENANT_DELIVERY_ENTRIES_SCHEMA_VERSION };
|
|
1
3
|
import { Schema } from 'mongoose';
|
|
2
4
|
import { ALL_DAY_INDEX } from '../../constants/ENUMS';
|
|
3
5
|
import { ALL_MATERIALIZED_REPORT_KEY_FILTERS, DELIVERY_KEY_FILTERS, MATERIALIZED_DELIVERY_ENTRY_SCOPES, } from '../../constants/MATERIALIZED_REPORTS';
|
|
@@ -19,7 +21,6 @@ import { ALL_MATERIALIZED_REPORT_KEY_FILTERS, DELIVERY_KEY_FILTERS, MATERIALIZED
|
|
|
19
21
|
* pre-launch contract. Schema versioning will be reintroduced only when a
|
|
20
22
|
* future stored-shape change requires an explicit migration.
|
|
21
23
|
*/
|
|
22
|
-
export const MATERIALIZED_TENANT_DELIVERY_ENTRIES_SCHEMA_VERSION = 1;
|
|
23
24
|
export const MaterializedTenantDeliveryEntriesSchema = new Schema({
|
|
24
25
|
tenant_id: { type: String, required: true },
|
|
25
26
|
brand_id: { type: String, required: true },
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { MATERIALIZED_TENANT_DELIVERY_REPORTS_SCHEMA_VERSION } from '../../constants/MATERIALIZED_SCHEMA_VERSIONS';
|
|
2
|
+
export { MATERIALIZED_TENANT_DELIVERY_REPORTS_SCHEMA_VERSION };
|
|
1
3
|
import { Schema } from 'mongoose';
|
|
2
4
|
import { ALL_DAY_INDEX } from '../../constants/ENUMS';
|
|
3
5
|
import { ALL_MATERIALIZED_REPORT_KEY_FILTERS, DELIVERY_KEY_FILTERS, MATERIALIZED_DELIVERY_REPORT_SCOPES, } from '../../constants/MATERIALIZED_REPORTS';
|
|
@@ -17,7 +19,6 @@ import { ALL_MATERIALIZED_REPORT_KEY_FILTERS, DELIVERY_KEY_FILTERS, MATERIALIZED
|
|
|
17
19
|
* rows as the refund source. Schema versioning is reset to 1 across all
|
|
18
20
|
* materialized collections for this pre-launch contract.
|
|
19
21
|
*/
|
|
20
|
-
export const MATERIALIZED_TENANT_DELIVERY_REPORTS_SCHEMA_VERSION = 1;
|
|
21
22
|
export const MaterializedTenantDeliveryReportSchema = new Schema({
|
|
22
23
|
tenant_id: { type: String, required: true },
|
|
23
24
|
brand_id: { type: String, required: true },
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { MATERIALIZED_TENANT_DIALER_ENTRIES_SCHEMA_VERSION } from '../../constants/MATERIALIZED_SCHEMA_VERSIONS';
|
|
2
|
+
export { MATERIALIZED_TENANT_DIALER_ENTRIES_SCHEMA_VERSION };
|
|
1
3
|
import { Schema } from 'mongoose';
|
|
2
4
|
import { ALL_DAY_INDEX } from '../../constants/ENUMS';
|
|
3
5
|
import { MATERIALIZED_DIALER_ENTRY_SCOPES } from '../../constants/MATERIALIZED_REPORTS';
|
|
@@ -13,7 +15,6 @@ import { MATERIALIZED_DIALER_ENTRY_SCOPES } from '../../constants/MATERIALIZED_R
|
|
|
13
15
|
* sections whose keys are the report's `<ACTION>:<POS_ID>:<STAFF_ID>` grammar.
|
|
14
16
|
*/
|
|
15
17
|
/** Document shape version. Bump with a migration for already-stored pages. */
|
|
16
|
-
export const MATERIALIZED_TENANT_DIALER_ENTRIES_SCHEMA_VERSION = 1;
|
|
17
18
|
export const MaterializedTenantDialerEntriesSchema = new Schema({
|
|
18
19
|
tenant_id: { type: String, required: true },
|
|
19
20
|
brand_id: { type: String, required: true },
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { MATERIALIZED_TENANT_DIALER_REPORTS_SCHEMA_VERSION } from '../../constants/MATERIALIZED_SCHEMA_VERSIONS';
|
|
2
|
+
export { MATERIALIZED_TENANT_DIALER_REPORTS_SCHEMA_VERSION };
|
|
1
3
|
import { Schema } from 'mongoose';
|
|
2
4
|
import { ALL_DAY_INDEX } from '../../constants/ENUMS';
|
|
3
5
|
import { ALL_MATERIALIZED_REPORT_KEY_FILTERS, DIALER_KEY_FILTERS, MATERIALIZED_DIALER_REPORT_SCOPES, } from '../../constants/MATERIALIZED_REPORTS';
|
|
@@ -12,7 +14,6 @@ import { ALL_MATERIALIZED_REPORT_KEY_FILTERS, DIALER_KEY_FILTERS, MATERIALIZED_D
|
|
|
12
14
|
* `materialized_tenant_dialer_entries` collection (one page per source day).
|
|
13
15
|
*/
|
|
14
16
|
/** Document shape version. Bump on a key-grammar/metric change + backfill. */
|
|
15
|
-
export const MATERIALIZED_TENANT_DIALER_REPORTS_SCHEMA_VERSION = 1;
|
|
16
17
|
export const MaterializedTenantDialerReportSchema = new Schema({
|
|
17
18
|
tenant_id: { type: String, required: true },
|
|
18
19
|
brand_id: { type: String, required: true },
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { MATERIALIZED_TENANT_DINEIN_ENTRIES_SCHEMA_VERSION } from '../../constants/MATERIALIZED_SCHEMA_VERSIONS';
|
|
2
|
+
export { MATERIALIZED_TENANT_DINEIN_ENTRIES_SCHEMA_VERSION };
|
|
1
3
|
import { Schema } from 'mongoose';
|
|
2
4
|
import { ALL_DAY_INDEX } from '../../constants/ENUMS';
|
|
3
5
|
import { MATERIALIZED_DINEIN_ENTRY_SCOPES } from '../../constants/MATERIALIZED_REPORTS';
|
|
@@ -13,7 +15,6 @@ import { MATERIALIZED_DINEIN_ENTRY_SCOPES } from '../../constants/MATERIALIZED_R
|
|
|
13
15
|
* `day_index: null`.
|
|
14
16
|
*/
|
|
15
17
|
/** Document shape version. Bump on a row-shape change + backfill. */
|
|
16
|
-
export const MATERIALIZED_TENANT_DINEIN_ENTRIES_SCHEMA_VERSION = 1;
|
|
17
18
|
export const MaterializedTenantDineinEntriesSchema = new Schema({
|
|
18
19
|
tenant_id: { type: String, required: true },
|
|
19
20
|
brand_id: { type: String, required: true },
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { MATERIALIZED_TENANT_DINEIN_REPORTS_SCHEMA_VERSION } from '../../constants/MATERIALIZED_SCHEMA_VERSIONS';
|
|
2
|
+
export { MATERIALIZED_TENANT_DINEIN_REPORTS_SCHEMA_VERSION };
|
|
1
3
|
import { Schema } from 'mongoose';
|
|
2
4
|
import { ALL_DAY_INDEX } from '../../constants/ENUMS';
|
|
3
5
|
import { ALL_MATERIALIZED_REPORT_KEY_FILTERS, DINEIN_KEY_FILTERS, MATERIALIZED_DINEIN_REPORT_SCOPES, } from '../../constants/MATERIALIZED_REPORTS';
|
|
@@ -14,7 +16,6 @@ import { ALL_MATERIALIZED_REPORT_KEY_FILTERS, DINEIN_KEY_FILTERS, MATERIALIZED_D
|
|
|
14
16
|
* `materialized_tenant_dinein_entries` collection (one page per source day).
|
|
15
17
|
*/
|
|
16
18
|
/** Document shape version. Bump on a key-grammar/metric change + backfill. */
|
|
17
|
-
export const MATERIALIZED_TENANT_DINEIN_REPORTS_SCHEMA_VERSION = 1;
|
|
18
19
|
export const MaterializedTenantDineinReportSchema = new Schema({
|
|
19
20
|
tenant_id: { type: String, required: true },
|
|
20
21
|
brand_id: { type: String, required: true },
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_SCHEMA_VERSION } from '../../constants/MATERIALIZED_SCHEMA_VERSIONS';
|
|
2
|
+
export { MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_SCHEMA_VERSION };
|
|
1
3
|
import { Schema } from 'mongoose';
|
|
2
4
|
import { REPORT_SALE_TYPE_ENUM } from '../../constants';
|
|
3
5
|
import { ALL_DAY_INDEX } from '../../constants/ENUMS';
|
|
@@ -27,7 +29,6 @@ import { ALL_MATERIALIZED_REPORT_KEY_FILTERS, ALL_MATERIALIZED_REPORT_SCOPES, SA
|
|
|
27
29
|
* this value during a rollout). PRE-RELEASE: the collection has no live
|
|
28
30
|
* tenants/consumers yet, so every change so far folds into version `1`.
|
|
29
31
|
*/
|
|
30
|
-
export const MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_SCHEMA_VERSION = 1;
|
|
31
32
|
const ReportDiscountByTypeSchema = new Schema({
|
|
32
33
|
special_discount: {
|
|
33
34
|
type: Number, // cents — Σ order_discount_details.special_discount
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PURE materialized-report schema versions.
|
|
3
|
+
*
|
|
4
|
+
* The close-day plans stamp these versions on the documents they build, so the
|
|
5
|
+
* COMPILE graph must be able to read them without importing a mongoose schema
|
|
6
|
+
* model (the schema files re-export these constants for their existing API).
|
|
7
|
+
*
|
|
8
|
+
* Keep this module dependency-free: it is imported by the worker compile path.
|
|
9
|
+
*/
|
|
10
|
+
export declare const MATERIALIZED_CREDIT_BILLS_SCHEMA_VERSION = 1;
|
|
11
|
+
export declare const MATERIALIZED_TENANT_DELIVERY_ENTRIES_SCHEMA_VERSION = 1;
|
|
12
|
+
export declare const MATERIALIZED_TENANT_DELIVERY_REPORTS_SCHEMA_VERSION = 1;
|
|
13
|
+
export declare const MATERIALIZED_TENANT_DIALER_ENTRIES_SCHEMA_VERSION = 1;
|
|
14
|
+
export declare const MATERIALIZED_TENANT_DIALER_REPORTS_SCHEMA_VERSION = 1;
|
|
15
|
+
export declare const MATERIALIZED_TENANT_DINEIN_ENTRIES_SCHEMA_VERSION = 1;
|
|
16
|
+
export declare const MATERIALIZED_TENANT_DINEIN_REPORTS_SCHEMA_VERSION = 1;
|
|
17
|
+
export declare const MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_SCHEMA_VERSION = 1;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_SCHEMA_VERSION = exports.MATERIALIZED_TENANT_DINEIN_REPORTS_SCHEMA_VERSION = exports.MATERIALIZED_TENANT_DINEIN_ENTRIES_SCHEMA_VERSION = exports.MATERIALIZED_TENANT_DIALER_REPORTS_SCHEMA_VERSION = exports.MATERIALIZED_TENANT_DIALER_ENTRIES_SCHEMA_VERSION = exports.MATERIALIZED_TENANT_DELIVERY_REPORTS_SCHEMA_VERSION = exports.MATERIALIZED_TENANT_DELIVERY_ENTRIES_SCHEMA_VERSION = exports.MATERIALIZED_CREDIT_BILLS_SCHEMA_VERSION = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* PURE materialized-report schema versions.
|
|
6
|
+
*
|
|
7
|
+
* The close-day plans stamp these versions on the documents they build, so the
|
|
8
|
+
* COMPILE graph must be able to read them without importing a mongoose schema
|
|
9
|
+
* model (the schema files re-export these constants for their existing API).
|
|
10
|
+
*
|
|
11
|
+
* Keep this module dependency-free: it is imported by the worker compile path.
|
|
12
|
+
*/
|
|
13
|
+
exports.MATERIALIZED_CREDIT_BILLS_SCHEMA_VERSION = 1;
|
|
14
|
+
exports.MATERIALIZED_TENANT_DELIVERY_ENTRIES_SCHEMA_VERSION = 1;
|
|
15
|
+
exports.MATERIALIZED_TENANT_DELIVERY_REPORTS_SCHEMA_VERSION = 1;
|
|
16
|
+
exports.MATERIALIZED_TENANT_DIALER_ENTRIES_SCHEMA_VERSION = 1;
|
|
17
|
+
exports.MATERIALIZED_TENANT_DIALER_REPORTS_SCHEMA_VERSION = 1;
|
|
18
|
+
exports.MATERIALIZED_TENANT_DINEIN_ENTRIES_SCHEMA_VERSION = 1;
|
|
19
|
+
exports.MATERIALIZED_TENANT_DINEIN_REPORTS_SCHEMA_VERSION = 1;
|
|
20
|
+
exports.MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_SCHEMA_VERSION = 1;
|
|
@@ -28,8 +28,6 @@ export declare const WORKER_ENDPOINTS: {
|
|
|
28
28
|
readonly INCREMENT_CASH_IN_HAND: "/increment-cash-in-hand";
|
|
29
29
|
readonly REMOVE_DINEIN_TABLE: "/remove-dinein-table";
|
|
30
30
|
readonly UPDATE_MODIFIER_NAME_IN_ITEMS: "/update-modifier-name-in-items";
|
|
31
|
-
readonly ITEMS_USING_MODIFIER: "/items-using-modifier";
|
|
32
|
-
readonly AUDIT_ITEM_MODIFIERS: "/audit-item-modifiers";
|
|
33
31
|
readonly PROCESS_SWITCHPAY_PAYMENT_FOR_ORDER: "/process-switchpay-payment-for-order";
|
|
34
32
|
readonly COMMIT_SWITCHPAY_PAYMENT_FOR_ORDER: "/commit-switchpay-payment-for-order";
|
|
35
33
|
readonly SYNC_SWITCHPAY_PAYMENT_SUCCESS: "/sync-switchpay-payment-success";
|
|
@@ -34,8 +34,8 @@ exports.WORKER_ENDPOINTS = {
|
|
|
34
34
|
REMOVE_DINEIN_TABLE: '/remove-dinein-table',
|
|
35
35
|
// ========================>> Modifiers / Catalog <<======================= //
|
|
36
36
|
UPDATE_MODIFIER_NAME_IN_ITEMS: '/update-modifier-name-in-items',
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
// The two catalog reads that used to live here (items-using-modifier and
|
|
38
|
+
// audit-item-modifiers) are OWNED by items-service now and run locally.
|
|
39
39
|
// ========================>> Payment (SwitchPay) <<======================= //
|
|
40
40
|
PROCESS_SWITCHPAY_PAYMENT_FOR_ORDER: '/process-switchpay-payment-for-order',
|
|
41
41
|
COMMIT_SWITCHPAY_PAYMENT_FOR_ORDER: '/commit-switchpay-payment-for-order',
|
|
@@ -69,4 +69,6 @@ export * from './tenant-dinein-formatter';
|
|
|
69
69
|
export * from './tenant-prep-time-formatter';
|
|
70
70
|
export * from './tenant-sales-overview-formatter';
|
|
71
71
|
export * from './tenant-sales-overview-helpers';
|
|
72
|
+
export * from './tenant-sales-overview-bson';
|
|
72
73
|
export * from './report-platform';
|
|
74
|
+
export * as reportCompile from './report-compile';
|