@managesome/eposmatic-toolkit 0.4.8 → 0.4.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/constants/MATERIALIZED_REPORTS.js +448 -0
- package/esm/constants/enums/communications.js +1 -0
- package/esm/helpers/index.js +3 -0
- package/esm/helpers/materialized-reports/index.js +32 -0
- package/esm/helpers/materialized-reports/materialized-cash-accumulator-helpers.js +114 -0
- package/esm/helpers/materialized-reports/materialized-cash-classification-helpers.js +286 -0
- package/esm/helpers/materialized-reports/materialized-cash-close-day-helpers.js +396 -0
- package/esm/helpers/materialized-reports/materialized-cash-compile-helpers.js +244 -0
- package/esm/helpers/materialized-reports/materialized-delivery-accumulator-helpers.js +170 -0
- package/esm/helpers/materialized-reports/materialized-delivery-classification-helpers.js +426 -0
- package/esm/helpers/materialized-reports/materialized-delivery-close-day-helpers.js +372 -0
- package/esm/helpers/materialized-reports/materialized-delivery-compile-helpers.js +214 -0
- package/esm/helpers/materialized-reports/materialized-discount-accumulator-helpers.js +318 -0
- package/esm/helpers/materialized-reports/materialized-discount-classification-helpers.js +213 -0
- package/esm/helpers/materialized-reports/materialized-discount-close-day-helpers.js +604 -0
- package/esm/helpers/materialized-reports/materialized-discount-compile-helpers.js +186 -0
- package/esm/helpers/materialized-reports/materialized-hourly-comparison-close-day-helpers.js +155 -0
- package/esm/helpers/materialized-reports/materialized-hourly-comparison-compile-helpers.js +199 -0
- package/esm/helpers/materialized-reports/materialized-hourly-comparison-selection-helpers.js +111 -0
- package/esm/helpers/materialized-reports/materialized-payments-comparison-accumulator-helpers.js +88 -0
- package/esm/helpers/materialized-reports/materialized-payments-comparison-close-day-helpers.js +394 -0
- package/esm/helpers/materialized-reports/materialized-payments-comparison-compile-helpers.js +167 -0
- package/esm/helpers/materialized-reports/materialized-prep-time-classification-helpers.js +215 -0
- package/esm/helpers/materialized-reports/materialized-prep-time-close-day-helpers.js +476 -0
- package/esm/helpers/materialized-reports/materialized-prep-time-compile-helpers.js +201 -0
- package/esm/helpers/materialized-reports/materialized-reports-selection-helpers.js +7 -0
- package/esm/helpers/materialized-reports/materialized-sales-comparison-accumulator-helpers.js +189 -0
- package/esm/helpers/materialized-reports/materialized-sales-comparison-baseline-helpers.js +157 -0
- package/esm/helpers/materialized-reports/materialized-sales-comparison-close-day-helpers.js +588 -0
- package/esm/helpers/materialized-reports/materialized-sales-comparison-compile-helpers.js +175 -0
- package/esm/helpers/materialized-reports/tenant-cash-in-out-formatter.js +156 -0
- package/esm/helpers/materialized-reports/tenant-delivery-formatter.js +230 -0
- package/esm/helpers/materialized-reports/tenant-discount-formatter.js +427 -0
- package/esm/helpers/materialized-reports/tenant-hourly-comparison-formatter.js +237 -0
- package/esm/helpers/materialized-reports/tenant-payments-comparison-formatter.js +279 -0
- package/esm/helpers/materialized-reports/tenant-prep-time-formatter.js +228 -0
- package/esm/helpers/materialized-reports/tenant-sales-comparison-formatter.js +343 -0
- package/esm/helpers/reporting-contract/index.js +2 -0
- package/esm/helpers/reporting-contract/overview-contract.js +122 -0
- package/esm/helpers/reporting-contract/report-contract.js +228 -0
- package/esm/helpers/rider-earnings/index.js +1 -0
- package/esm/helpers/rider-earnings/rider-earnings.js +59 -0
- package/esm/helpers/rider-reports/index.js +2 -0
- package/esm/helpers/rider-reports/rider-daily-report.js +90 -0
- package/esm/helpers/rider-reports/rider-report.js +67 -0
- package/esm/schemas/models/deliveries.js +75 -0
- package/esm/schemas/models/index.js +15 -0
- package/esm/schemas/models/materialized_rider_daily_reports.js +39 -0
- package/esm/schemas/models/materialized_tenant_cash_entries.js +95 -0
- package/esm/schemas/models/materialized_tenant_cash_reports.js +77 -0
- package/esm/schemas/models/materialized_tenant_delivery_entries.js +63 -0
- package/esm/schemas/models/materialized_tenant_delivery_reports.js +63 -0
- package/esm/schemas/models/materialized_tenant_discount_entries.js +156 -0
- package/esm/schemas/models/materialized_tenant_discount_reports.js +333 -0
- package/esm/schemas/models/materialized_tenant_hourly_comparison_entries.js +87 -0
- package/esm/schemas/models/materialized_tenant_hourly_comparison_reports.js +99 -0
- package/esm/schemas/models/materialized_tenant_payments_comparison_entries.js +71 -0
- package/esm/schemas/models/materialized_tenant_payments_comparison_reports.js +76 -0
- package/esm/schemas/models/materialized_tenant_prep_time_entries.js +130 -0
- package/esm/schemas/models/materialized_tenant_prep_time_reports.js +109 -0
- package/esm/schemas/models/materialized_tenant_sales_comparison_entries.js +130 -0
- package/esm/schemas/models/materialized_tenant_sales_comparison_reports.js +154 -0
- package/esm/schemas/types/index.js +15 -0
- package/esm/schemas/types/materialized_rider_daily_reports.js +1 -0
- package/esm/schemas/types/materialized_tenant_cash_entries.js +1 -0
- package/esm/schemas/types/materialized_tenant_cash_reports.js +1 -0
- package/esm/schemas/types/materialized_tenant_delivery_entries.js +1 -0
- package/esm/schemas/types/materialized_tenant_delivery_reports.js +1 -0
- package/esm/schemas/types/materialized_tenant_discount_entries.js +1 -0
- package/esm/schemas/types/materialized_tenant_discount_reports.js +2 -0
- package/esm/schemas/types/materialized_tenant_hourly_comparison_entries.js +1 -0
- package/esm/schemas/types/materialized_tenant_hourly_comparison_reports.js +1 -0
- package/esm/schemas/types/materialized_tenant_payments_comparison_entries.js +1 -0
- package/esm/schemas/types/materialized_tenant_payments_comparison_reports.js +11 -0
- package/esm/schemas/types/materialized_tenant_prep_time_entries.js +1 -0
- package/esm/schemas/types/materialized_tenant_prep_time_reports.js +1 -0
- package/esm/schemas/types/materialized_tenant_sales_comparison_entries.js +1 -0
- package/esm/schemas/types/materialized_tenant_sales_comparison_reports.js +14 -0
- package/lib/constants/MATERIALIZED_REPORTS.d.ts +339 -2
- package/lib/constants/MATERIALIZED_REPORTS.js +450 -1
- package/lib/constants/enums/communications.d.ts +1 -0
- package/lib/constants/enums/communications.js +2 -1
- package/lib/helpers/index.d.ts +3 -0
- package/lib/helpers/index.js +3 -0
- package/lib/helpers/materialized-reports/index.d.ts +32 -0
- package/lib/helpers/materialized-reports/index.js +32 -0
- package/lib/helpers/materialized-reports/materialized-cash-accumulator-helpers.d.ts +18 -0
- package/lib/helpers/materialized-reports/materialized-cash-accumulator-helpers.js +118 -0
- package/lib/helpers/materialized-reports/materialized-cash-classification-helpers.d.ts +90 -0
- package/lib/helpers/materialized-reports/materialized-cash-classification-helpers.js +295 -0
- package/lib/helpers/materialized-reports/materialized-cash-close-day-helpers.d.ts +102 -0
- package/lib/helpers/materialized-reports/materialized-cash-close-day-helpers.js +409 -0
- package/lib/helpers/materialized-reports/materialized-cash-compile-helpers.d.ts +72 -0
- package/lib/helpers/materialized-reports/materialized-cash-compile-helpers.js +251 -0
- package/lib/helpers/materialized-reports/materialized-delivery-accumulator-helpers.d.ts +7 -0
- package/lib/helpers/materialized-reports/materialized-delivery-accumulator-helpers.js +173 -0
- package/lib/helpers/materialized-reports/materialized-delivery-classification-helpers.d.ts +84 -0
- package/lib/helpers/materialized-reports/materialized-delivery-classification-helpers.js +438 -0
- package/lib/helpers/materialized-reports/materialized-delivery-close-day-helpers.d.ts +97 -0
- package/lib/helpers/materialized-reports/materialized-delivery-close-day-helpers.js +385 -0
- package/lib/helpers/materialized-reports/materialized-delivery-compile-helpers.d.ts +40 -0
- package/lib/helpers/materialized-reports/materialized-delivery-compile-helpers.js +218 -0
- package/lib/helpers/materialized-reports/materialized-discount-accumulator-helpers.d.ts +52 -0
- package/lib/helpers/materialized-reports/materialized-discount-accumulator-helpers.js +324 -0
- package/lib/helpers/materialized-reports/materialized-discount-classification-helpers.d.ts +50 -0
- package/lib/helpers/materialized-reports/materialized-discount-classification-helpers.js +222 -0
- package/lib/helpers/materialized-reports/materialized-discount-close-day-helpers.d.ts +182 -0
- package/lib/helpers/materialized-reports/materialized-discount-close-day-helpers.js +615 -0
- package/lib/helpers/materialized-reports/materialized-discount-compile-helpers.d.ts +47 -0
- package/lib/helpers/materialized-reports/materialized-discount-compile-helpers.js +193 -0
- package/lib/helpers/materialized-reports/materialized-hourly-comparison-close-day-helpers.d.ts +64 -0
- package/lib/helpers/materialized-reports/materialized-hourly-comparison-close-day-helpers.js +163 -0
- package/lib/helpers/materialized-reports/materialized-hourly-comparison-compile-helpers.d.ts +61 -0
- package/lib/helpers/materialized-reports/materialized-hourly-comparison-compile-helpers.js +207 -0
- package/lib/helpers/materialized-reports/materialized-hourly-comparison-selection-helpers.d.ts +23 -0
- package/lib/helpers/materialized-reports/materialized-hourly-comparison-selection-helpers.js +116 -0
- package/lib/helpers/materialized-reports/materialized-payments-comparison-accumulator-helpers.d.ts +25 -0
- package/lib/helpers/materialized-reports/materialized-payments-comparison-accumulator-helpers.js +98 -0
- package/lib/helpers/materialized-reports/materialized-payments-comparison-close-day-helpers.d.ts +79 -0
- package/lib/helpers/materialized-reports/materialized-payments-comparison-close-day-helpers.js +407 -0
- package/lib/helpers/materialized-reports/materialized-payments-comparison-compile-helpers.d.ts +35 -0
- package/lib/helpers/materialized-reports/materialized-payments-comparison-compile-helpers.js +173 -0
- package/lib/helpers/materialized-reports/materialized-prep-time-classification-helpers.d.ts +66 -0
- package/lib/helpers/materialized-reports/materialized-prep-time-classification-helpers.js +224 -0
- package/lib/helpers/materialized-reports/materialized-prep-time-close-day-helpers.d.ts +128 -0
- package/lib/helpers/materialized-reports/materialized-prep-time-close-day-helpers.js +490 -0
- package/lib/helpers/materialized-reports/materialized-prep-time-compile-helpers.d.ts +46 -0
- package/lib/helpers/materialized-reports/materialized-prep-time-compile-helpers.js +208 -0
- package/lib/helpers/materialized-reports/materialized-reports-selection-helpers.d.ts +8 -0
- package/lib/helpers/materialized-reports/materialized-reports-selection-helpers.js +8 -1
- package/lib/helpers/materialized-reports/materialized-sales-comparison-accumulator-helpers.d.ts +48 -0
- package/lib/helpers/materialized-reports/materialized-sales-comparison-accumulator-helpers.js +204 -0
- package/lib/helpers/materialized-reports/materialized-sales-comparison-baseline-helpers.d.ts +22 -0
- package/lib/helpers/materialized-reports/materialized-sales-comparison-baseline-helpers.js +161 -0
- package/lib/helpers/materialized-reports/materialized-sales-comparison-close-day-helpers.d.ts +163 -0
- package/lib/helpers/materialized-reports/materialized-sales-comparison-close-day-helpers.js +603 -0
- package/lib/helpers/materialized-reports/materialized-sales-comparison-compile-helpers.d.ts +68 -0
- package/lib/helpers/materialized-reports/materialized-sales-comparison-compile-helpers.js +182 -0
- package/lib/helpers/materialized-reports/tenant-cash-in-out-formatter.d.ts +98 -0
- package/lib/helpers/materialized-reports/tenant-cash-in-out-formatter.js +159 -0
- package/lib/helpers/materialized-reports/tenant-delivery-formatter.d.ts +133 -0
- package/lib/helpers/materialized-reports/tenant-delivery-formatter.js +233 -0
- package/lib/helpers/materialized-reports/tenant-discount-formatter.d.ts +114 -0
- package/lib/helpers/materialized-reports/tenant-discount-formatter.js +431 -0
- package/lib/helpers/materialized-reports/tenant-hourly-comparison-formatter.d.ts +60 -0
- package/lib/helpers/materialized-reports/tenant-hourly-comparison-formatter.js +243 -0
- package/lib/helpers/materialized-reports/tenant-payments-comparison-formatter.d.ts +75 -0
- package/lib/helpers/materialized-reports/tenant-payments-comparison-formatter.js +286 -0
- package/lib/helpers/materialized-reports/tenant-prep-time-formatter.d.ts +97 -0
- package/lib/helpers/materialized-reports/tenant-prep-time-formatter.js +232 -0
- package/lib/helpers/materialized-reports/tenant-sales-comparison-formatter.d.ts +105 -0
- package/lib/helpers/materialized-reports/tenant-sales-comparison-formatter.js +349 -0
- package/lib/helpers/reporting-contract/index.d.ts +2 -0
- package/lib/helpers/reporting-contract/index.js +18 -0
- package/lib/helpers/reporting-contract/overview-contract.d.ts +55 -0
- package/lib/helpers/reporting-contract/overview-contract.js +126 -0
- package/lib/helpers/reporting-contract/report-contract.d.ts +159 -0
- package/lib/helpers/reporting-contract/report-contract.js +239 -0
- package/lib/helpers/rider-earnings/index.d.ts +1 -0
- package/lib/helpers/rider-earnings/index.js +17 -0
- package/lib/helpers/rider-earnings/rider-earnings.d.ts +58 -0
- package/lib/helpers/rider-earnings/rider-earnings.js +64 -0
- package/lib/helpers/rider-reports/index.d.ts +2 -0
- package/lib/helpers/rider-reports/index.js +18 -0
- package/lib/helpers/rider-reports/rider-daily-report.d.ts +26 -0
- package/lib/helpers/rider-reports/rider-daily-report.js +93 -0
- package/lib/helpers/rider-reports/rider-report.d.ts +49 -0
- package/lib/helpers/rider-reports/rider-report.js +70 -0
- package/lib/helpers/types/materialized-reports-apis.d.ts +297 -1
- package/lib/schemas/models/deliveries.d.ts +54 -0
- package/lib/schemas/models/deliveries.js +75 -0
- package/lib/schemas/models/expense_details.d.ts +3 -3
- package/lib/schemas/models/index.d.ts +15 -0
- package/lib/schemas/models/index.js +15 -0
- package/lib/schemas/models/materialized_rider_daily_reports.d.ts +27 -0
- package/lib/schemas/models/materialized_rider_daily_reports.js +42 -0
- package/lib/schemas/models/materialized_tenant_cash_entries.d.ts +181 -0
- package/lib/schemas/models/materialized_tenant_cash_entries.js +98 -0
- package/lib/schemas/models/materialized_tenant_cash_reports.d.ts +111 -0
- package/lib/schemas/models/materialized_tenant_cash_reports.js +80 -0
- package/lib/schemas/models/materialized_tenant_delivery_entries.d.ts +98 -0
- package/lib/schemas/models/materialized_tenant_delivery_entries.js +66 -0
- package/lib/schemas/models/materialized_tenant_delivery_reports.d.ts +98 -0
- package/lib/schemas/models/materialized_tenant_delivery_reports.js +66 -0
- package/lib/schemas/models/materialized_tenant_discount_entries.d.ts +199 -0
- package/lib/schemas/models/materialized_tenant_discount_entries.js +159 -0
- package/lib/schemas/models/materialized_tenant_discount_reports.d.ts +216 -0
- package/lib/schemas/models/materialized_tenant_discount_reports.js +336 -0
- package/lib/schemas/models/materialized_tenant_hourly_comparison_entries.d.ts +95 -0
- package/lib/schemas/models/materialized_tenant_hourly_comparison_entries.js +82 -0
- package/lib/schemas/models/materialized_tenant_hourly_comparison_reports.d.ts +105 -0
- package/lib/schemas/models/materialized_tenant_hourly_comparison_reports.js +91 -0
- package/lib/schemas/models/materialized_tenant_payments_comparison_entries.d.ts +91 -0
- package/lib/schemas/models/materialized_tenant_payments_comparison_entries.js +70 -0
- package/lib/schemas/models/materialized_tenant_payments_comparison_reports.d.ts +98 -0
- package/lib/schemas/models/materialized_tenant_payments_comparison_reports.js +71 -0
- package/lib/schemas/models/materialized_tenant_prep_time_entries.d.ts +181 -0
- package/lib/schemas/models/materialized_tenant_prep_time_entries.js +133 -0
- package/lib/schemas/models/materialized_tenant_prep_time_reports.d.ts +118 -0
- package/lib/schemas/models/materialized_tenant_prep_time_reports.js +112 -0
- package/lib/schemas/models/materialized_tenant_sales_comparison_entries.d.ts +139 -0
- package/lib/schemas/models/materialized_tenant_sales_comparison_entries.js +120 -0
- package/lib/schemas/models/materialized_tenant_sales_comparison_reports.d.ts +167 -0
- package/lib/schemas/models/materialized_tenant_sales_comparison_reports.js +137 -0
- package/lib/schemas/models/tenant_purchase_order_vendor_returns.d.ts +3 -3
- package/lib/schemas/models/warehouse_internal_movements.d.ts +6 -6
- package/lib/schemas/models/warehouse_purchase_order_receipts.d.ts +3 -3
- package/lib/schemas/models/warehouse_purchase_order_vendor_returns.d.ts +3 -3
- package/lib/schemas/models/warehouse_sale_deliveries.d.ts +6 -6
- package/lib/schemas/models/warehouse_sale_invoices.d.ts +3 -3
- package/lib/schemas/types/deliveries.d.ts +40 -1
- package/lib/schemas/types/index.d.ts +15 -0
- package/lib/schemas/types/index.js +15 -0
- package/lib/schemas/types/materialized_rider_daily_reports.d.ts +37 -0
- package/lib/schemas/types/materialized_rider_daily_reports.js +2 -0
- package/lib/schemas/types/materialized_tenant_cash_entries.d.ts +87 -0
- package/lib/schemas/types/materialized_tenant_cash_entries.js +2 -0
- package/lib/schemas/types/materialized_tenant_cash_reports.d.ts +144 -0
- package/lib/schemas/types/materialized_tenant_cash_reports.js +2 -0
- package/lib/schemas/types/materialized_tenant_delivery_entries.d.ts +98 -0
- package/lib/schemas/types/materialized_tenant_delivery_entries.js +2 -0
- package/lib/schemas/types/materialized_tenant_delivery_reports.d.ts +179 -0
- package/lib/schemas/types/materialized_tenant_delivery_reports.js +2 -0
- package/lib/schemas/types/materialized_tenant_discount_entries.d.ts +81 -0
- package/lib/schemas/types/materialized_tenant_discount_entries.js +2 -0
- package/lib/schemas/types/materialized_tenant_discount_reports.d.ts +209 -0
- package/lib/schemas/types/materialized_tenant_discount_reports.js +3 -0
- package/lib/schemas/types/materialized_tenant_hourly_comparison_entries.d.ts +33 -0
- package/lib/schemas/types/materialized_tenant_hourly_comparison_entries.js +2 -0
- package/lib/schemas/types/materialized_tenant_hourly_comparison_reports.d.ts +40 -0
- package/lib/schemas/types/materialized_tenant_hourly_comparison_reports.js +2 -0
- package/lib/schemas/types/materialized_tenant_payments_comparison_entries.d.ts +48 -0
- package/lib/schemas/types/materialized_tenant_payments_comparison_entries.js +2 -0
- package/lib/schemas/types/materialized_tenant_payments_comparison_reports.d.ts +51 -0
- package/lib/schemas/types/materialized_tenant_payments_comparison_reports.js +14 -0
- package/lib/schemas/types/materialized_tenant_prep_time_entries.d.ts +88 -0
- package/lib/schemas/types/materialized_tenant_prep_time_entries.js +2 -0
- package/lib/schemas/types/materialized_tenant_prep_time_reports.d.ts +132 -0
- package/lib/schemas/types/materialized_tenant_prep_time_reports.js +2 -0
- package/lib/schemas/types/materialized_tenant_sales_comparison_entries.d.ts +43 -0
- package/lib/schemas/types/materialized_tenant_sales_comparison_entries.js +2 -0
- package/lib/schemas/types/materialized_tenant_sales_comparison_reports.d.ts +74 -0
- package/lib/schemas/types/materialized_tenant_sales_comparison_reports.js +17 -0
- package/lib/tests/materialized-reports/analytics-growth-helpers.test.d.ts +1 -0
- package/lib/tests/materialized-reports/analytics-overview-helpers.test.d.ts +1 -0
- package/lib/tests/materialized-reports/analytics-performance-helpers.test.d.ts +1 -0
- package/lib/tests/materialized-reports/fixtures.d.ts +15 -1
- package/lib/tests/materialized-reports/fixtures.js +1 -0
- package/lib/tests/materialized-reports/materialized-cash-compile.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-cash-compile.test.js +196 -0
- package/lib/tests/materialized-reports/materialized-cash-fold.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-cash-fold.test.js +116 -0
- package/lib/tests/materialized-reports/materialized-cash-formatter.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-cash-formatter.test.js +152 -0
- package/lib/tests/materialized-reports/materialized-cash-plan.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-cash-plan.test.js +168 -0
- package/lib/tests/materialized-reports/materialized-cash-reconciliation.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-cash-reconciliation.test.js +267 -0
- package/lib/tests/materialized-reports/materialized-delivery-accumulation.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-delivery-accumulation.test.js +147 -0
- package/lib/tests/materialized-reports/materialized-delivery-compile.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-delivery-compile.test.js +241 -0
- package/lib/tests/materialized-reports/materialized-delivery-fold.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-delivery-fold.test.js +109 -0
- package/lib/tests/materialized-reports/materialized-delivery-formatter.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-delivery-formatter.test.js +141 -0
- package/lib/tests/materialized-reports/materialized-delivery-plan.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-delivery-plan.test.js +198 -0
- package/lib/tests/materialized-reports/materialized-discount-aggregated-formatter.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-discount-aggregated-formatter.test.js +173 -0
- package/lib/tests/materialized-reports/materialized-discount-classification.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-discount-classification.test.js +339 -0
- package/lib/tests/materialized-reports/materialized-discount-close-day.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-discount-close-day.test.js +506 -0
- package/lib/tests/materialized-reports/materialized-discount-compile.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-discount-compile.test.js +161 -0
- package/lib/tests/materialized-reports/materialized-discount-counter-rows.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-discount-counter-rows.test.js +107 -0
- package/lib/tests/materialized-reports/materialized-discount-entries-accumulation.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-discount-entries-accumulation.test.js +125 -0
- package/lib/tests/materialized-reports/materialized-hourly-comparison-compile.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-hourly-comparison-compile.test.js +146 -0
- package/lib/tests/materialized-reports/materialized-hourly-comparison-formatter.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-hourly-comparison-formatter.test.js +127 -0
- package/lib/tests/materialized-reports/materialized-hourly-comparison-plan.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-hourly-comparison-plan.test.js +138 -0
- package/lib/tests/materialized-reports/materialized-hourly-comparison-selection.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-hourly-comparison-selection.test.js +90 -0
- package/lib/tests/materialized-reports/materialized-payments-comparison-compile.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-payments-comparison-compile.test.js +164 -0
- package/lib/tests/materialized-reports/materialized-payments-comparison-formatter.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-payments-comparison-formatter.test.js +117 -0
- package/lib/tests/materialized-reports/materialized-payments-comparison-plan.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-payments-comparison-plan.test.js +149 -0
- package/lib/tests/materialized-reports/materialized-prep-time-classification.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-prep-time-classification.test.js +273 -0
- package/lib/tests/materialized-reports/materialized-prep-time-close-day.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-prep-time-close-day.test.js +270 -0
- package/lib/tests/materialized-reports/materialized-prep-time-compile.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-prep-time-compile.test.js +217 -0
- package/lib/tests/materialized-reports/materialized-prep-time-constants.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-prep-time-constants.test.js +84 -0
- package/lib/tests/materialized-reports/materialized-prep-time-plan.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-prep-time-plan.test.js +176 -0
- package/lib/tests/materialized-reports/materialized-sales-comparison-baseline.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-sales-comparison-baseline.test.js +126 -0
- package/lib/tests/materialized-reports/materialized-sales-comparison-compile.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-sales-comparison-compile.test.js +206 -0
- package/lib/tests/materialized-reports/materialized-sales-comparison-formatter.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-sales-comparison-formatter.test.js +179 -0
- package/lib/tests/materialized-reports/materialized-sales-comparison-parity.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-sales-comparison-parity.test.js +196 -0
- package/lib/tests/materialized-reports/materialized-sales-comparison-plan.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-sales-comparison-plan.test.js +241 -0
- package/lib/tests/materialized-reports/materialized-tenant-hourly-comparison-schema.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-tenant-hourly-comparison-schema.test.js +96 -0
- package/lib/tests/materialized-reports/materialized-tenant-payments-comparison-schema.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-tenant-payments-comparison-schema.test.js +112 -0
- package/lib/tests/materialized-reports/materialized-tenant-sales-comparison-schema.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-tenant-sales-comparison-schema.test.js +142 -0
- package/lib/tests/materialized-reports/materialized-tenant-sales-overview-reports-schema.test.js +8 -1
- package/lib/tests/materialized-reports/sales-comparison-reference.d.ts +55 -0
- package/lib/tests/materialized-reports/sales-comparison-reference.js +86 -0
- package/lib/tests/materialized-reports/tenant-discount-formatter.test.d.ts +1 -0
- package/lib/tests/materialized-reports/tenant-discount-formatter.test.js +289 -0
- package/lib/tests/materialized-reports/tenant-prep-time-formatter.test.d.ts +1 -0
- package/lib/tests/materialized-reports/tenant-prep-time-formatter.test.js +354 -0
- package/lib/tests/reporting-contract.test.d.ts +1 -0
- package/lib/tests/reporting-contract.test.js +267 -0
- package/lib/tests/rider-daily-report.test.d.ts +1 -0
- package/lib/tests/rider-daily-report.test.js +86 -0
- package/lib/tests/rider-earnings.test.d.ts +1 -0
- package/lib/tests/rider-earnings.test.js +65 -0
- package/lib/tests/rider-report.test.d.ts +1 -0
- package/lib/tests/rider-report.test.js +98 -0
- package/package.json +10 -1
|
@@ -89,6 +89,20 @@ export var MATERIALIZED_REPORT_KEY_FILTER_ENUM;
|
|
|
89
89
|
(function (MATERIALIZED_REPORT_KEY_FILTER_ENUM) {
|
|
90
90
|
MATERIALIZED_REPORT_KEY_FILTER_ENUM["ORDER_STATUS"] = "ORDER_STATUS";
|
|
91
91
|
MATERIALIZED_REPORT_KEY_FILTER_ENUM["PLATFORM"] = "PLATFORM";
|
|
92
|
+
// Cash in/out (M3) has neither an order status nor a platform - its two
|
|
93
|
+
// operator questions are "which drawer" and "what kind of movement", so the
|
|
94
|
+
// cash report encodes <DRAWER_ID>:<REF_TYPE> instead. Adding members here is
|
|
95
|
+
// additive: the envelope merely declares which dimensions a key encodes.
|
|
96
|
+
MATERIALIZED_REPORT_KEY_FILTER_ENUM["DRAWER_ID"] = "DRAWER_ID";
|
|
97
|
+
MATERIALIZED_REPORT_KEY_FILTER_ENUM["REF_TYPE"] = "REF_TYPE";
|
|
98
|
+
// Delivery (M4) encodes <PLATFORM>:<CITY>, both joined from the ORDER - a delivery
|
|
99
|
+
// document carries neither, so the report joins by order_id and keys on the
|
|
100
|
+
// order's dimensions. CITY is a new dimension here.
|
|
101
|
+
MATERIALIZED_REPORT_KEY_FILTER_ENUM["CITY"] = "CITY";
|
|
102
|
+
// Payments Comparison encodes <PAYMENT_METHOD>:<ORDER_STATUS>. The method is an
|
|
103
|
+
// OPEN string (live stores carry values outside the enum) and is normalized only
|
|
104
|
+
// for the PAY_LATER -> UNPAID remap.
|
|
105
|
+
MATERIALIZED_REPORT_KEY_FILTER_ENUM["PAYMENT_METHOD"] = "PAYMENT_METHOD";
|
|
92
106
|
})(MATERIALIZED_REPORT_KEY_FILTER_ENUM || (MATERIALIZED_REPORT_KEY_FILTER_ENUM = {}));
|
|
93
107
|
export const ALL_MATERIALIZED_REPORT_KEY_FILTERS = Object.values(MATERIALIZED_REPORT_KEY_FILTER_ENUM);
|
|
94
108
|
/** Ordered key filters of the tenant sales overview report (`PLACED:POS_WALK-IN`). */
|
|
@@ -96,6 +110,112 @@ export const SALES_OVERVIEW_KEY_FILTERS = [
|
|
|
96
110
|
MATERIALIZED_REPORT_KEY_FILTER_ENUM.ORDER_STATUS,
|
|
97
111
|
MATERIALIZED_REPORT_KEY_FILTER_ENUM.PLATFORM,
|
|
98
112
|
];
|
|
113
|
+
/* ======================================================================== */
|
|
114
|
+
/* Discounts report (M1) */
|
|
115
|
+
/* ======================================================================== */
|
|
116
|
+
/**
|
|
117
|
+
* Scopes materialized by `materialized_tenant_discount_reports` — the same
|
|
118
|
+
* month-capped set as the credit ledger, for the same reason: the itemized
|
|
119
|
+
* discount rows live in the SIBLING entries collection
|
|
120
|
+
* (`materialized_tenant_discount_entries`), capped at `LOCAL_MONTH` so a
|
|
121
|
+
* document can never grow unboundedly.
|
|
122
|
+
*
|
|
123
|
+
* The report documents themselves are COUNTERS ONLY (see
|
|
124
|
+
* `schemas/types/materialized_tenant_discount_reports.ts`).
|
|
125
|
+
*/
|
|
126
|
+
export const MATERIALIZED_DISCOUNT_REPORT_SCOPES = [
|
|
127
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_HOUR,
|
|
128
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_DATE,
|
|
129
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_WEEK,
|
|
130
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_WEEK_OF_YEAR,
|
|
131
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_MONTH,
|
|
132
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_QUARTER,
|
|
133
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_SEMESTER,
|
|
134
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_YEAR,
|
|
135
|
+
];
|
|
136
|
+
/** Ordered key filters of the discounts report (`COMPLETED:POS_WALK-IN`). */
|
|
137
|
+
export const DISCOUNTS_KEY_FILTERS = [
|
|
138
|
+
MATERIALIZED_REPORT_KEY_FILTER_ENUM.ORDER_STATUS,
|
|
139
|
+
MATERIALIZED_REPORT_KEY_FILTER_ENUM.PLATFORM,
|
|
140
|
+
];
|
|
141
|
+
/**
|
|
142
|
+
* Discount SLOT of one row — mirrors the three slots of the order/item
|
|
143
|
+
* `IDiscountDetails` (`special_`, `loyalty_`, `voucher_`).
|
|
144
|
+
*/
|
|
145
|
+
export var MATERIALIZED_DISCOUNT_SLOT_ENUM;
|
|
146
|
+
(function (MATERIALIZED_DISCOUNT_SLOT_ENUM) {
|
|
147
|
+
MATERIALIZED_DISCOUNT_SLOT_ENUM["SPECIAL"] = "SPECIAL";
|
|
148
|
+
MATERIALIZED_DISCOUNT_SLOT_ENUM["LOYALTY"] = "LOYALTY";
|
|
149
|
+
MATERIALIZED_DISCOUNT_SLOT_ENUM["VOUCHER"] = "VOUCHER";
|
|
150
|
+
})(MATERIALIZED_DISCOUNT_SLOT_ENUM || (MATERIALIZED_DISCOUNT_SLOT_ENUM = {}));
|
|
151
|
+
export const ALL_MATERIALIZED_DISCOUNT_SLOTS = Object.values(MATERIALIZED_DISCOUNT_SLOT_ENUM);
|
|
152
|
+
/**
|
|
153
|
+
* Sub-kind of a discount row, derived from the slot's ID SHAPE (the only
|
|
154
|
+
* discriminator the write path stores — verified against live fixtures):
|
|
155
|
+
*
|
|
156
|
+
* - `COLLECTION` — `special_discount_id` is a 24-hex ObjectId (a
|
|
157
|
+
* `discounts` collection document).
|
|
158
|
+
* - `MANUAL` — id starts `MANUAL_` (quick % / custom amount /
|
|
159
|
+
* payment-type discounts). NOT `MANUAL_SINGLE_`.
|
|
160
|
+
* - `PRICE_OVERRIDE` — id starts `MANUAL_SINGLE_` (item price override).
|
|
161
|
+
* - `CATALOG_ITEM` — id is an item id or `SPECIAL_DISCOUNT` (a catalog
|
|
162
|
+
* item's own configured discount).
|
|
163
|
+
* - `OFFER` — loyalty/voucher slot whose id is an offer ObjectId.
|
|
164
|
+
* - `GIFT_CARD` — loyalty slot whose id is a gift-card ObjectId (the
|
|
165
|
+
* reference number carries the code).
|
|
166
|
+
* - `WALLET_CASHBACK` — the sentinel id `wallet_cashback_redemption`.
|
|
167
|
+
* - `UNATTRIBUTED` — no usable slot id, or order-level money the slots
|
|
168
|
+
* cannot explain (see the counter type).
|
|
169
|
+
*/
|
|
170
|
+
export var MATERIALIZED_DISCOUNT_SUB_KIND_ENUM;
|
|
171
|
+
(function (MATERIALIZED_DISCOUNT_SUB_KIND_ENUM) {
|
|
172
|
+
MATERIALIZED_DISCOUNT_SUB_KIND_ENUM["COLLECTION"] = "COLLECTION";
|
|
173
|
+
MATERIALIZED_DISCOUNT_SUB_KIND_ENUM["MANUAL"] = "MANUAL";
|
|
174
|
+
MATERIALIZED_DISCOUNT_SUB_KIND_ENUM["PRICE_OVERRIDE"] = "PRICE_OVERRIDE";
|
|
175
|
+
MATERIALIZED_DISCOUNT_SUB_KIND_ENUM["CATALOG_ITEM"] = "CATALOG_ITEM";
|
|
176
|
+
MATERIALIZED_DISCOUNT_SUB_KIND_ENUM["OFFER"] = "OFFER";
|
|
177
|
+
MATERIALIZED_DISCOUNT_SUB_KIND_ENUM["GIFT_CARD"] = "GIFT_CARD";
|
|
178
|
+
MATERIALIZED_DISCOUNT_SUB_KIND_ENUM["WALLET_CASHBACK"] = "WALLET_CASHBACK";
|
|
179
|
+
MATERIALIZED_DISCOUNT_SUB_KIND_ENUM["UNATTRIBUTED"] = "UNATTRIBUTED";
|
|
180
|
+
})(MATERIALIZED_DISCOUNT_SUB_KIND_ENUM || (MATERIALIZED_DISCOUNT_SUB_KIND_ENUM = {}));
|
|
181
|
+
export const ALL_MATERIALIZED_DISCOUNT_SUB_KINDS = Object.values(MATERIALIZED_DISCOUNT_SUB_KIND_ENUM);
|
|
182
|
+
/**
|
|
183
|
+
* Kind of one itemized discount row in
|
|
184
|
+
* `materialized_tenant_discount_entries`.
|
|
185
|
+
*
|
|
186
|
+
* - `DISCOUNT` — a slot on the order or on one item.
|
|
187
|
+
* - `FREE_ITEM` — a 100 % item row (also present as a `DISCOUNT` row; the
|
|
188
|
+
* drill-down decides which view lists it).
|
|
189
|
+
* - `COMPLIMENTARY` — a `COMPLIMENTARY` payment (no discount slot required).
|
|
190
|
+
*/
|
|
191
|
+
export var MATERIALIZED_DISCOUNT_ENTRY_KIND_ENUM;
|
|
192
|
+
(function (MATERIALIZED_DISCOUNT_ENTRY_KIND_ENUM) {
|
|
193
|
+
MATERIALIZED_DISCOUNT_ENTRY_KIND_ENUM["DISCOUNT"] = "DISCOUNT";
|
|
194
|
+
MATERIALIZED_DISCOUNT_ENTRY_KIND_ENUM["FREE_ITEM"] = "FREE_ITEM";
|
|
195
|
+
MATERIALIZED_DISCOUNT_ENTRY_KIND_ENUM["COMPLIMENTARY"] = "COMPLIMENTARY";
|
|
196
|
+
})(MATERIALIZED_DISCOUNT_ENTRY_KIND_ENUM || (MATERIALIZED_DISCOUNT_ENTRY_KIND_ENUM = {}));
|
|
197
|
+
export const ALL_MATERIALIZED_DISCOUNT_ENTRY_KINDS = Object.values(MATERIALIZED_DISCOUNT_ENTRY_KIND_ENUM);
|
|
198
|
+
/** Level a discount applies at — the order, one item, or a payment. */
|
|
199
|
+
export var MATERIALIZED_DISCOUNT_LEVEL_ENUM;
|
|
200
|
+
(function (MATERIALIZED_DISCOUNT_LEVEL_ENUM) {
|
|
201
|
+
MATERIALIZED_DISCOUNT_LEVEL_ENUM["ORDER"] = "ORDER";
|
|
202
|
+
MATERIALIZED_DISCOUNT_LEVEL_ENUM["ITEM"] = "ITEM";
|
|
203
|
+
MATERIALIZED_DISCOUNT_LEVEL_ENUM["PAYMENT"] = "PAYMENT";
|
|
204
|
+
})(MATERIALIZED_DISCOUNT_LEVEL_ENUM || (MATERIALIZED_DISCOUNT_LEVEL_ENUM = {}));
|
|
205
|
+
export const ALL_MATERIALIZED_DISCOUNT_LEVELS = Object.values(MATERIALIZED_DISCOUNT_LEVEL_ENUM);
|
|
206
|
+
/**
|
|
207
|
+
* Cap of a discount report document's `top_sources` leaderboard. Display-only:
|
|
208
|
+
* every number in that list is also derivable from `discount_counters`, so a
|
|
209
|
+
* truncated list can never change a total.
|
|
210
|
+
*/
|
|
211
|
+
export const MATERIALIZED_DISCOUNT_SOURCE_LIMIT = 12;
|
|
212
|
+
/**
|
|
213
|
+
* The gift-card / wallet sentinel ids the toolkit writes into discount slots.
|
|
214
|
+
* Kept here so the classifier and the writers cannot drift apart.
|
|
215
|
+
*/
|
|
216
|
+
export const MATERIALIZED_DISCOUNT_SPECIAL_DISCOUNT_ID = 'SPECIAL_DISCOUNT';
|
|
217
|
+
export const MATERIALIZED_DISCOUNT_MANUAL_PREFIX = 'MANUAL_';
|
|
218
|
+
export const MATERIALIZED_DISCOUNT_PRICE_OVERRIDE_PREFIX = 'MANUAL_SINGLE_';
|
|
99
219
|
/**
|
|
100
220
|
* Payment-type label used by the frontend report formatter for the derived
|
|
101
221
|
* credit-settlement line in a collection day's payments breakdown (a
|
|
@@ -122,6 +242,189 @@ export var MATERIALIZED_REPORT_CREDIT_BILL_EVENT_TYPE_ENUM;
|
|
|
122
242
|
MATERIALIZED_REPORT_CREDIT_BILL_EVENT_TYPE_ENUM["WRITE_OFF"] = "WRITE_OFF";
|
|
123
243
|
})(MATERIALIZED_REPORT_CREDIT_BILL_EVENT_TYPE_ENUM || (MATERIALIZED_REPORT_CREDIT_BILL_EVENT_TYPE_ENUM = {}));
|
|
124
244
|
export const ALL_MATERIALIZED_REPORT_CREDIT_BILL_EVENT_TYPES = Object.values(MATERIALIZED_REPORT_CREDIT_BILL_EVENT_TYPE_ENUM);
|
|
245
|
+
/* ======================================================================== */
|
|
246
|
+
/* Cash in/out report (M3) */
|
|
247
|
+
/* ======================================================================== */
|
|
248
|
+
/**
|
|
249
|
+
* Scopes materialized by `materialized_tenant_cash_in_out_reports`.
|
|
250
|
+
*
|
|
251
|
+
* NO `localHour`: cash is a close-of-shift concern, the same reasoning that keeps
|
|
252
|
+
* the hour scope out of the prep time report. Day + periods, capped at
|
|
253
|
+
* `LOCAL_MONTH` because the statement rows live in the SIBLING entries collection
|
|
254
|
+
* (`materialized_tenant_cash_in_out_entries`).
|
|
255
|
+
*/
|
|
256
|
+
export const MATERIALIZED_CASH_REPORT_SCOPES = [
|
|
257
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_DATE,
|
|
258
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_WEEK,
|
|
259
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_WEEK_OF_YEAR,
|
|
260
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_MONTH,
|
|
261
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_QUARTER,
|
|
262
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_SEMESTER,
|
|
263
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_YEAR,
|
|
264
|
+
];
|
|
265
|
+
/**
|
|
266
|
+
* Ordered key filters of the cash report - `<DRAWER_ID>:<REF_TYPE>` (decision
|
|
267
|
+
* (b3)). Shift ids are deliberately NOT a key dimension: they are
|
|
268
|
+
* high-cardinality and belong in a breakdown table, not in the key.
|
|
269
|
+
*/
|
|
270
|
+
export const CASH_KEY_FILTERS = [
|
|
271
|
+
MATERIALIZED_REPORT_KEY_FILTER_ENUM.DRAWER_ID,
|
|
272
|
+
MATERIALIZED_REPORT_KEY_FILTER_ENUM.REF_TYPE,
|
|
273
|
+
];
|
|
274
|
+
/** Cap of the per-document drawer leaderboard (bounded, display-only). */
|
|
275
|
+
export const MATERIALIZED_CASH_SOURCE_LIMIT = 12;
|
|
276
|
+
/* ======================================================================== */
|
|
277
|
+
/* Delivery report (M4) */
|
|
278
|
+
/* ======================================================================== */
|
|
279
|
+
/**
|
|
280
|
+
* Scopes materialized by `materialized_tenant_delivery_reports`.
|
|
281
|
+
*
|
|
282
|
+
* NO `localHour`: the hour dimension appears as an AREA HEAT MAP inside the document
|
|
283
|
+
* (`areas[city].by_hour`), which is the shape the page actually renders. Materializing
|
|
284
|
+
* a full hour scope as well would multiply documents for a view nobody opens.
|
|
285
|
+
*/
|
|
286
|
+
export const MATERIALIZED_DELIVERY_REPORT_SCOPES = [
|
|
287
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_DATE,
|
|
288
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_WEEK,
|
|
289
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_WEEK_OF_YEAR,
|
|
290
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_MONTH,
|
|
291
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_QUARTER,
|
|
292
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_SEMESTER,
|
|
293
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_YEAR,
|
|
294
|
+
];
|
|
295
|
+
/**
|
|
296
|
+
* Ordered key filters of the delivery report - `<PLATFORM>:<CITY>` (decision (b4)).
|
|
297
|
+
*
|
|
298
|
+
* Rider is deliberately NOT a key dimension: rider ids are high-cardinality, so rider
|
|
299
|
+
* analysis is a bounded `riders` map INSIDE each document rather than a partition of
|
|
300
|
+
* the key space.
|
|
301
|
+
*/
|
|
302
|
+
export const DELIVERY_KEY_FILTERS = [
|
|
303
|
+
MATERIALIZED_REPORT_KEY_FILTER_ENUM.PLATFORM,
|
|
304
|
+
MATERIALIZED_REPORT_KEY_FILTER_ENUM.CITY,
|
|
305
|
+
];
|
|
306
|
+
/**
|
|
307
|
+
* Distance histogram of the delivery report, in METRES: inclusive lower, EXCLUSIVE
|
|
308
|
+
* upper, with an open-ended top bucket.
|
|
309
|
+
*
|
|
310
|
+
* Fixed buckets rather than a raw array, for the same reason as the prep time report: a
|
|
311
|
+
* bounded shape keeps a document small and makes a period fold exact.
|
|
312
|
+
*/
|
|
313
|
+
export const MATERIALIZED_DELIVERY_DISTANCE_BUCKETS = [
|
|
314
|
+
{ key: 'under_2km', min: 0, max: 2000 },
|
|
315
|
+
{ key: 'between_2_5km', min: 2000, max: 5000 },
|
|
316
|
+
{ key: 'between_5_10km', min: 5000, max: 10000 },
|
|
317
|
+
{ key: 'between_10_15km', min: 10000, max: 15000 },
|
|
318
|
+
{ key: 'between_15_25km', min: 15000, max: 25000 },
|
|
319
|
+
{ key: 'over_25km', min: 25000, max: null },
|
|
320
|
+
];
|
|
321
|
+
/** Cap of the per-document rider leaderboard (bounded, display-only). */
|
|
322
|
+
export const MATERIALIZED_DELIVERY_RIDER_LIMIT = 50;
|
|
323
|
+
/** Cap of the per-document area leaderboard (bounded, display-only). */
|
|
324
|
+
export const MATERIALIZED_DELIVERY_AREA_LIMIT = 50;
|
|
325
|
+
/* ======================================================================== */
|
|
326
|
+
/* Prep time report (M2) */
|
|
327
|
+
/* ======================================================================== */
|
|
328
|
+
/**
|
|
329
|
+
* Scopes materialized by `materialized_tenant_prep_time_reports`.
|
|
330
|
+
*
|
|
331
|
+
* NO `localHour` (decision h2): the tracked population per hour is 2-3 items in
|
|
332
|
+
* the dev stores, so an hourly prep time would be noise. Day + periods only,
|
|
333
|
+
* capped at `LOCAL_MONTH` because the itemized rows live in the SIBLING entries
|
|
334
|
+
* collection (`materialized_tenant_prep_time_entries`).
|
|
335
|
+
*/
|
|
336
|
+
export const MATERIALIZED_PREP_TIME_REPORT_SCOPES = [
|
|
337
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_DATE,
|
|
338
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_WEEK,
|
|
339
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_WEEK_OF_YEAR,
|
|
340
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_MONTH,
|
|
341
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_QUARTER,
|
|
342
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_SEMESTER,
|
|
343
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_YEAR,
|
|
344
|
+
];
|
|
345
|
+
/** Ordered key filters of the prep time report (`COMPLETED:POS_WALK-IN`). */
|
|
346
|
+
export const PREP_TIME_KEY_FILTERS = [
|
|
347
|
+
MATERIALIZED_REPORT_KEY_FILTER_ENUM.ORDER_STATUS,
|
|
348
|
+
MATERIALIZED_REPORT_KEY_FILTER_ENUM.PLATFORM,
|
|
349
|
+
];
|
|
350
|
+
/**
|
|
351
|
+
* ANCHOR PROVENANCE of one tracked item - the split that makes this report
|
|
352
|
+
* correct (decision b2, section 3.2.1 of the concept doc).
|
|
353
|
+
*
|
|
354
|
+
* `ready_minutes` is written from the chain
|
|
355
|
+
* `prep_started_at ?? order_status_updated_at ?? createdAt`, and the two
|
|
356
|
+
* populations behave completely differently:
|
|
357
|
+
*
|
|
358
|
+
* - MEASURED - `prep_started_at` AND `ready_minutes` both present. The item owns
|
|
359
|
+
* its prep clock, so the ready instant is reconstructible
|
|
360
|
+
* (`prep_started_at + ready_minutes`). Two independent stores AGREE here
|
|
361
|
+
* (avg ~9.3 min, median 5-8, p90 23, ~30% instant).
|
|
362
|
+
* - UNMEASURED - everything else, including `ready_minutes` with NO
|
|
363
|
+
* `prep_started_at`: the anchor fell back to the order stage and the value is
|
|
364
|
+
* degenerate (bruzo: avg 0.0, 99.8% zeros). Counted in COVERAGE only.
|
|
365
|
+
*
|
|
366
|
+
* Blending them under-reports the average by ~13x in the store with the MOST
|
|
367
|
+
* data (0.7 vs 9.2 min) - the single mistake this design exists to prevent.
|
|
368
|
+
*/
|
|
369
|
+
export var MATERIALIZED_PREP_TIME_ANCHOR_ENUM;
|
|
370
|
+
(function (MATERIALIZED_PREP_TIME_ANCHOR_ENUM) {
|
|
371
|
+
MATERIALIZED_PREP_TIME_ANCHOR_ENUM["MEASURED"] = "MEASURED";
|
|
372
|
+
MATERIALIZED_PREP_TIME_ANCHOR_ENUM["UNMEASURED"] = "UNMEASURED";
|
|
373
|
+
})(MATERIALIZED_PREP_TIME_ANCHOR_ENUM || (MATERIALIZED_PREP_TIME_ANCHOR_ENUM = {}));
|
|
374
|
+
export const ALL_MATERIALIZED_PREP_TIME_ANCHORS = Object.values(MATERIALIZED_PREP_TIME_ANCHOR_ENUM);
|
|
375
|
+
/**
|
|
376
|
+
* Fixed duration histogram of the MEASURED bucket, in minutes.
|
|
377
|
+
*
|
|
378
|
+
* A fixed histogram (decision d2) keeps documents small and is exactly what the
|
|
379
|
+
* UI renders; `median` / `p90` are derived from it and are therefore
|
|
380
|
+
* BUCKET-APPROXIMATE (the exact `avg` comes from `sum / count`). Storing every
|
|
381
|
+
* duration to get exact percentiles is the expensive option this avoids.
|
|
382
|
+
*/
|
|
383
|
+
export const MATERIALIZED_PREP_TIME_BUCKETS = [
|
|
384
|
+
{ label: '0', min: 0, max: 0 },
|
|
385
|
+
{ label: '1-5', min: 1, max: 5 },
|
|
386
|
+
{ label: '6-10', min: 6, max: 10 },
|
|
387
|
+
{ label: '11-15', min: 11, max: 15 },
|
|
388
|
+
{ label: '16-30', min: 16, max: 30 },
|
|
389
|
+
{ label: '31-60', min: 31, max: 60 },
|
|
390
|
+
{ label: '60+', min: 61, max: null },
|
|
391
|
+
];
|
|
392
|
+
export const ALL_MATERIALIZED_PREP_TIME_BUCKET_LABELS = MATERIALIZED_PREP_TIME_BUCKETS.map((bucket) => bucket.label);
|
|
393
|
+
/**
|
|
394
|
+
* Longest prep duration (minutes) trusted as a real prep time. A stored
|
|
395
|
+
* `ready_minutes` beyond this is a clock/backfill artefact rather than a prep
|
|
396
|
+
* time, so it still lands in the top bucket (the counts stay honest) but is kept
|
|
397
|
+
* out of `sum` / `min` / `max` - the same defensive posture the other reports
|
|
398
|
+
* take with outlier inputs.
|
|
399
|
+
*/
|
|
400
|
+
export const MATERIALIZED_PREP_TIME_MAX_MINUTES = 60 * 24;
|
|
401
|
+
/** Label of the top histogram bucket (everything at or above its `min`). */
|
|
402
|
+
export const MATERIALIZED_PREP_TIME_TOP_BUCKET = '60+';
|
|
403
|
+
/**
|
|
404
|
+
* On-time tolerance (decision f2): ready instant <= target counts as ON TIME
|
|
405
|
+
* (`delta <= 0`) for v1. The signed `delta_sum` is kept so a grace window can be
|
|
406
|
+
* applied later WITHOUT re-materializing.
|
|
407
|
+
*/
|
|
408
|
+
export const MATERIALIZED_PREP_TIME_ON_TIME_MAX_DELTA = 0;
|
|
409
|
+
/**
|
|
410
|
+
* WHERE an item's on-time target came from (decision e2).
|
|
411
|
+
*
|
|
412
|
+
* Promise-only grading would leave 63-97% of items ungraded (measured: only
|
|
413
|
+
* 2.7% / 36.2% of orders carry an explicit estimate), so an item with no promise
|
|
414
|
+
* is graded against the TENANT DEFAULT - the documented
|
|
415
|
+
* `getDeliveryExpectedTime` fallback chain. The baseline is labelled per row so
|
|
416
|
+
* a reader can always tell the two apart.
|
|
417
|
+
*/
|
|
418
|
+
export var MATERIALIZED_PREP_TIME_TARGET_ENUM;
|
|
419
|
+
(function (MATERIALIZED_PREP_TIME_TARGET_ENUM) {
|
|
420
|
+
/** The order carried an explicit estimate. */
|
|
421
|
+
MATERIALIZED_PREP_TIME_TARGET_ENUM["PROMISE"] = "PROMISE";
|
|
422
|
+
/** The order was ASAP and is graded against the tenant default. */
|
|
423
|
+
MATERIALIZED_PREP_TIME_TARGET_ENUM["TENANT_DEFAULT"] = "TENANT_DEFAULT";
|
|
424
|
+
/** Neither exists - the row cannot be graded. */
|
|
425
|
+
MATERIALIZED_PREP_TIME_TARGET_ENUM["NONE"] = "NONE";
|
|
426
|
+
})(MATERIALIZED_PREP_TIME_TARGET_ENUM || (MATERIALIZED_PREP_TIME_TARGET_ENUM = {}));
|
|
427
|
+
export const ALL_MATERIALIZED_PREP_TIME_TARGETS = Object.values(MATERIALIZED_PREP_TIME_TARGET_ENUM);
|
|
125
428
|
/**
|
|
126
429
|
* Materialized report kinds — the discriminator stored on
|
|
127
430
|
* `materialized_tenant_reports_iterations` rows. A single shared history collection records
|
|
@@ -134,5 +437,150 @@ export var MATERIALIZED_REPORT_TYPE_ENUM;
|
|
|
134
437
|
(function (MATERIALIZED_REPORT_TYPE_ENUM) {
|
|
135
438
|
MATERIALIZED_REPORT_TYPE_ENUM["TENANT_SALES_OVERVIEW"] = "TENANT_SALES_OVERVIEW";
|
|
136
439
|
MATERIALIZED_REPORT_TYPE_ENUM["TENANT_CREDIT_BILLS"] = "TENANT_CREDIT_BILLS";
|
|
440
|
+
MATERIALIZED_REPORT_TYPE_ENUM["TENANT_DISCOUNT_REPORTS"] = "TENANT_DISCOUNT_REPORTS";
|
|
441
|
+
MATERIALIZED_REPORT_TYPE_ENUM["TENANT_DISCOUNT_ENTRIES"] = "TENANT_DISCOUNT_ENTRIES";
|
|
442
|
+
MATERIALIZED_REPORT_TYPE_ENUM["TENANT_PREP_TIME_REPORTS"] = "TENANT_PREP_TIME_REPORTS";
|
|
443
|
+
MATERIALIZED_REPORT_TYPE_ENUM["TENANT_PREP_TIME_ENTRIES"] = "TENANT_PREP_TIME_ENTRIES";
|
|
444
|
+
MATERIALIZED_REPORT_TYPE_ENUM["TENANT_CASH_REPORTS"] = "TENANT_CASH_REPORTS";
|
|
445
|
+
MATERIALIZED_REPORT_TYPE_ENUM["TENANT_CASH_ENTRIES"] = "TENANT_CASH_ENTRIES";
|
|
446
|
+
MATERIALIZED_REPORT_TYPE_ENUM["TENANT_DELIVERY_REPORTS"] = "TENANT_DELIVERY_REPORTS";
|
|
447
|
+
MATERIALIZED_REPORT_TYPE_ENUM["TENANT_DELIVERY_ENTRIES"] = "TENANT_DELIVERY_ENTRIES";
|
|
448
|
+
MATERIALIZED_REPORT_TYPE_ENUM["TENANT_SALES_COMPARISON_REPORTS"] = "TENANT_SALES_COMPARISON_REPORTS";
|
|
449
|
+
MATERIALIZED_REPORT_TYPE_ENUM["TENANT_SALES_COMPARISON_ENTRIES"] = "TENANT_SALES_COMPARISON_ENTRIES";
|
|
450
|
+
MATERIALIZED_REPORT_TYPE_ENUM["TENANT_HOURLY_COMPARISON_REPORTS"] = "TENANT_HOURLY_COMPARISON_REPORTS";
|
|
451
|
+
MATERIALIZED_REPORT_TYPE_ENUM["TENANT_HOURLY_COMPARISON_ENTRIES"] = "TENANT_HOURLY_COMPARISON_ENTRIES";
|
|
452
|
+
MATERIALIZED_REPORT_TYPE_ENUM["TENANT_PAYMENTS_COMPARISON_REPORTS"] = "TENANT_PAYMENTS_COMPARISON_REPORTS";
|
|
453
|
+
MATERIALIZED_REPORT_TYPE_ENUM["TENANT_PAYMENTS_COMPARISON_ENTRIES"] = "TENANT_PAYMENTS_COMPARISON_ENTRIES";
|
|
137
454
|
})(MATERIALIZED_REPORT_TYPE_ENUM || (MATERIALIZED_REPORT_TYPE_ENUM = {}));
|
|
138
455
|
export const ALL_MATERIALIZED_REPORT_TYPES = Object.values(MATERIALIZED_REPORT_TYPE_ENUM);
|
|
456
|
+
/* =====================> Sales Comparison report <===================== */
|
|
457
|
+
/**
|
|
458
|
+
* Sales Comparison (see console/admin-panel/docs/report-sales-comparison-concept.md).
|
|
459
|
+
*
|
|
460
|
+
* A REPORT, not Analytics: it lives under Reports - New -> Comparisons and its numbers are
|
|
461
|
+
* decimal-exact. The comparison itself is never stored - `current` and `comparison` are two
|
|
462
|
+
* ordinary reads, subtracted in the formatter.
|
|
463
|
+
*
|
|
464
|
+
* Fixes no time bias: a complete business day (localDate) is the anchor, because the day
|
|
465
|
+
* close defines it. A range-based bias is meaningless once the business day exists.
|
|
466
|
+
*/
|
|
467
|
+
export const MATERIALIZED_TENANT_SALES_COMPARISON_REPORTS_COLLECTION_NAME = 'materialized_tenant_sales_comparison_reports';
|
|
468
|
+
export const MATERIALIZED_TENANT_SALES_COMPARISON_ENTRIES_COLLECTION_NAME = 'materialized_tenant_sales_comparison_entries';
|
|
469
|
+
/** Six grains. NO ISO week (owner decision) and NO hour - this is not the hourly report. */
|
|
470
|
+
export const MATERIALIZED_SALES_COMPARISON_REPORT_SCOPES = [
|
|
471
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_DATE,
|
|
472
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_WEEK,
|
|
473
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_MONTH,
|
|
474
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_QUARTER,
|
|
475
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_SEMESTER,
|
|
476
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_YEAR,
|
|
477
|
+
];
|
|
478
|
+
/** Key grammar: `COMPLETED:POS_DINE-IN`. No sale-type dimension (owner decision). */
|
|
479
|
+
export const SALES_COMPARISON_KEY_FILTERS = [
|
|
480
|
+
MATERIALIZED_REPORT_KEY_FILTER_ENUM.ORDER_STATUS,
|
|
481
|
+
MATERIALIZED_REPORT_KEY_FILTER_ENUM.PLATFORM,
|
|
482
|
+
];
|
|
483
|
+
export const MATERIALIZED_TENANT_SALES_COMPARISON_REPORTS_SCHEMA_VERSION = 1;
|
|
484
|
+
export const MATERIALIZED_TENANT_SALES_COMPARISON_ENTRIES_SCHEMA_VERSION = 1;
|
|
485
|
+
/**
|
|
486
|
+
* The baseline a Sales Comparison read is compared against (owner decision:
|
|
487
|
+
* Toast/Square behaviour). The user picks ONE range; the comparison range is
|
|
488
|
+
* DERIVED server-side:
|
|
489
|
+
* - `NONE` — no comparison series;
|
|
490
|
+
* - `PREVIOUS_PERIOD` — an EQUAL-LENGTH range immediately preceding the primary
|
|
491
|
+
* range (never "the previous calendar month" — that is the classic
|
|
492
|
+
* off-by-one-day bug);
|
|
493
|
+
* - `PREVIOUS_YEAR` — the primary range shifted back 12 months, same length.
|
|
494
|
+
*/
|
|
495
|
+
export var SALES_COMPARISON_BASELINE_ENUM;
|
|
496
|
+
(function (SALES_COMPARISON_BASELINE_ENUM) {
|
|
497
|
+
SALES_COMPARISON_BASELINE_ENUM["NONE"] = "NONE";
|
|
498
|
+
SALES_COMPARISON_BASELINE_ENUM["PREVIOUS_PERIOD"] = "PREVIOUS_PERIOD";
|
|
499
|
+
SALES_COMPARISON_BASELINE_ENUM["PREVIOUS_YEAR"] = "PREVIOUS_YEAR";
|
|
500
|
+
})(SALES_COMPARISON_BASELINE_ENUM || (SALES_COMPARISON_BASELINE_ENUM = {}));
|
|
501
|
+
export const ALL_SALES_COMPARISON_BASELINES = Object.values(SALES_COMPARISON_BASELINE_ENUM);
|
|
502
|
+
/**
|
|
503
|
+
* The metric the page charts / headlines (concept §9, `Select Field`).
|
|
504
|
+
*
|
|
505
|
+
* CLIENT-SIDE ONLY: the document already carries every additive counter, so
|
|
506
|
+
* changing this selection must NOT refetch. `AVERAGE_TICKET` is DERIVED
|
|
507
|
+
* (`net_amount / order_count`) and is never stored.
|
|
508
|
+
*/
|
|
509
|
+
export var SALES_COMPARISON_METRIC_ENUM;
|
|
510
|
+
(function (SALES_COMPARISON_METRIC_ENUM) {
|
|
511
|
+
SALES_COMPARISON_METRIC_ENUM["NET_SALES"] = "NET_SALES";
|
|
512
|
+
SALES_COMPARISON_METRIC_ENUM["GROSS_SALES"] = "GROSS_SALES";
|
|
513
|
+
SALES_COMPARISON_METRIC_ENUM["DISCOUNTS"] = "DISCOUNTS";
|
|
514
|
+
SALES_COMPARISON_METRIC_ENUM["ORDER_COUNT"] = "ORDER_COUNT";
|
|
515
|
+
SALES_COMPARISON_METRIC_ENUM["AVERAGE_TICKET"] = "AVERAGE_TICKET";
|
|
516
|
+
SALES_COMPARISON_METRIC_ENUM["ITEMS_SOLD"] = "ITEMS_SOLD";
|
|
517
|
+
})(SALES_COMPARISON_METRIC_ENUM || (SALES_COMPARISON_METRIC_ENUM = {}));
|
|
518
|
+
export const ALL_SALES_COMPARISON_METRICS = Object.values(SALES_COMPARISON_METRIC_ENUM);
|
|
519
|
+
/* =====================> Hourly Comparison report <===================== */
|
|
520
|
+
/**
|
|
521
|
+
* Hourly Comparison (see console/admin-panel/docs/report-hourly-comparison-concept.md).
|
|
522
|
+
*
|
|
523
|
+
* ONE hourly PROFILE compared against the same profile in a derived baseline range
|
|
524
|
+
* (decision A: one profile pair, not a per-day matrix). The comparison is never stored -
|
|
525
|
+
* `current` and `comparison` are two ordinary reads of HOUR documents, aligned and
|
|
526
|
+
* subtracted in the formatter.
|
|
527
|
+
*
|
|
528
|
+
* Anchor: `order_settled_at` -> the tenant-local settled day AND hour. No time bias.
|
|
529
|
+
*
|
|
530
|
+
* No period documents are written: the profile read only needs hour buckets. The period
|
|
531
|
+
* comparison report already owns the day/period materialization.
|
|
532
|
+
*/
|
|
533
|
+
export const MATERIALIZED_TENANT_HOURLY_COMPARISON_REPORTS_COLLECTION_NAME = 'materialized_tenant_hourly_comparison_reports';
|
|
534
|
+
export const MATERIALIZED_TENANT_HOURLY_COMPARISON_ENTRIES_COLLECTION_NAME = 'materialized_tenant_hourly_comparison_entries';
|
|
535
|
+
/** Hour documents only. This is an HOURLY report; no day or period documents. */
|
|
536
|
+
export const MATERIALIZED_HOURLY_COMPARISON_REPORT_SCOPES = [
|
|
537
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_HOUR,
|
|
538
|
+
];
|
|
539
|
+
/** The same key grammar as Sales Comparison: `COMPLETED:POS_DINE-IN`. */
|
|
540
|
+
export const HOURLY_COMPARISON_KEY_FILTERS = [
|
|
541
|
+
MATERIALIZED_REPORT_KEY_FILTER_ENUM.ORDER_STATUS,
|
|
542
|
+
MATERIALIZED_REPORT_KEY_FILTER_ENUM.PLATFORM,
|
|
543
|
+
];
|
|
544
|
+
export const MATERIALIZED_TENANT_HOURLY_COMPARISON_REPORTS_SCHEMA_VERSION = 1;
|
|
545
|
+
export const MATERIALIZED_TENANT_HOURLY_COMPARISON_ENTRIES_SCHEMA_VERSION = 1;
|
|
546
|
+
/* =====================> Payments Comparison report <===================== */
|
|
547
|
+
/**
|
|
548
|
+
* Payments Comparison (see console/admin-panel/docs/report-payments-comparison-concept.md).
|
|
549
|
+
*
|
|
550
|
+
* Payment ROWS, not orders: a split order contributes one row per payment, so this
|
|
551
|
+
* report can never be merged with Sales Comparison (which sums orders). The key is
|
|
552
|
+
* `<PAYMENT_METHOD>:<ORDER_STATUS>` (decision B); the method is the normalized,
|
|
553
|
+
* OPEN-string payment type.
|
|
554
|
+
*/
|
|
555
|
+
export const MATERIALIZED_TENANT_PAYMENTS_COMPARISON_REPORTS_COLLECTION_NAME = 'materialized_tenant_payments_comparison_reports';
|
|
556
|
+
export const MATERIALIZED_TENANT_PAYMENTS_COMPARISON_ENTRIES_COLLECTION_NAME = 'materialized_tenant_payments_comparison_entries';
|
|
557
|
+
/** The same six comparison grains; no hour / ISO week. */
|
|
558
|
+
export const MATERIALIZED_PAYMENTS_COMPARISON_REPORT_SCOPES = [
|
|
559
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_DATE,
|
|
560
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_WEEK,
|
|
561
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_MONTH,
|
|
562
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_QUARTER,
|
|
563
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_SEMESTER,
|
|
564
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_YEAR,
|
|
565
|
+
];
|
|
566
|
+
/** Ordered key filters: `<PAYMENT_METHOD>:<ORDER_STATUS>`. */
|
|
567
|
+
export const PAYMENTS_COMPARISON_KEY_FILTERS = [
|
|
568
|
+
MATERIALIZED_REPORT_KEY_FILTER_ENUM.PAYMENT_METHOD,
|
|
569
|
+
MATERIALIZED_REPORT_KEY_FILTER_ENUM.ORDER_STATUS,
|
|
570
|
+
];
|
|
571
|
+
export const MATERIALIZED_TENANT_PAYMENTS_COMPARISON_REPORTS_SCHEMA_VERSION = 1;
|
|
572
|
+
export const MATERIALIZED_TENANT_PAYMENTS_COMPARISON_ENTRIES_SCHEMA_VERSION = 1;
|
|
573
|
+
/**
|
|
574
|
+
* The metric the Payments Comparison page charts (client-side).
|
|
575
|
+
* `AVERAGE_PAYMENT` is derived (`payment_amount / payment_count`), never stored.
|
|
576
|
+
*/
|
|
577
|
+
export var PAYMENTS_COMPARISON_METRIC_ENUM;
|
|
578
|
+
(function (PAYMENTS_COMPARISON_METRIC_ENUM) {
|
|
579
|
+
PAYMENTS_COMPARISON_METRIC_ENUM["PAYMENT_AMOUNT"] = "PAYMENT_AMOUNT";
|
|
580
|
+
PAYMENTS_COMPARISON_METRIC_ENUM["PAYMENT_COUNT"] = "PAYMENT_COUNT";
|
|
581
|
+
PAYMENTS_COMPARISON_METRIC_ENUM["AVERAGE_PAYMENT"] = "AVERAGE_PAYMENT";
|
|
582
|
+
PAYMENTS_COMPARISON_METRIC_ENUM["CARD_CHARGES"] = "CARD_CHARGES";
|
|
583
|
+
PAYMENTS_COMPARISON_METRIC_ENUM["REFUNDED_AMOUNT"] = "REFUNDED_AMOUNT";
|
|
584
|
+
PAYMENTS_COMPARISON_METRIC_ENUM["AMOUNT_DUE"] = "AMOUNT_DUE";
|
|
585
|
+
})(PAYMENTS_COMPARISON_METRIC_ENUM || (PAYMENTS_COMPARISON_METRIC_ENUM = {}));
|
|
586
|
+
export const ALL_PAYMENTS_COMPARISON_METRICS = Object.values(PAYMENTS_COMPARISON_METRIC_ENUM);
|
|
@@ -290,6 +290,7 @@ export const BLACKLISTED_SMS_COUNTRY_CODES = [
|
|
|
290
290
|
'+263', // Zimbabwe
|
|
291
291
|
];
|
|
292
292
|
export const WHITELISTED_API_SMS_COUNTRY_CODES = ['+92']; // Pakistan
|
|
293
|
+
export const BLACKLISTED_WHATSAPP_COUNTRY_CODES = ['+92']; // Pakistan
|
|
293
294
|
// ======================>> <<====================== //
|
|
294
295
|
export var ALERT_NOTIFICATIONS_TYPE_ENUM;
|
|
295
296
|
(function (ALERT_NOTIFICATIONS_TYPE_ENUM) {
|
package/esm/helpers/index.js
CHANGED
|
@@ -2,6 +2,9 @@ export * from './fbr';
|
|
|
2
2
|
export * from './hubrise';
|
|
3
3
|
export * from './kpra';
|
|
4
4
|
export * from './materialized-reports';
|
|
5
|
+
export * from './reporting-contract';
|
|
6
|
+
export * from './rider-earnings';
|
|
7
|
+
export * from './rider-reports';
|
|
5
8
|
export * from './order';
|
|
6
9
|
export * from './pra';
|
|
7
10
|
export * from './srb';
|
|
@@ -1,10 +1,42 @@
|
|
|
1
1
|
export * from './key-helpers';
|
|
2
2
|
export * from './materialized-credit-bills-helpers';
|
|
3
|
+
export * from './materialized-discount-accumulator-helpers';
|
|
4
|
+
export * from './materialized-discount-classification-helpers';
|
|
5
|
+
export * from './materialized-discount-close-day-helpers';
|
|
6
|
+
export * from './materialized-discount-compile-helpers';
|
|
7
|
+
export * from './materialized-hourly-comparison-close-day-helpers';
|
|
8
|
+
export * from './materialized-hourly-comparison-compile-helpers';
|
|
9
|
+
export * from './materialized-hourly-comparison-selection-helpers';
|
|
10
|
+
export * from './materialized-payments-comparison-accumulator-helpers';
|
|
11
|
+
export * from './materialized-payments-comparison-close-day-helpers';
|
|
12
|
+
export * from './materialized-payments-comparison-compile-helpers';
|
|
13
|
+
export * from './materialized-cash-accumulator-helpers';
|
|
14
|
+
export * from './materialized-delivery-accumulator-helpers';
|
|
15
|
+
export * from './materialized-delivery-compile-helpers';
|
|
16
|
+
export * from './materialized-delivery-classification-helpers';
|
|
17
|
+
export * from './materialized-delivery-close-day-helpers';
|
|
18
|
+
export * from './materialized-cash-classification-helpers';
|
|
19
|
+
export * from './materialized-cash-close-day-helpers';
|
|
20
|
+
export * from './materialized-cash-compile-helpers';
|
|
21
|
+
export * from './materialized-prep-time-classification-helpers';
|
|
22
|
+
export * from './materialized-prep-time-close-day-helpers';
|
|
23
|
+
export * from './materialized-prep-time-compile-helpers';
|
|
3
24
|
export * from './materialized-reports-read-helpers';
|
|
4
25
|
export * from './materialized-reports-scope-group-helpers';
|
|
5
26
|
export * from './materialized-reports-selection-helpers';
|
|
27
|
+
export * from './materialized-sales-comparison-accumulator-helpers';
|
|
28
|
+
export * from './materialized-sales-comparison-baseline-helpers';
|
|
29
|
+
export * from './materialized-sales-comparison-close-day-helpers';
|
|
30
|
+
export * from './materialized-sales-comparison-compile-helpers';
|
|
6
31
|
export * from './materialized-tenant-reports-iterations-helpers';
|
|
7
32
|
export * from './scope-helpers';
|
|
33
|
+
export * from './tenant-hourly-comparison-formatter';
|
|
34
|
+
export * from './tenant-payments-comparison-formatter';
|
|
35
|
+
export * from './tenant-sales-comparison-formatter';
|
|
8
36
|
export * from './tenant-sales-overview-close-day-helpers';
|
|
37
|
+
export * from './tenant-discount-formatter';
|
|
38
|
+
export * from './tenant-cash-in-out-formatter';
|
|
39
|
+
export * from './tenant-delivery-formatter';
|
|
40
|
+
export * from './tenant-prep-time-formatter';
|
|
9
41
|
export * from './tenant-sales-overview-formatter';
|
|
10
42
|
export * from './tenant-sales-overview-helpers';
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { CASH_IN_OUT_REF_ENUM } from '../../constants/enums/cash';
|
|
2
|
+
import { freshCashCounters } from './materialized-cash-classification-helpers';
|
|
3
|
+
/**
|
|
4
|
+
* M3 cash - folding counters across days into a PERIOD document.
|
|
5
|
+
*
|
|
6
|
+
* Two rules, and both exist because cash has non-additive quantities:
|
|
7
|
+
*
|
|
8
|
+
* 1. **Derived values are RECOMPUTED, never summed.** `ledger_net`, `operator.net`,
|
|
9
|
+
* `system.net` and every `by_ref` total are all `in - out`. They happen to be
|
|
10
|
+
* linear here, but recomputing from the summed parts means a future change to a
|
|
11
|
+
* definition cannot silently desynchronize a period total from its components.
|
|
12
|
+
* 2. **`staff_count` is a UNION, not a sum.** It counts DISTINCT staff, so adding two
|
|
13
|
+
* days double-counts anyone who worked both. The fold unions the stored id sets.
|
|
14
|
+
* A period document therefore cannot be produced by summing day documents alone -
|
|
15
|
+
* which is the same reason the prep time report stores its histogram rows.
|
|
16
|
+
*
|
|
17
|
+
* Period documents are always RE-FOLDED from the day documents rather than
|
|
18
|
+
* incremented in place: you cannot subtract a distinct count, so an incremental
|
|
19
|
+
* update could never undo a removed day.
|
|
20
|
+
*/
|
|
21
|
+
const addFlow = (target, source) => {
|
|
22
|
+
target.in_count += Number(source?.in_count) || 0;
|
|
23
|
+
target.in_amount += Number(source?.in_amount) || 0;
|
|
24
|
+
target.out_count += Number(source?.out_count) || 0;
|
|
25
|
+
target.out_amount += Number(source?.out_amount) || 0;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Merges `source` into `target`, IN PLACE. Used to fold day counters into a period.
|
|
29
|
+
*
|
|
30
|
+
* Null-safe: a source block missing a sub-object is treated as zeroes rather than
|
|
31
|
+
* throwing, so one malformed historical document cannot break a whole fold.
|
|
32
|
+
*/
|
|
33
|
+
export function mergeMaterializedCashCounters(target, source) {
|
|
34
|
+
var _a;
|
|
35
|
+
if (target == null || source == null)
|
|
36
|
+
return target;
|
|
37
|
+
const t = target.movements;
|
|
38
|
+
const s = source.movements;
|
|
39
|
+
if (t != null && s != null) {
|
|
40
|
+
t.count += Number(s.count) || 0;
|
|
41
|
+
t.in_count += Number(s.in_count) || 0;
|
|
42
|
+
t.in_amount += Number(s.in_amount) || 0;
|
|
43
|
+
t.out_count += Number(s.out_count) || 0;
|
|
44
|
+
t.out_amount += Number(s.out_amount) || 0;
|
|
45
|
+
if (t.operator != null && s.operator != null) {
|
|
46
|
+
addFlow(t.operator, s.operator);
|
|
47
|
+
t.operator.count += Number(s.operator.count) || 0;
|
|
48
|
+
}
|
|
49
|
+
if (t.system != null && s.system != null) {
|
|
50
|
+
addFlow(t.system, s.system);
|
|
51
|
+
t.system.count += Number(s.system.count) || 0;
|
|
52
|
+
}
|
|
53
|
+
if (t.lifecycle != null && s.lifecycle != null) {
|
|
54
|
+
t.lifecycle.float_count += Number(s.lifecycle.float_count) || 0;
|
|
55
|
+
t.lifecycle.float_amount += Number(s.lifecycle.float_amount) || 0;
|
|
56
|
+
t.lifecycle.reopen_count += Number(s.lifecycle.reopen_count) || 0;
|
|
57
|
+
t.lifecycle.reopen_amount += Number(s.lifecycle.reopen_amount) || 0;
|
|
58
|
+
t.lifecycle.countout_count += Number(s.lifecycle.countout_count) || 0;
|
|
59
|
+
t.lifecycle.countout_amount += Number(s.lifecycle.countout_amount) || 0;
|
|
60
|
+
}
|
|
61
|
+
t.by_ref ?? (t.by_ref = {});
|
|
62
|
+
for (const refType of Object.values(CASH_IN_OUT_REF_ENUM)) {
|
|
63
|
+
const sourceFlow = s.by_ref?.[refType];
|
|
64
|
+
if (sourceFlow == null)
|
|
65
|
+
continue;
|
|
66
|
+
(_a = t.by_ref)[refType] ?? (_a[refType] = { in_count: 0, in_amount: 0, out_count: 0, out_amount: 0 });
|
|
67
|
+
addFlow(t.by_ref[refType], sourceFlow);
|
|
68
|
+
}
|
|
69
|
+
// UNION the rosters - never add the counts.
|
|
70
|
+
const roster = new Set(t.staff_ids ?? []);
|
|
71
|
+
for (const id of s.staff_ids ?? [])
|
|
72
|
+
roster.add(String(id));
|
|
73
|
+
t.staff_ids = [...roster].sort();
|
|
74
|
+
t.staff_count = t.staff_ids.length;
|
|
75
|
+
}
|
|
76
|
+
const ts = target.sessions;
|
|
77
|
+
const ss = source.sessions;
|
|
78
|
+
if (ts != null && ss != null) {
|
|
79
|
+
ts.session_count += Number(ss.session_count) || 0;
|
|
80
|
+
ts.reopen_count += Number(ss.reopen_count) || 0;
|
|
81
|
+
ts.reopened_session_count += Number(ss.reopened_session_count) || 0;
|
|
82
|
+
ts.opening_float_amount += Number(ss.opening_float_amount) || 0;
|
|
83
|
+
ts.net_movements_amount += Number(ss.net_movements_amount) || 0;
|
|
84
|
+
ts.expected_close_amount += Number(ss.expected_close_amount) || 0;
|
|
85
|
+
ts.counted_close_amount += Number(ss.counted_close_amount) || 0;
|
|
86
|
+
ts.variance_amount += Number(ss.variance_amount) || 0;
|
|
87
|
+
ts.variance_positive_count += Number(ss.variance_positive_count) || 0;
|
|
88
|
+
ts.variance_negative_count += Number(ss.variance_negative_count) || 0;
|
|
89
|
+
ts.open_sessions_count += Number(ss.open_sessions_count) || 0;
|
|
90
|
+
ts.unmatched_close_count += Number(ss.unmatched_close_count) || 0;
|
|
91
|
+
}
|
|
92
|
+
recalculateCashDerived(target);
|
|
93
|
+
return target;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Recomputes every DERIVED value from the summed components, in place.
|
|
97
|
+
*
|
|
98
|
+
* This is what makes a folded document self-consistent: the nets and the `by_ref`
|
|
99
|
+
* totals are always a function of the counts and amounts beside them.
|
|
100
|
+
*/
|
|
101
|
+
export function recalculateCashDerived(counters) {
|
|
102
|
+
const m = counters?.movements;
|
|
103
|
+
if (m == null)
|
|
104
|
+
return;
|
|
105
|
+
m.ledger_net = (Number(m.in_amount) || 0) - (Number(m.out_amount) || 0);
|
|
106
|
+
if (m.operator != null) {
|
|
107
|
+
m.operator.net = (Number(m.operator.in_amount) || 0) - (Number(m.operator.out_amount) || 0);
|
|
108
|
+
}
|
|
109
|
+
if (m.system != null) {
|
|
110
|
+
m.system.net = (Number(m.system.in_amount) || 0) - (Number(m.system.out_amount) || 0);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/** A fresh zeroed block - re-exported so callers fold from the same seed. */
|
|
114
|
+
export { freshCashCounters };
|