@managesome/eposmatic-toolkit 0.4.62 → 0.4.64
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/helpers/store/common-tenant-purchase-order-actions.js +12 -0
- package/esm/helpers/store/common-warehouse-purchase-order-actions.js +20 -0
- package/esm/helpers/store/tenant-purchase-orders-cart-actions.js +24 -7
- package/esm/helpers/store/warehouse-purchase-orders-cart-actions.js +23 -10
- package/esm/helpers/utils/index.js +1 -0
- package/esm/helpers/utils/tenant-purchase-order-engine.js +47 -0
- package/esm/helpers/utils/warehouse-purchase-order-engine.js +63 -4
- 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/esm/schemas/models/tenant_purchase_orders.js +4 -0
- package/esm/schemas/models/warehouse_purchase_orders.js +4 -0
- 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/helpers/store/common-tenant-purchase-order-actions.d.ts +6 -1
- package/lib/helpers/store/common-tenant-purchase-order-actions.js +13 -0
- package/lib/helpers/store/common-warehouse-purchase-order-actions.js +20 -0
- package/lib/helpers/store/tenant-purchase-orders-cart-actions.js +23 -6
- package/lib/helpers/store/warehouse-purchase-orders-cart-actions.js +23 -10
- package/lib/helpers/utils/index.d.ts +1 -0
- package/lib/helpers/utils/index.js +1 -0
- package/lib/helpers/utils/tenant-purchase-order-engine.d.ts +24 -0
- package/lib/helpers/utils/tenant-purchase-order-engine.js +51 -0
- package/lib/helpers/utils/warehouse-purchase-order-engine.d.ts +23 -1
- package/lib/helpers/utils/warehouse-purchase-order-engine.js +65 -4
- 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/schemas/models/tenant_purchase_orders.d.ts +972 -0
- package/lib/schemas/models/tenant_purchase_orders.js +4 -0
- package/lib/schemas/models/warehouse_purchase_orders.d.ts +972 -0
- package/lib/schemas/models/warehouse_purchase_orders.js +4 -0
- package/lib/schemas/types/tenant_purchase_orders.d.ts +2 -1
- package/lib/schemas/types/warehouse_purchase_orders.d.ts +2 -1
- 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
|
@@ -9,9 +9,9 @@ exports.needsMaterializedDialerReportWrite = needsMaterializedDialerReportWrite;
|
|
|
9
9
|
exports.needsMaterializedDialerEntriesWrite = needsMaterializedDialerEntriesWrite;
|
|
10
10
|
exports.foldMaterializedDialerPeriodCounters = foldMaterializedDialerPeriodCounters;
|
|
11
11
|
exports.buildTenantDialerCloseDayPlan = buildTenantDialerCloseDayPlan;
|
|
12
|
-
const
|
|
12
|
+
const bson_objectid_1 = __importDefault(require("bson-objectid"));
|
|
13
13
|
const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
|
|
14
|
-
const
|
|
14
|
+
const MATERIALIZED_SCHEMA_VERSIONS_1 = require("../../constants/MATERIALIZED_SCHEMA_VERSIONS");
|
|
15
15
|
const materialized_dialer_accumulator_helpers_1 = require("./materialized-dialer-accumulator-helpers");
|
|
16
16
|
const materialized_dialer_entry_pages_1 = require("./materialized-dialer-entry-pages");
|
|
17
17
|
const materialized_document_size_1 = require("./materialized-document-size");
|
|
@@ -166,7 +166,7 @@ function buildTenantDialerCloseDayPlan(input) {
|
|
|
166
166
|
const existing = storedReportsByScope.get(dialerScopeKey(compiledDateDoc));
|
|
167
167
|
const next = {
|
|
168
168
|
...compiledDateDoc,
|
|
169
|
-
_id: existing?._id ?? new
|
|
169
|
+
_id: existing?._id ?? new bson_objectid_1.default().toHexString(),
|
|
170
170
|
iteration: Number(existing?.iteration ?? 0) + 1,
|
|
171
171
|
};
|
|
172
172
|
if (force || needsMaterializedDialerReportWrite(existing, next))
|
|
@@ -239,7 +239,7 @@ function buildTenantDialerCloseDayPlan(input) {
|
|
|
239
239
|
for (const key of keys)
|
|
240
240
|
counters[key] = folded[key];
|
|
241
241
|
const report = {
|
|
242
|
-
_id: existing?._id ?? new
|
|
242
|
+
_id: existing?._id ?? new bson_objectid_1.default().toHexString(),
|
|
243
243
|
tenant_id: tenantId,
|
|
244
244
|
brand_id: existing?.brand_id ?? compiledDateDoc?.brand_id ?? '',
|
|
245
245
|
scope_context: scope,
|
|
@@ -248,7 +248,7 @@ function buildTenantDialerCloseDayPlan(input) {
|
|
|
248
248
|
sale_type_key_filters: [...MATERIALIZED_REPORTS_1.DIALER_KEY_FILTERS],
|
|
249
249
|
dialer_counters: counters,
|
|
250
250
|
iteration: existing?.iteration,
|
|
251
|
-
schema_version: compiledDateDoc?.schema_version ??
|
|
251
|
+
schema_version: compiledDateDoc?.schema_version ?? MATERIALIZED_SCHEMA_VERSIONS_1.MATERIALIZED_TENANT_DIALER_REPORTS_SCHEMA_VERSION,
|
|
252
252
|
// FROM THE DAYS THAT BELONG TO THIS PERIOD — never the stored watermark,
|
|
253
253
|
// and never an unrelated day from another period.
|
|
254
254
|
source_watermark: watermarkOfDays(nextDayDocs.filter((dayDoc) => {
|
|
@@ -271,7 +271,7 @@ function buildTenantDialerCloseDayPlan(input) {
|
|
|
271
271
|
const existing = storedEntriesByPage.get(key) ?? null;
|
|
272
272
|
const next = {
|
|
273
273
|
...compiled,
|
|
274
|
-
_id: existing?._id ?? new
|
|
274
|
+
_id: existing?._id ?? new bson_objectid_1.default().toHexString(),
|
|
275
275
|
iteration: Number(existing?.iteration ?? 0) + 1,
|
|
276
276
|
};
|
|
277
277
|
if (existing == null || force || needsMaterializedDialerEntriesWrite(existing, next)) {
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.compileTenantDialerReports = compileTenantDialerReports;
|
|
4
4
|
const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
5
|
+
const MATERIALIZED_SCHEMA_VERSIONS_1 = require("../../constants/MATERIALIZED_SCHEMA_VERSIONS");
|
|
6
|
+
const MATERIALIZED_SCHEMA_VERSIONS_2 = require("../../constants/MATERIALIZED_SCHEMA_VERSIONS");
|
|
7
|
+
const materialized_tenant_dialer_reports_1 = require("../../schemas/types/materialized_tenant_dialer_reports");
|
|
8
8
|
const materialized_dialer_accumulator_helpers_1 = require("./materialized-dialer-accumulator-helpers");
|
|
9
9
|
const materialized_dialer_entry_pages_1 = require("./materialized-dialer-entry-pages");
|
|
10
10
|
const materialized_dialer_key_helpers_1 = require("./materialized-dialer-key-helpers");
|
|
@@ -116,9 +116,9 @@ function compileTenantDialerReports(input) {
|
|
|
116
116
|
scope_context: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_DATE,
|
|
117
117
|
scope_field: localDate,
|
|
118
118
|
day_index: dayIndex,
|
|
119
|
-
sale_type_key_filters: [...
|
|
119
|
+
sale_type_key_filters: [...materialized_tenant_dialer_reports_1.MATERIALIZED_DIALER_REPORT_KEY_FILTERS],
|
|
120
120
|
dialer_counters: dialerCounters,
|
|
121
|
-
schema_version:
|
|
121
|
+
schema_version: MATERIALIZED_SCHEMA_VERSIONS_2.MATERIALIZED_TENANT_DIALER_REPORTS_SCHEMA_VERSION,
|
|
122
122
|
source_watermark: watermark,
|
|
123
123
|
computed_at: computedAt,
|
|
124
124
|
createdAt: computedAt,
|
|
@@ -144,7 +144,7 @@ function compileTenantDialerReports(input) {
|
|
|
144
144
|
page,
|
|
145
145
|
day_index: scope === MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_DATE ? dayIndex : null,
|
|
146
146
|
dialer_entries: entrySections,
|
|
147
|
-
schema_version:
|
|
147
|
+
schema_version: MATERIALIZED_SCHEMA_VERSIONS_1.MATERIALIZED_TENANT_DIALER_ENTRIES_SCHEMA_VERSION,
|
|
148
148
|
source_watermark: watermark,
|
|
149
149
|
computed_at: computedAt,
|
|
150
150
|
createdAt: computedAt,
|
|
@@ -9,9 +9,9 @@ exports.needsMaterializedDineinReportWrite = needsMaterializedDineinReportWrite;
|
|
|
9
9
|
exports.needsMaterializedDineinEntriesWrite = needsMaterializedDineinEntriesWrite;
|
|
10
10
|
exports.foldMaterializedDineinPeriodCounters = foldMaterializedDineinPeriodCounters;
|
|
11
11
|
exports.buildTenantDineinCloseDayPlan = buildTenantDineinCloseDayPlan;
|
|
12
|
-
const
|
|
12
|
+
const bson_objectid_1 = __importDefault(require("bson-objectid"));
|
|
13
13
|
const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
|
|
14
|
-
const
|
|
14
|
+
const MATERIALIZED_SCHEMA_VERSIONS_1 = require("../../constants/MATERIALIZED_SCHEMA_VERSIONS");
|
|
15
15
|
const materialized_dinein_accumulator_helpers_1 = require("./materialized-dinein-accumulator-helpers");
|
|
16
16
|
const materialized_document_size_1 = require("./materialized-document-size");
|
|
17
17
|
const materialized_dinein_entry_pages_1 = require("./materialized-dinein-entry-pages");
|
|
@@ -183,7 +183,7 @@ function buildTenantDineinCloseDayPlan(input) {
|
|
|
183
183
|
const existing = storedReportsByScope.get(dineinScopeKey(compiledDateDoc));
|
|
184
184
|
const next = {
|
|
185
185
|
...compiledDateDoc,
|
|
186
|
-
_id: existing?._id ?? new
|
|
186
|
+
_id: existing?._id ?? new bson_objectid_1.default().toHexString(),
|
|
187
187
|
iteration: Number(existing?.iteration ?? 0) + 1,
|
|
188
188
|
};
|
|
189
189
|
if (force || needsMaterializedDineinReportWrite(existing, next))
|
|
@@ -271,7 +271,7 @@ function buildTenantDineinCloseDayPlan(input) {
|
|
|
271
271
|
for (const key of keys)
|
|
272
272
|
counters[key] = folded.counters[key];
|
|
273
273
|
const report = {
|
|
274
|
-
_id: existing?._id ?? new
|
|
274
|
+
_id: existing?._id ?? new bson_objectid_1.default().toHexString(),
|
|
275
275
|
tenant_id: tenantId,
|
|
276
276
|
brand_id: existing?.brand_id ?? compiledDateDoc?.brand_id ?? '',
|
|
277
277
|
scope_context: scope,
|
|
@@ -287,7 +287,7 @@ function buildTenantDineinCloseDayPlan(input) {
|
|
|
287
287
|
top_edited_checks: folded.topEditedChecks,
|
|
288
288
|
iteration: existing?.iteration,
|
|
289
289
|
// A folded period is always a CURRENT-shape document.
|
|
290
|
-
schema_version: compiledDateDoc?.schema_version ??
|
|
290
|
+
schema_version: compiledDateDoc?.schema_version ?? MATERIALIZED_SCHEMA_VERSIONS_1.MATERIALIZED_TENANT_DINEIN_REPORTS_SCHEMA_VERSION,
|
|
291
291
|
// FROM THE DAYS THAT BELONG TO THIS PERIOD - never the stored watermark.
|
|
292
292
|
source_watermark: watermarkOfDays(nextDayDocs.filter((dayDoc) => {
|
|
293
293
|
const fields = (0, scope_helpers_1.getMaterializedPeriodScopeFields)(String(dayDoc?.scope_field));
|
|
@@ -309,7 +309,7 @@ function buildTenantDineinCloseDayPlan(input) {
|
|
|
309
309
|
const existing = storedEntriesByPage.get(key) ?? null;
|
|
310
310
|
const next = {
|
|
311
311
|
...compiled,
|
|
312
|
-
_id: existing?._id ?? new
|
|
312
|
+
_id: existing?._id ?? new bson_objectid_1.default().toHexString(),
|
|
313
313
|
iteration: Number(existing?.iteration ?? 0) + 1,
|
|
314
314
|
};
|
|
315
315
|
if (existing == null || force || needsMaterializedDineinEntriesWrite(existing, next)) {
|
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.maskReservationGuestLabel = maskReservationGuestLabel;
|
|
4
4
|
exports.compileTenantDineinReports = compileTenantDineinReports;
|
|
5
5
|
const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
6
|
+
const MATERIALIZED_SCHEMA_VERSIONS_1 = require("../../constants/MATERIALIZED_SCHEMA_VERSIONS");
|
|
7
|
+
const MATERIALIZED_SCHEMA_VERSIONS_2 = require("../../constants/MATERIALIZED_SCHEMA_VERSIONS");
|
|
8
|
+
const materialized_tenant_dinein_reports_1 = require("../../schemas/types/materialized_tenant_dinein_reports");
|
|
9
9
|
const materialized_dinein_accumulator_helpers_1 = require("./materialized-dinein-accumulator-helpers");
|
|
10
10
|
const materialized_dinein_classification_helpers_1 = require("./materialized-dinein-classification-helpers");
|
|
11
11
|
const materialized_dinein_entry_pages_1 = require("./materialized-dinein-entry-pages");
|
|
@@ -429,12 +429,12 @@ function compileTenantDineinReports(input) {
|
|
|
429
429
|
scope_context: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_DATE,
|
|
430
430
|
scope_field: localDate,
|
|
431
431
|
day_index: dayIndex,
|
|
432
|
-
sale_type_key_filters: [...
|
|
432
|
+
sale_type_key_filters: [...materialized_tenant_dinein_reports_1.MATERIALIZED_DINEIN_REPORT_KEY_FILTERS],
|
|
433
433
|
dinein_counters: dineinCounters,
|
|
434
434
|
reservation_counters: reservationCounters,
|
|
435
435
|
upcoming_reservations: (0, materialized_dinein_accumulator_helpers_1.mergeMaterializedDineinUpcomingReservations)([upcomingReservations], MATERIALIZED_REPORTS_1.MATERIALIZED_DINEIN_UPCOMING_RESERVATION_LIMIT),
|
|
436
436
|
top_edited_checks: (0, materialized_dinein_accumulator_helpers_1.mergeMaterializedDineinTopEditedChecks)([topEditedChecks], MATERIALIZED_REPORTS_1.MATERIALIZED_DINEIN_TOP_EDITED_CHECK_LIMIT),
|
|
437
|
-
schema_version:
|
|
437
|
+
schema_version: MATERIALIZED_SCHEMA_VERSIONS_2.MATERIALIZED_TENANT_DINEIN_REPORTS_SCHEMA_VERSION,
|
|
438
438
|
source_watermark: watermark,
|
|
439
439
|
computed_at: computedAt,
|
|
440
440
|
createdAt: computedAt,
|
|
@@ -470,7 +470,7 @@ function compileTenantDineinReports(input) {
|
|
|
470
470
|
page,
|
|
471
471
|
day_index: scope === MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_DATE ? dayIndex : null,
|
|
472
472
|
dinein_entries: sections,
|
|
473
|
-
schema_version:
|
|
473
|
+
schema_version: MATERIALIZED_SCHEMA_VERSIONS_1.MATERIALIZED_TENANT_DINEIN_ENTRIES_SCHEMA_VERSION,
|
|
474
474
|
source_watermark: watermark,
|
|
475
475
|
computed_at: computedAt,
|
|
476
476
|
createdAt: computedAt,
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.MATERIALIZED_DISCOUNT_COMPILED_SCOPES = void 0;
|
|
7
7
|
exports.compileTenantDiscountReports = compileTenantDiscountReports;
|
|
8
|
-
const
|
|
8
|
+
const bson_objectid_1 = __importDefault(require("bson-objectid"));
|
|
9
9
|
const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
|
|
10
10
|
const materialized_discount_accumulator_helpers_1 = require("./materialized-discount-accumulator-helpers");
|
|
11
11
|
const materialized_discount_classification_helpers_1 = require("./materialized-discount-classification-helpers");
|
|
@@ -163,7 +163,7 @@ function compileTenantDiscountReports(input) {
|
|
|
163
163
|
const docWatermark = watermark ?? sourceWatermark;
|
|
164
164
|
const isDateScoped = scope === MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_DATE || scope === MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_HOUR;
|
|
165
165
|
reports.push({
|
|
166
|
-
_id: new
|
|
166
|
+
_id: new bson_objectid_1.default().toHexString(),
|
|
167
167
|
tenant_id: tenantId,
|
|
168
168
|
brand_id: brandId,
|
|
169
169
|
scope_context: scope,
|
|
@@ -186,7 +186,7 @@ function compileTenantDiscountReports(input) {
|
|
|
186
186
|
// Entries documents exist only when there is at least one row.
|
|
187
187
|
if (Object.keys(entrySections).length > 0) {
|
|
188
188
|
entriesDocs.push({
|
|
189
|
-
_id: new
|
|
189
|
+
_id: new bson_objectid_1.default().toHexString(),
|
|
190
190
|
tenant_id: tenantId,
|
|
191
191
|
brand_id: brandId,
|
|
192
192
|
scope_context: scope,
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.materializedDocumentBsonBytes = materializedDocumentBsonBytes;
|
|
7
4
|
exports.assertMaterializedDocumentSize = assertMaterializedDocumentSize;
|
|
8
5
|
exports.assertMaterializedDocumentsSize = assertMaterializedDocumentsSize;
|
|
9
|
-
const
|
|
6
|
+
const bson_1 = require("bson");
|
|
10
7
|
/**
|
|
11
8
|
* The BSON SIZE BUDGET of a materialized report/entry/geo document.
|
|
12
9
|
*
|
|
@@ -39,7 +36,7 @@ const mongoose_1 = __importDefault(require("mongoose"));
|
|
|
39
36
|
function materializedDocumentBsonBytes(document) {
|
|
40
37
|
if (document == null)
|
|
41
38
|
return 0;
|
|
42
|
-
return
|
|
39
|
+
return (0, bson_1.calculateObjectSize)(document);
|
|
43
40
|
}
|
|
44
41
|
/**
|
|
45
42
|
* Throws when ONE document exceeds its budget.
|
|
@@ -12,7 +12,7 @@ exports.getMaterializedPrepTimePeriodDayScopeFields = getMaterializedPrepTimePer
|
|
|
12
12
|
exports.getMaterializedPrepTimeReportPeriodDayScopeFields = getMaterializedPrepTimeReportPeriodDayScopeFields;
|
|
13
13
|
exports.needsMaterializedPrepTimeReportWrite = needsMaterializedPrepTimeReportWrite;
|
|
14
14
|
exports.buildTenantPrepTimeCloseDayPlan = buildTenantPrepTimeCloseDayPlan;
|
|
15
|
-
const
|
|
15
|
+
const bson_objectid_1 = __importDefault(require("bson-objectid"));
|
|
16
16
|
const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
|
|
17
17
|
const materialized_prep_time_classification_helpers_1 = require("./materialized-prep-time-classification-helpers");
|
|
18
18
|
const materialized_prep_time_compile_helpers_1 = require("./materialized-prep-time-compile-helpers");
|
|
@@ -375,7 +375,7 @@ function buildTenantPrepTimeCloseDayPlan(input) {
|
|
|
375
375
|
const report = {
|
|
376
376
|
// A period document created by the fold gets a fresh id; an existing one keeps
|
|
377
377
|
// its identity so the upsert targets the same row.
|
|
378
|
-
_id: existingDoc?._id ?? new
|
|
378
|
+
_id: existingDoc?._id ?? new bson_objectid_1.default().toHexString(),
|
|
379
379
|
tenant_id: tenantId,
|
|
380
380
|
brand_id: existingDoc?.brand_id ?? reports[0]?.brand_id ?? '',
|
|
381
381
|
scope_context: scope,
|
|
@@ -486,7 +486,7 @@ function buildTenantPrepTimeCloseDayPlan(input) {
|
|
|
486
486
|
}
|
|
487
487
|
}
|
|
488
488
|
const report = {
|
|
489
|
-
_id: existingDoc?._id ?? new
|
|
489
|
+
_id: existingDoc?._id ?? new bson_objectid_1.default().toHexString(),
|
|
490
490
|
tenant_id: tenantId,
|
|
491
491
|
brand_id: existingDoc?.brand_id ?? entries[0]?.brand_id ?? '',
|
|
492
492
|
scope_context: scope,
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.mergeMaterializedPrepTimeCounters = mergeMaterializedPrepTimeCounters;
|
|
7
7
|
exports.compileTenantPrepTimeReports = compileTenantPrepTimeReports;
|
|
8
|
-
const
|
|
8
|
+
const bson_objectid_1 = __importDefault(require("bson-objectid"));
|
|
9
9
|
const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
|
|
10
10
|
const materialized_prep_time_classification_helpers_1 = require("./materialized-prep-time-classification-helpers");
|
|
11
11
|
const scope_helpers_1 = require("./scope-helpers");
|
|
@@ -176,7 +176,7 @@ function compileTenantPrepTimeReports(input) {
|
|
|
176
176
|
const docWatermark = watermark ?? sourceWatermark;
|
|
177
177
|
const isDateScoped = scopeContext === MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_DATE;
|
|
178
178
|
reports.push({
|
|
179
|
-
_id: new
|
|
179
|
+
_id: new bson_objectid_1.default().toHexString(),
|
|
180
180
|
tenant_id: tenantId,
|
|
181
181
|
brand_id: brandId,
|
|
182
182
|
scope_context: scopeContext,
|
|
@@ -194,7 +194,7 @@ function compileTenantPrepTimeReports(input) {
|
|
|
194
194
|
});
|
|
195
195
|
if (itemScopes.has(scopeContext) && Object.keys(entrySections).length > 0) {
|
|
196
196
|
entries.push({
|
|
197
|
-
_id: new
|
|
197
|
+
_id: new bson_objectid_1.default().toHexString(),
|
|
198
198
|
tenant_id: tenantId,
|
|
199
199
|
brand_id: brandId,
|
|
200
200
|
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,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* PURE materialized-report COMPILE entrypoint.
|
|
4
|
+
*
|
|
5
|
+
* This module is the workers-service Piscina worker's toolkit surface. Its
|
|
6
|
+
* transitive import graph contains NO mongoose, NO schema model, NO DB
|
|
7
|
+
* initializer and NO model registration: every close-day plan/compile helper
|
|
8
|
+
* was moved to pure modules (schema-version constants live in
|
|
9
|
+
* `constants/MATERIALIZED_SCHEMA_VERSIONS`, ObjectIds are generated with
|
|
10
|
+
* `bson-objectid`, document size uses the `bson` calculator).
|
|
11
|
+
*
|
|
12
|
+
* Import the ROOT toolkit barrel for the service-facing API; import THIS module
|
|
13
|
+
* (or its built `lib/helpers/materialized-reports/report-compile.js` path) from
|
|
14
|
+
* a worker.
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.normalizeOverviewAggregatedShape = exports.resolveCreditBillDay = exports.getMaterializedCreditBillScopeRefsForIssue = exports.getMaterializedCreditBillScopeRefsForDay = exports.computeMaterializedCreditBillTotalsFromReportsByKey = exports.buildMaterializedCreditBillSelectionFromScopeGroups = exports.applyCreditResolutionToReportDocuments = exports.buildTenantSalesOverviewCloseDayPlan = exports.sumMaterializedTenantSalesOverviewReports = exports.convertOrdersToMaterializedTenantSalesOverviewReports = exports.buildReportResponse = exports.buildReportMeta = exports.buildReportDetailsResponse = exports.REPORT_MODE_ENUM = exports.REPORT_KEY_ENUM = exports.parseMaterializedLocalDate = exports.getMaterializedPeriodScopeFields = exports.mergeMaterializedDineinEntryPages = exports.dineinKeyPassesFilters = exports.pruneDocumentDineinMaps = exports.foldMaterializedDineinPeriodCounters = exports.buildTenantDineinCloseDayPlan = exports.compileTenantDineinReports = exports.buildTenantDialerCloseDayPlan = exports.compileTenantDialerReports = exports.compileTenantDeliveryGeoCellsWithStats = exports.buildTenantDeliveryCloseDayPlan = exports.compileTenantDeliveryReports = exports.buildTenantDiscountCloseDayPlan = exports.compileTenantDiscountReports = exports.getMaterializedPrepTimeReportPeriodDayScopeFields = exports.getMaterializedPrepTimePeriodDayScopeFields = exports.buildTenantPrepTimeCloseDayPlan = exports.compileTenantPrepTimeReports = exports.REPORT_SALE_TYPE_ENUM = exports.SALES_OVERVIEW_KEY_FILTERS = exports.MATERIALIZED_TENANT_DINEIN_REPORTS_SCHEMA_VERSION = exports.MATERIALIZED_TENANT_DINEIN_ENTRIES_SCHEMA_VERSION = exports.MATERIALIZED_CREDIT_BILLS_SCHEMA_VERSION = exports.MATERIALIZED_REPORT_SCOPE_ENUM = exports.MATERIALIZED_PREP_TIME_REPORT_SCOPES = exports.MATERIALIZED_PREP_TIME_ITEM_SCOPES = exports.MATERIALIZED_DINEIN_UNKNOWN_TOKEN = exports.MATERIALIZED_DINEIN_SPLIT_PARENT_DELETE_REASON = exports.MATERIALIZED_DINEIN_REPORT_SCOPES = exports.MATERIALIZED_DINEIN_ORIGIN_ENUM = void 0;
|
|
18
|
+
var MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
|
|
19
|
+
Object.defineProperty(exports, "MATERIALIZED_DINEIN_ORIGIN_ENUM", { enumerable: true, get: function () { return MATERIALIZED_REPORTS_1.MATERIALIZED_DINEIN_ORIGIN_ENUM; } });
|
|
20
|
+
Object.defineProperty(exports, "MATERIALIZED_DINEIN_REPORT_SCOPES", { enumerable: true, get: function () { return MATERIALIZED_REPORTS_1.MATERIALIZED_DINEIN_REPORT_SCOPES; } });
|
|
21
|
+
Object.defineProperty(exports, "MATERIALIZED_DINEIN_SPLIT_PARENT_DELETE_REASON", { enumerable: true, get: function () { return MATERIALIZED_REPORTS_1.MATERIALIZED_DINEIN_SPLIT_PARENT_DELETE_REASON; } });
|
|
22
|
+
Object.defineProperty(exports, "MATERIALIZED_DINEIN_UNKNOWN_TOKEN", { enumerable: true, get: function () { return MATERIALIZED_REPORTS_1.MATERIALIZED_DINEIN_UNKNOWN_TOKEN; } });
|
|
23
|
+
Object.defineProperty(exports, "MATERIALIZED_PREP_TIME_ITEM_SCOPES", { enumerable: true, get: function () { return MATERIALIZED_REPORTS_1.MATERIALIZED_PREP_TIME_ITEM_SCOPES; } });
|
|
24
|
+
Object.defineProperty(exports, "MATERIALIZED_PREP_TIME_REPORT_SCOPES", { enumerable: true, get: function () { return MATERIALIZED_REPORTS_1.MATERIALIZED_PREP_TIME_REPORT_SCOPES; } });
|
|
25
|
+
Object.defineProperty(exports, "MATERIALIZED_REPORT_SCOPE_ENUM", { enumerable: true, get: function () { return MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_SCOPE_ENUM; } });
|
|
26
|
+
var MATERIALIZED_SCHEMA_VERSIONS_1 = require("../../constants/MATERIALIZED_SCHEMA_VERSIONS");
|
|
27
|
+
Object.defineProperty(exports, "MATERIALIZED_CREDIT_BILLS_SCHEMA_VERSION", { enumerable: true, get: function () { return MATERIALIZED_SCHEMA_VERSIONS_1.MATERIALIZED_CREDIT_BILLS_SCHEMA_VERSION; } });
|
|
28
|
+
Object.defineProperty(exports, "MATERIALIZED_TENANT_DINEIN_ENTRIES_SCHEMA_VERSION", { enumerable: true, get: function () { return MATERIALIZED_SCHEMA_VERSIONS_1.MATERIALIZED_TENANT_DINEIN_ENTRIES_SCHEMA_VERSION; } });
|
|
29
|
+
Object.defineProperty(exports, "MATERIALIZED_TENANT_DINEIN_REPORTS_SCHEMA_VERSION", { enumerable: true, get: function () { return MATERIALIZED_SCHEMA_VERSIONS_1.MATERIALIZED_TENANT_DINEIN_REPORTS_SCHEMA_VERSION; } });
|
|
30
|
+
var MATERIALIZED_REPORTS_2 = require("../../constants/MATERIALIZED_REPORTS");
|
|
31
|
+
Object.defineProperty(exports, "SALES_OVERVIEW_KEY_FILTERS", { enumerable: true, get: function () { return MATERIALIZED_REPORTS_2.SALES_OVERVIEW_KEY_FILTERS; } });
|
|
32
|
+
var ANALYTICS_1 = require("../../constants/ANALYTICS");
|
|
33
|
+
Object.defineProperty(exports, "REPORT_SALE_TYPE_ENUM", { enumerable: true, get: function () { return ANALYTICS_1.REPORT_SALE_TYPE_ENUM; } });
|
|
34
|
+
var materialized_prep_time_compile_helpers_1 = require("./materialized-prep-time-compile-helpers");
|
|
35
|
+
Object.defineProperty(exports, "compileTenantPrepTimeReports", { enumerable: true, get: function () { return materialized_prep_time_compile_helpers_1.compileTenantPrepTimeReports; } });
|
|
36
|
+
var materialized_prep_time_close_day_helpers_1 = require("./materialized-prep-time-close-day-helpers");
|
|
37
|
+
Object.defineProperty(exports, "buildTenantPrepTimeCloseDayPlan", { enumerable: true, get: function () { return materialized_prep_time_close_day_helpers_1.buildTenantPrepTimeCloseDayPlan; } });
|
|
38
|
+
Object.defineProperty(exports, "getMaterializedPrepTimePeriodDayScopeFields", { enumerable: true, get: function () { return materialized_prep_time_close_day_helpers_1.getMaterializedPrepTimePeriodDayScopeFields; } });
|
|
39
|
+
Object.defineProperty(exports, "getMaterializedPrepTimeReportPeriodDayScopeFields", { enumerable: true, get: function () { return materialized_prep_time_close_day_helpers_1.getMaterializedPrepTimeReportPeriodDayScopeFields; } });
|
|
40
|
+
var materialized_discount_compile_helpers_1 = require("./materialized-discount-compile-helpers");
|
|
41
|
+
Object.defineProperty(exports, "compileTenantDiscountReports", { enumerable: true, get: function () { return materialized_discount_compile_helpers_1.compileTenantDiscountReports; } });
|
|
42
|
+
var materialized_discount_close_day_helpers_1 = require("./materialized-discount-close-day-helpers");
|
|
43
|
+
Object.defineProperty(exports, "buildTenantDiscountCloseDayPlan", { enumerable: true, get: function () { return materialized_discount_close_day_helpers_1.buildTenantDiscountCloseDayPlan; } });
|
|
44
|
+
var materialized_delivery_compile_helpers_1 = require("./materialized-delivery-compile-helpers");
|
|
45
|
+
Object.defineProperty(exports, "compileTenantDeliveryReports", { enumerable: true, get: function () { return materialized_delivery_compile_helpers_1.compileTenantDeliveryReports; } });
|
|
46
|
+
var materialized_delivery_close_day_helpers_1 = require("./materialized-delivery-close-day-helpers");
|
|
47
|
+
Object.defineProperty(exports, "buildTenantDeliveryCloseDayPlan", { enumerable: true, get: function () { return materialized_delivery_close_day_helpers_1.buildTenantDeliveryCloseDayPlan; } });
|
|
48
|
+
var materialized_tenant_delivery_geo_helpers_1 = require("./materialized-tenant-delivery-geo-helpers");
|
|
49
|
+
Object.defineProperty(exports, "compileTenantDeliveryGeoCellsWithStats", { enumerable: true, get: function () { return materialized_tenant_delivery_geo_helpers_1.compileTenantDeliveryGeoCellsWithStats; } });
|
|
50
|
+
var materialized_dialer_compile_helpers_1 = require("./materialized-dialer-compile-helpers");
|
|
51
|
+
Object.defineProperty(exports, "compileTenantDialerReports", { enumerable: true, get: function () { return materialized_dialer_compile_helpers_1.compileTenantDialerReports; } });
|
|
52
|
+
var materialized_dialer_close_day_helpers_1 = require("./materialized-dialer-close-day-helpers");
|
|
53
|
+
Object.defineProperty(exports, "buildTenantDialerCloseDayPlan", { enumerable: true, get: function () { return materialized_dialer_close_day_helpers_1.buildTenantDialerCloseDayPlan; } });
|
|
54
|
+
var materialized_dinein_compile_helpers_1 = require("./materialized-dinein-compile-helpers");
|
|
55
|
+
Object.defineProperty(exports, "compileTenantDineinReports", { enumerable: true, get: function () { return materialized_dinein_compile_helpers_1.compileTenantDineinReports; } });
|
|
56
|
+
var materialized_dinein_close_day_helpers_1 = require("./materialized-dinein-close-day-helpers");
|
|
57
|
+
Object.defineProperty(exports, "buildTenantDineinCloseDayPlan", { enumerable: true, get: function () { return materialized_dinein_close_day_helpers_1.buildTenantDineinCloseDayPlan; } });
|
|
58
|
+
Object.defineProperty(exports, "foldMaterializedDineinPeriodCounters", { enumerable: true, get: function () { return materialized_dinein_close_day_helpers_1.foldMaterializedDineinPeriodCounters; } });
|
|
59
|
+
var materialized_dinein_accumulator_helpers_1 = require("./materialized-dinein-accumulator-helpers");
|
|
60
|
+
Object.defineProperty(exports, "pruneDocumentDineinMaps", { enumerable: true, get: function () { return materialized_dinein_accumulator_helpers_1.pruneDocumentDineinMaps; } });
|
|
61
|
+
var materialized_dinein_key_helpers_1 = require("./materialized-dinein-key-helpers");
|
|
62
|
+
Object.defineProperty(exports, "dineinKeyPassesFilters", { enumerable: true, get: function () { return materialized_dinein_key_helpers_1.dineinKeyPassesFilters; } });
|
|
63
|
+
var materialized_dinein_entry_pages_1 = require("./materialized-dinein-entry-pages");
|
|
64
|
+
Object.defineProperty(exports, "mergeMaterializedDineinEntryPages", { enumerable: true, get: function () { return materialized_dinein_entry_pages_1.mergeMaterializedDineinEntryPages; } });
|
|
65
|
+
var scope_helpers_1 = require("./scope-helpers");
|
|
66
|
+
Object.defineProperty(exports, "getMaterializedPeriodScopeFields", { enumerable: true, get: function () { return scope_helpers_1.getMaterializedPeriodScopeFields; } });
|
|
67
|
+
Object.defineProperty(exports, "parseMaterializedLocalDate", { enumerable: true, get: function () { return scope_helpers_1.parseMaterializedLocalDate; } });
|
|
68
|
+
var report_contract_1 = require("../reporting-contract/report-contract");
|
|
69
|
+
Object.defineProperty(exports, "REPORT_KEY_ENUM", { enumerable: true, get: function () { return report_contract_1.REPORT_KEY_ENUM; } });
|
|
70
|
+
Object.defineProperty(exports, "REPORT_MODE_ENUM", { enumerable: true, get: function () { return report_contract_1.REPORT_MODE_ENUM; } });
|
|
71
|
+
Object.defineProperty(exports, "buildReportDetailsResponse", { enumerable: true, get: function () { return report_contract_1.buildReportDetailsResponse; } });
|
|
72
|
+
Object.defineProperty(exports, "buildReportMeta", { enumerable: true, get: function () { return report_contract_1.buildReportMeta; } });
|
|
73
|
+
Object.defineProperty(exports, "buildReportResponse", { enumerable: true, get: function () { return report_contract_1.buildReportResponse; } });
|
|
74
|
+
var tenant_sales_overview_helpers_1 = require("./tenant-sales-overview-helpers");
|
|
75
|
+
Object.defineProperty(exports, "convertOrdersToMaterializedTenantSalesOverviewReports", { enumerable: true, get: function () { return tenant_sales_overview_helpers_1.convertOrdersToMaterializedTenantSalesOverviewReports; } });
|
|
76
|
+
Object.defineProperty(exports, "sumMaterializedTenantSalesOverviewReports", { enumerable: true, get: function () { return tenant_sales_overview_helpers_1.sumMaterializedTenantSalesOverviewReports; } });
|
|
77
|
+
var tenant_sales_overview_close_day_helpers_1 = require("./tenant-sales-overview-close-day-helpers");
|
|
78
|
+
Object.defineProperty(exports, "buildTenantSalesOverviewCloseDayPlan", { enumerable: true, get: function () { return tenant_sales_overview_close_day_helpers_1.buildTenantSalesOverviewCloseDayPlan; } });
|
|
79
|
+
var materialized_credit_bills_helpers_1 = require("./materialized-credit-bills-helpers");
|
|
80
|
+
Object.defineProperty(exports, "applyCreditResolutionToReportDocuments", { enumerable: true, get: function () { return materialized_credit_bills_helpers_1.applyCreditResolutionToReportDocuments; } });
|
|
81
|
+
Object.defineProperty(exports, "buildMaterializedCreditBillSelectionFromScopeGroups", { enumerable: true, get: function () { return materialized_credit_bills_helpers_1.buildMaterializedCreditBillSelectionFromScopeGroups; } });
|
|
82
|
+
Object.defineProperty(exports, "computeMaterializedCreditBillTotalsFromReportsByKey", { enumerable: true, get: function () { return materialized_credit_bills_helpers_1.computeMaterializedCreditBillTotalsFromReportsByKey; } });
|
|
83
|
+
Object.defineProperty(exports, "getMaterializedCreditBillScopeRefsForDay", { enumerable: true, get: function () { return materialized_credit_bills_helpers_1.getMaterializedCreditBillScopeRefsForDay; } });
|
|
84
|
+
Object.defineProperty(exports, "getMaterializedCreditBillScopeRefsForIssue", { enumerable: true, get: function () { return materialized_credit_bills_helpers_1.getMaterializedCreditBillScopeRefsForIssue; } });
|
|
85
|
+
Object.defineProperty(exports, "resolveCreditBillDay", { enumerable: true, get: function () { return materialized_credit_bills_helpers_1.resolveCreditBillDay; } });
|
|
86
|
+
var overview_contract_1 = require("../reporting-contract/overview-contract");
|
|
87
|
+
Object.defineProperty(exports, "normalizeOverviewAggregatedShape", { enumerable: true, get: function () { return overview_contract_1.normalizeOverviewAggregatedShape; } });
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import mongoose from 'mongoose';
|
|
2
|
+
import type { IMaterializedTenantSalesOverviewReport } from '../../schemas/types/materialized_tenant_sales_overview_reports';
|
|
3
|
+
/**
|
|
4
|
+
* Casts a JSON materialized report through the collection's mongoose schema,
|
|
5
|
+
* returning a hydrated document ready to be saved / bulk-written (the
|
|
6
|
+
* `sale_type_metrics` plain object becomes a `Map`, date strings become
|
|
7
|
+
* `Date` instances, etc.).
|
|
8
|
+
*
|
|
9
|
+
* The document is NOT validated here — `save()` / `Model.validate()` still
|
|
10
|
+
* runs the schema validators.
|
|
11
|
+
*/
|
|
12
|
+
export declare function convertMaterializedTenantSalesOverviewReportJsonToBson(report: IMaterializedTenantSalesOverviewReport): mongoose.HydratedDocument<IMaterializedTenantSalesOverviewReport>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.convertMaterializedTenantSalesOverviewReportJsonToBson = convertMaterializedTenantSalesOverviewReportJsonToBson;
|
|
7
|
+
const mongoose_1 = __importDefault(require("mongoose"));
|
|
8
|
+
const materialized_tenant_sales_overview_reports_1 = require("../../schemas/models/materialized_tenant_sales_overview_reports");
|
|
9
|
+
/**
|
|
10
|
+
* MAIN-THREAD-ONLY Overview persistence adapter.
|
|
11
|
+
*
|
|
12
|
+
* Deliberately SPLIT from `tenant-sales-overview-helpers.ts`: the compile
|
|
13
|
+
* helpers must stay mongoose-free for the workers-service Piscina compile
|
|
14
|
+
* graph, while the BSON casting step needs the mongoose schema. Importing this
|
|
15
|
+
* file is the ONLY way to pull mongoose into the Overview compile path — and
|
|
16
|
+
* the worker never imports it.
|
|
17
|
+
*/
|
|
18
|
+
function getMaterializedTenantSalesOverviewReportModel() {
|
|
19
|
+
return (mongoose_1.default.models[materialized_tenant_sales_overview_reports_1.MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_COLLECTION_NAME] ??
|
|
20
|
+
mongoose_1.default.model(materialized_tenant_sales_overview_reports_1.MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_COLLECTION_NAME, materialized_tenant_sales_overview_reports_1.MaterializedTenantSalesOverviewReportSchema, materialized_tenant_sales_overview_reports_1.MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_COLLECTION_NAME));
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Casts a JSON materialized report through the collection's mongoose schema,
|
|
24
|
+
* returning a hydrated document ready to be saved / bulk-written (the
|
|
25
|
+
* `sale_type_metrics` plain object becomes a `Map`, date strings become
|
|
26
|
+
* `Date` instances, etc.).
|
|
27
|
+
*
|
|
28
|
+
* The document is NOT validated here — `save()` / `Model.validate()` still
|
|
29
|
+
* runs the schema validators.
|
|
30
|
+
*/
|
|
31
|
+
function convertMaterializedTenantSalesOverviewReportJsonToBson(report) {
|
|
32
|
+
return new (getMaterializedTenantSalesOverviewReportModel())(report);
|
|
33
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { IOrder, IOrderPayment } from '../../schemas';
|
|
1
|
+
import type { IOrder, IOrderPayment } from '../../schemas/types/orders';
|
|
3
2
|
import { IMaterializedReportKeyMetrics, IMaterializedTenantSalesOverviewReport } from '../../schemas/types/materialized_tenant_sales_overview_reports';
|
|
4
3
|
import { ICreditBillEventCandidate, ICreditBillIssuedCandidate, isMaterializedCreditBillPayment } from './materialized-credit-bills-helpers';
|
|
5
4
|
/**
|
|
@@ -133,16 +132,6 @@ export declare function normalizeMaterializedSaleTypeMetrics(metrics: IMateriali
|
|
|
133
132
|
* missing or containing reserved characters) — `null` means a data issue.
|
|
134
133
|
*/
|
|
135
134
|
export declare function convertOrdersToMaterializedTenantSalesOverviewReports(localDate: string, orders: IOrder[], options?: IConvertOrdersToMaterializedReportsOptions): IConvertOrdersToMaterializedReportsResult | null;
|
|
136
|
-
/**
|
|
137
|
-
* Casts a JSON materialized report through the collection's mongoose schema,
|
|
138
|
-
* returning a hydrated document ready to be saved / bulk-written (the
|
|
139
|
-
* `sale_type_metrics` plain object becomes a `Map`, date strings become
|
|
140
|
-
* `Date` instances, etc.).
|
|
141
|
-
*
|
|
142
|
-
* The document is NOT validated here — `save()` / `Model.validate()` still
|
|
143
|
-
* runs the schema validators.
|
|
144
|
-
*/
|
|
145
|
-
export declare function convertMaterializedTenantSalesOverviewReportJsonToBson(report: IMaterializedTenantSalesOverviewReport): mongoose.HydratedDocument<IMaterializedTenantSalesOverviewReport>;
|
|
146
135
|
/**
|
|
147
136
|
* Sums materialized reports that share the same tenant, brand, key filters and
|
|
148
137
|
* `schema_version` — the period accumulation path. The scope MAY differ: pass
|
|
@@ -9,14 +9,13 @@ exports.isPaymentIncludedInMaterializedSalesOverview = isPaymentIncludedInMateri
|
|
|
9
9
|
exports.getMaterializedPaymentGross = getMaterializedPaymentGross;
|
|
10
10
|
exports.normalizeMaterializedSaleTypeMetrics = normalizeMaterializedSaleTypeMetrics;
|
|
11
11
|
exports.convertOrdersToMaterializedTenantSalesOverviewReports = convertOrdersToMaterializedTenantSalesOverviewReports;
|
|
12
|
-
exports.convertMaterializedTenantSalesOverviewReportJsonToBson = convertMaterializedTenantSalesOverviewReportJsonToBson;
|
|
13
12
|
exports.sumMaterializedTenantSalesOverviewReports = sumMaterializedTenantSalesOverviewReports;
|
|
14
13
|
exports.subtractMaterializedTenantSalesOverviewReports = subtractMaterializedTenantSalesOverviewReports;
|
|
15
14
|
exports.updateMaterializedTenantSalesOverviewReport = updateMaterializedTenantSalesOverviewReport;
|
|
16
|
-
const
|
|
15
|
+
const bson_objectid_1 = __importDefault(require("bson-objectid"));
|
|
16
|
+
const MATERIALIZED_SCHEMA_VERSIONS_1 = require("../../constants/MATERIALIZED_SCHEMA_VERSIONS");
|
|
17
17
|
const constants_1 = require("../../constants");
|
|
18
18
|
const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
|
|
19
|
-
const materialized_tenant_sales_overview_reports_1 = require("../../schemas/models/materialized_tenant_sales_overview_reports");
|
|
20
19
|
const key_helpers_1 = require("./key-helpers");
|
|
21
20
|
const materialized_day_input_signature_1 = require("./materialized-day-input-signature");
|
|
22
21
|
const materialized_credit_bills_helpers_1 = require("./materialized-credit-bills-helpers");
|
|
@@ -341,7 +340,7 @@ const createEmptyReportDocument = (args) => {
|
|
|
341
340
|
? (0, scope_helpers_1.getDayIndexFromLocalDate)(scopeField.split(' ')[0])
|
|
342
341
|
: null;
|
|
343
342
|
return {
|
|
344
|
-
_id: new
|
|
343
|
+
_id: new bson_objectid_1.default().toHexString(),
|
|
345
344
|
tenant_id: tenantId,
|
|
346
345
|
brand_id: brandId,
|
|
347
346
|
scope_context: scopeContext,
|
|
@@ -353,7 +352,7 @@ const createEmptyReportDocument = (args) => {
|
|
|
353
352
|
// does not run mongoose defaults) persists a schema-conformant document
|
|
354
353
|
// matching its history row.
|
|
355
354
|
iteration: 1,
|
|
356
|
-
schema_version:
|
|
355
|
+
schema_version: MATERIALIZED_SCHEMA_VERSIONS_1.MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_SCHEMA_VERSION,
|
|
357
356
|
source_watermark: now,
|
|
358
357
|
computed_at: now,
|
|
359
358
|
createdAt: now,
|
|
@@ -546,25 +545,6 @@ function convertOrdersToMaterializedTenantSalesOverviewReports(localDate, orders
|
|
|
546
545
|
return { materializedReports, credit_bill_issues: creditBillIssues, credit_bill_events: creditEventCandidates };
|
|
547
546
|
}
|
|
548
547
|
/* ------------------------------------------------------------------------ */
|
|
549
|
-
/* 2. JSON → BSON (mongoose document) */
|
|
550
|
-
/* ------------------------------------------------------------------------ */
|
|
551
|
-
function getMaterializedTenantSalesOverviewReportModel() {
|
|
552
|
-
return (mongoose_1.default.models[materialized_tenant_sales_overview_reports_1.MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_COLLECTION_NAME] ??
|
|
553
|
-
mongoose_1.default.model(materialized_tenant_sales_overview_reports_1.MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_COLLECTION_NAME, materialized_tenant_sales_overview_reports_1.MaterializedTenantSalesOverviewReportSchema, materialized_tenant_sales_overview_reports_1.MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_COLLECTION_NAME));
|
|
554
|
-
}
|
|
555
|
-
/**
|
|
556
|
-
* Casts a JSON materialized report through the collection's mongoose schema,
|
|
557
|
-
* returning a hydrated document ready to be saved / bulk-written (the
|
|
558
|
-
* `sale_type_metrics` plain object becomes a `Map`, date strings become
|
|
559
|
-
* `Date` instances, etc.).
|
|
560
|
-
*
|
|
561
|
-
* The document is NOT validated here — `save()` / `Model.validate()` still
|
|
562
|
-
* runs the schema validators.
|
|
563
|
-
*/
|
|
564
|
-
function convertMaterializedTenantSalesOverviewReportJsonToBson(report) {
|
|
565
|
-
return new (getMaterializedTenantSalesOverviewReportModel())(report);
|
|
566
|
-
}
|
|
567
|
-
/* ------------------------------------------------------------------------ */
|
|
568
548
|
/* 3. Summing documents (period accumulation) */
|
|
569
549
|
/* ------------------------------------------------------------------------ */
|
|
570
550
|
const sumOrderMetrics = (target, source) => {
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { IOrderPayment, ITenantPurchaseOrder, ITenantPurchaseOrderCategory, ITenantPurchaseOrderDiscountDetails, ITenantPurchaseOrderItem, ITenantPurchaseOrderIteration } from '../../schemas';
|
|
1
|
+
import { IDiscountDetails, IOrderPayment, ITenantPurchaseOrder, ITenantPurchaseOrderCategory, ITenantPurchaseOrderDiscountDetails, ITenantPurchaseOrderItem, ITenantPurchaseOrderIteration } from '../../schemas';
|
|
2
2
|
import { SORT_TYPE_ENUM } from '../../constants';
|
|
3
3
|
import { ITenantGeneralPurchaseOrderItem, ITenantPurchaseOrderCartItemsObj } from '../types/tenant-purchase-order-cart-actions';
|
|
4
4
|
export declare function getTenantPurchaseOrderIterationsWithPrice(iterations?: ITenantPurchaseOrderIteration[] | undefined, writeable?: boolean): ITenantPurchaseOrderIteration[];
|
|
5
5
|
export declare function getTenantPurchaseOrderPaymentsWithPrice(payments: IOrderPayment[] | undefined, convertToPrice: (price: number) => number): IOrderPayment[];
|
|
6
|
+
/**
|
|
7
|
+
* An item discount mixes money and percentages, so the shared order-discount
|
|
8
|
+
* conversion is applied: percentages are left untouched.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getTenantPurchaseOrderItemDiscountDetailsWithPrice(discount: IDiscountDetails, convertToPrice: (price: number) => number): IDiscountDetails;
|
|
6
11
|
export declare function getTenantPurchaseOrderItemsWithPrice(items: ITenantPurchaseOrderItem[] | undefined, convertToPrice: (price: number) => number): ITenantPurchaseOrderItem[];
|
|
7
12
|
export declare function getTenantPurchaseOrderCategoriesWithPrice(categories: ITenantPurchaseOrderCategory[] | undefined, convertToPrice: (price: number) => number): ITenantPurchaseOrderCategory[];
|
|
8
13
|
export declare function getTenantPurchaseOrderDiscountDetailsWithPrice(discount: ITenantPurchaseOrderDiscountDetails | null | undefined, convertToPrice: (price: number) => number): ITenantPurchaseOrderDiscountDetails | null;
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getTenantPurchaseOrderIterationsWithPrice = getTenantPurchaseOrderIterationsWithPrice;
|
|
7
7
|
exports.getTenantPurchaseOrderPaymentsWithPrice = getTenantPurchaseOrderPaymentsWithPrice;
|
|
8
|
+
exports.getTenantPurchaseOrderItemDiscountDetailsWithPrice = getTenantPurchaseOrderItemDiscountDetailsWithPrice;
|
|
8
9
|
exports.getTenantPurchaseOrderItemsWithPrice = getTenantPurchaseOrderItemsWithPrice;
|
|
9
10
|
exports.getTenantPurchaseOrderCategoriesWithPrice = getTenantPurchaseOrderCategoriesWithPrice;
|
|
10
11
|
exports.getTenantPurchaseOrderDiscountDetailsWithPrice = getTenantPurchaseOrderDiscountDetailsWithPrice;
|
|
@@ -40,6 +41,13 @@ function getTenantPurchaseOrderPaymentsWithPrice(payments, convertToPrice) {
|
|
|
40
41
|
amount_refunded: convertToPrice(payment.amount_refunded),
|
|
41
42
|
}));
|
|
42
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* An item discount mixes money and percentages, so the shared order-discount
|
|
46
|
+
* conversion is applied: percentages are left untouched.
|
|
47
|
+
*/
|
|
48
|
+
function getTenantPurchaseOrderItemDiscountDetailsWithPrice(discount, convertToPrice) {
|
|
49
|
+
return getTenantPurchaseOrderDiscountDetailsWithPrice(discount, convertToPrice);
|
|
50
|
+
}
|
|
43
51
|
function getTenantPurchaseOrderItemsWithPrice(items, convertToPrice) {
|
|
44
52
|
if (!items)
|
|
45
53
|
return [];
|
|
@@ -48,6 +56,11 @@ function getTenantPurchaseOrderItemsWithPrice(items, convertToPrice) {
|
|
|
48
56
|
quantity: (0, utils_1.parseNum)(item.quantity || 1, true),
|
|
49
57
|
price: convertToPrice(item.price ?? 0),
|
|
50
58
|
subtotal: convertToPrice(item.subtotal ?? 0),
|
|
59
|
+
...(item.item_discount_details != null
|
|
60
|
+
? {
|
|
61
|
+
item_discount_details: getTenantPurchaseOrderItemDiscountDetailsWithPrice(item.item_discount_details, convertToPrice),
|
|
62
|
+
}
|
|
63
|
+
: {}),
|
|
51
64
|
_gst_amount: convertToPrice(item._gst_amount ?? 0),
|
|
52
65
|
_net_amount: convertToPrice(item._net_amount ?? 0),
|
|
53
66
|
_gross_amount: convertToPrice(item._gross_amount ?? 0),
|