@managesome/eposmatic-toolkit 0.4.9 → 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/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/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
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { MATERIALIZED_PREP_TIME_ANCHOR_ENUM, MATERIALIZED_PREP_TIME_BUCKETS, MATERIALIZED_PREP_TIME_MAX_MINUTES, MATERIALIZED_PREP_TIME_ON_TIME_MAX_DELTA, MATERIALIZED_PREP_TIME_TARGET_ENUM, MATERIALIZED_PREP_TIME_TOP_BUCKET, } from '../../constants/MATERIALIZED_REPORTS';
|
|
2
|
+
/**
|
|
3
|
+
* Numeric or null - never NaN. The stored field is a duration in whole minutes.
|
|
4
|
+
*/
|
|
5
|
+
const toMinutes = (value) => {
|
|
6
|
+
if (typeof value === 'number' && Number.isFinite(value))
|
|
7
|
+
return value;
|
|
8
|
+
if (typeof value === 'string' && value.trim() !== '') {
|
|
9
|
+
const parsed = Number(value);
|
|
10
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
11
|
+
}
|
|
12
|
+
return null;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Histogram bucket label of a duration. Total by construction: the top bucket is
|
|
16
|
+
* open-ended, so every finite duration lands in exactly one bucket.
|
|
17
|
+
*/
|
|
18
|
+
export function resolveMaterializedPrepTimeBucket(minutes) {
|
|
19
|
+
for (const bucket of MATERIALIZED_PREP_TIME_BUCKETS) {
|
|
20
|
+
if (minutes >= bucket.min && (bucket.max === null || minutes <= bucket.max)) {
|
|
21
|
+
return bucket.label;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
// Unreachable while the buckets tile the range (a unit test pins the tiling),
|
|
25
|
+
// but a NaN or negative duration must never silently vanish from the counts.
|
|
26
|
+
return MATERIALIZED_PREP_TIME_TOP_BUCKET;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Provenance of ONE item (decision b2).
|
|
30
|
+
*
|
|
31
|
+
* MEASURED requires BOTH `prep_started_at` and `ready_minutes`: the item owns its
|
|
32
|
+
* prep clock, so the ready instant is reconstructible. Anything else - including
|
|
33
|
+
* `ready_minutes` with no `prep_started_at` - is UNMEASURED.
|
|
34
|
+
*/
|
|
35
|
+
export function classifyMaterializedPrepTimeAnchor(item) {
|
|
36
|
+
const hasOwnAnchor = item?.prep_started_at != null;
|
|
37
|
+
const minutes = toMinutes(item?.ready_minutes);
|
|
38
|
+
return hasOwnAnchor && minutes != null
|
|
39
|
+
? MATERIALIZED_PREP_TIME_ANCHOR_ENUM.MEASURED
|
|
40
|
+
: MATERIALIZED_PREP_TIME_ANCHOR_ENUM.UNMEASURED;
|
|
41
|
+
}
|
|
42
|
+
/** A zeroed counter block. */
|
|
43
|
+
export function freshMaterializedPrepTimeCounters() {
|
|
44
|
+
const buckets = {};
|
|
45
|
+
for (const bucket of MATERIALIZED_PREP_TIME_BUCKETS)
|
|
46
|
+
buckets[bucket.label] = 0;
|
|
47
|
+
return {
|
|
48
|
+
coverage: {
|
|
49
|
+
item_count: 0,
|
|
50
|
+
ready_item_count: 0,
|
|
51
|
+
tracked_count: 0,
|
|
52
|
+
own_anchor_count: 0,
|
|
53
|
+
fallback_anchor_count: 0,
|
|
54
|
+
order_count: 0,
|
|
55
|
+
},
|
|
56
|
+
duration: { min: 0, max: 0, sum: 0, count: 0, instant_count: 0, buckets },
|
|
57
|
+
promise: {
|
|
58
|
+
promise_set_count: 0,
|
|
59
|
+
default_baseline_count: 0,
|
|
60
|
+
on_time_count: 0,
|
|
61
|
+
late_count: 0,
|
|
62
|
+
delta_sum: 0,
|
|
63
|
+
no_target_count: 0,
|
|
64
|
+
},
|
|
65
|
+
late_items: { count: 0, worst_delta: 0 },
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/** The on-time target of one order, and where it came from (decision e2). */
|
|
69
|
+
export function resolveMaterializedPrepTimeTarget(order, tenantDefaultMinutes) {
|
|
70
|
+
// An explicit estimate is an ABSOLUTE timestamp on the order's detail block.
|
|
71
|
+
const promised = order?.takeaway_details?.estimated_takeaway_time ?? order?.delivery_details?.estimated_delivery_time ?? null;
|
|
72
|
+
if (typeof promised === 'string' && promised.trim() !== '') {
|
|
73
|
+
const at = new Date(promised);
|
|
74
|
+
if (!Number.isNaN(at.getTime())) {
|
|
75
|
+
return { target_at: at, target_source: MATERIALIZED_PREP_TIME_TARGET_ENUM.PROMISE };
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// Otherwise the tenant default, measured from the punch instant. Absent in the
|
|
79
|
+
// dev fixtures (0 orders carry one), so it arrives from tenant config and is
|
|
80
|
+
// usually null - those items are honestly counted as NONE, never graded against
|
|
81
|
+
// an invented baseline.
|
|
82
|
+
const fallbackMinutes = toMinutes(tenantDefaultMinutes);
|
|
83
|
+
const createdMs = order?.createdAt != null ? new Date(order.createdAt).getTime() : NaN;
|
|
84
|
+
if (fallbackMinutes != null && fallbackMinutes > 0 && !Number.isNaN(createdMs)) {
|
|
85
|
+
return {
|
|
86
|
+
target_at: new Date(createdMs + fallbackMinutes * 60000),
|
|
87
|
+
target_source: MATERIALIZED_PREP_TIME_TARGET_ENUM.TENANT_DEFAULT,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return { target_at: null, target_source: MATERIALIZED_PREP_TIME_TARGET_ENUM.NONE };
|
|
91
|
+
}
|
|
92
|
+
/** Stable identity of a row inside its order - part of the page cursor. */
|
|
93
|
+
export const buildMaterializedPrepTimeEntryKey = (itemId) => 'item:' + String(itemId ?? 'unknown');
|
|
94
|
+
/**
|
|
95
|
+
* Accumulates ONE order's items into the prep counters + drill-down rows.
|
|
96
|
+
*
|
|
97
|
+
* Items are read from `order.categories[].items[]` (the verified shape). Every
|
|
98
|
+
* item counts toward coverage; only MEASURED items reach the duration statistics,
|
|
99
|
+
* and only MEASURED items with a target are graded on time.
|
|
100
|
+
*/
|
|
101
|
+
export function accumulateOrderPrepTime({ order, context, tenantDefaultMinutes = null, }) {
|
|
102
|
+
const counters = freshMaterializedPrepTimeCounters();
|
|
103
|
+
const entries = [];
|
|
104
|
+
if (order == null)
|
|
105
|
+
return { counters, entries, has_tracked: false };
|
|
106
|
+
const orderId = order._id != null ? String(order._id) : null;
|
|
107
|
+
if (orderId == null)
|
|
108
|
+
return { counters, entries, has_tracked: false };
|
|
109
|
+
const orderStatus = String(order.order_status ?? '');
|
|
110
|
+
const platform = String(order.platform ?? order.order_from ?? '');
|
|
111
|
+
const staffId = order.staff_details?._id != null ? String(order.staff_details._id) : null;
|
|
112
|
+
const staffName = order.staff_details?.name != null ? String(order.staff_details.name) : null;
|
|
113
|
+
const createdMs = order.createdAt != null ? new Date(order.createdAt).getTime() : NaN;
|
|
114
|
+
const createdAt = Number.isNaN(createdMs) ? new Date(0) : new Date(createdMs);
|
|
115
|
+
const { target_at, target_source } = resolveMaterializedPrepTimeTarget(order, tenantDefaultMinutes);
|
|
116
|
+
let tracked = 0;
|
|
117
|
+
for (const category of order.categories ?? []) {
|
|
118
|
+
for (const item of category?.items ?? []) {
|
|
119
|
+
counters.coverage.item_count += 1;
|
|
120
|
+
const isReady = item?.is_ready === true;
|
|
121
|
+
if (isReady)
|
|
122
|
+
counters.coverage.ready_item_count += 1;
|
|
123
|
+
const minutes = toMinutes(item?.ready_minutes);
|
|
124
|
+
const prepStartedAt = item?.prep_started_at != null ? new Date(item.prep_started_at) : null;
|
|
125
|
+
const prepStartedValid = prepStartedAt != null && !Number.isNaN(prepStartedAt.getTime());
|
|
126
|
+
const anchor = prepStartedValid && minutes != null
|
|
127
|
+
? MATERIALIZED_PREP_TIME_ANCHOR_ENUM.MEASURED
|
|
128
|
+
: MATERIALIZED_PREP_TIME_ANCHOR_ENUM.UNMEASURED;
|
|
129
|
+
let readyAt = null;
|
|
130
|
+
let deltaMinutes = null;
|
|
131
|
+
if (minutes != null) {
|
|
132
|
+
tracked += 1;
|
|
133
|
+
counters.coverage.tracked_count += 1;
|
|
134
|
+
if (anchor === MATERIALIZED_PREP_TIME_ANCHOR_ENUM.MEASURED) {
|
|
135
|
+
counters.coverage.own_anchor_count += 1;
|
|
136
|
+
// RECONSTRUCTED ready instant - the source field ready_at does not exist.
|
|
137
|
+
readyAt = new Date(prepStartedAt.getTime() + minutes * 60000);
|
|
138
|
+
counters.duration.count += 1;
|
|
139
|
+
if (minutes === 0)
|
|
140
|
+
counters.duration.instant_count += 1;
|
|
141
|
+
const bucket = resolveMaterializedPrepTimeBucket(minutes);
|
|
142
|
+
counters.duration.buckets[bucket] = (counters.duration.buckets[bucket] ?? 0) + 1;
|
|
143
|
+
// Counts above stay complete; only the EXTREMES are guarded, so a single
|
|
144
|
+
// clock/backfill artefact cannot define min/max/sum.
|
|
145
|
+
if (minutes <= MATERIALIZED_PREP_TIME_MAX_MINUTES) {
|
|
146
|
+
counters.duration.sum += minutes;
|
|
147
|
+
if (counters.duration.count === 1 || minutes < counters.duration.min) {
|
|
148
|
+
counters.duration.min = minutes;
|
|
149
|
+
}
|
|
150
|
+
if (minutes > counters.duration.max)
|
|
151
|
+
counters.duration.max = minutes;
|
|
152
|
+
}
|
|
153
|
+
if (target_at != null) {
|
|
154
|
+
deltaMinutes = Math.round((readyAt.getTime() - target_at.getTime()) / 60000);
|
|
155
|
+
counters.promise.delta_sum += deltaMinutes;
|
|
156
|
+
if (deltaMinutes <= MATERIALIZED_PREP_TIME_ON_TIME_MAX_DELTA) {
|
|
157
|
+
counters.promise.on_time_count += 1;
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
counters.promise.late_count += 1;
|
|
161
|
+
counters.late_items.count += 1;
|
|
162
|
+
if (deltaMinutes > counters.late_items.worst_delta) {
|
|
163
|
+
counters.late_items.worst_delta = deltaMinutes;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
counters.coverage.fallback_anchor_count += 1;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if (target_at != null) {
|
|
173
|
+
if (target_source === MATERIALIZED_PREP_TIME_TARGET_ENUM.PROMISE) {
|
|
174
|
+
counters.promise.promise_set_count += 1;
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
counters.promise.default_baseline_count += 1;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
counters.promise.no_target_count += 1;
|
|
182
|
+
}
|
|
183
|
+
const itemId = item?._id != null ? String(item._id) : null;
|
|
184
|
+
const row = {
|
|
185
|
+
entry_key: buildMaterializedPrepTimeEntryKey(itemId),
|
|
186
|
+
order_id: orderId,
|
|
187
|
+
order_number: order.order_number ?? null,
|
|
188
|
+
item_id: itemId,
|
|
189
|
+
item_name: item?.name != null ? String(item.name) : null,
|
|
190
|
+
category_name: category?.name != null ? String(category.name) : null,
|
|
191
|
+
anchor,
|
|
192
|
+
duration_minutes: minutes,
|
|
193
|
+
prep_started_at: prepStartedValid ? prepStartedAt : null,
|
|
194
|
+
ready_at: readyAt,
|
|
195
|
+
is_ready: isReady,
|
|
196
|
+
target_at,
|
|
197
|
+
target_source: target_at != null ? target_source : null,
|
|
198
|
+
delta_minutes: deltaMinutes,
|
|
199
|
+
staff_id: staffId,
|
|
200
|
+
staff_name: staffName,
|
|
201
|
+
order_status: orderStatus,
|
|
202
|
+
platform,
|
|
203
|
+
created_at: createdAt,
|
|
204
|
+
local_hour: context.local_hour_label,
|
|
205
|
+
};
|
|
206
|
+
// Only items with a prep signal become rows: an untouched item has nothing
|
|
207
|
+
// to inspect, and the drill-down exists to explain the numbers.
|
|
208
|
+
if (minutes != null || prepStartedValid)
|
|
209
|
+
entries.push(row);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
if (tracked > 0)
|
|
213
|
+
counters.coverage.order_count = 1;
|
|
214
|
+
return { counters, entries, has_tracked: tracked > 0 };
|
|
215
|
+
}
|
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
import mongoose from 'mongoose';
|
|
2
|
+
import { MATERIALIZED_PREP_TIME_REPORT_SCOPES, MATERIALIZED_REPORT_TYPE_ENUM, } from '../../constants/MATERIALIZED_REPORTS';
|
|
3
|
+
import { freshMaterializedPrepTimeCounters } from './materialized-prep-time-classification-helpers';
|
|
4
|
+
import { mergeMaterializedPrepTimeCounters } from './materialized-prep-time-compile-helpers';
|
|
5
|
+
import { buildMaterializedTenantReportIteration } from './materialized-tenant-reports-iterations-helpers';
|
|
6
|
+
import { getMaterializedPeriodScopeFields } from './scope-helpers';
|
|
7
|
+
/**
|
|
8
|
+
* M2 close-day helpers.
|
|
9
|
+
*
|
|
10
|
+
* ## Why period counters are RECOMPUTED, not patched
|
|
11
|
+
*
|
|
12
|
+
* The other report ledgers keep period scopes up to date by SUBTRACTING the
|
|
13
|
+
* stored day delta and adding the fresh one. That cannot work here:
|
|
14
|
+
* `duration.min` / `duration.max` / `late_items.worst_delta` are AGGREGATES, and
|
|
15
|
+
* there is no way to "subtract" a minimum - removing the day that contributed the
|
|
16
|
+
* smallest value would leave a minimum that no longer exists in any day.
|
|
17
|
+
*
|
|
18
|
+
* So a period document's counters are FOLDED from the day documents that belong
|
|
19
|
+
* to it (the stored ones plus the day being closed). That is both correct for
|
|
20
|
+
* aggregates and IDEMPOTENT: re-closing the same day replaces that day's
|
|
21
|
+
* contribution and re-folds, so a re-close converges instead of drifting.
|
|
22
|
+
*/
|
|
23
|
+
/** Scopes written wholesale for the compiled day (no hour scope in v1). */
|
|
24
|
+
const PREP_TIME_DAY_SCOPES = ['localDate'];
|
|
25
|
+
/** Row identity inside a period document: an order holds many items. */
|
|
26
|
+
const prepEntryRowIdentity = (row) => String(row.order_id) + '|' + String(row.entry_key);
|
|
27
|
+
/**
|
|
28
|
+
* Merges a freshly compiled day of prep rows into a PERIOD document's stored
|
|
29
|
+
* rows.
|
|
30
|
+
*
|
|
31
|
+
* Idempotent by construction: the merge key is `(order_id, entry_key)`, which is
|
|
32
|
+
* globally unique per row (`entry_key` is the row's stable identity INSIDE its
|
|
33
|
+
* order, and an order belongs to exactly one day). Re-closing the SAME day
|
|
34
|
+
* therefore REPLACES its own rows rather than duplicating them, while a new day
|
|
35
|
+
* ADDS its rows.
|
|
36
|
+
*
|
|
37
|
+
* Without this a period document would hold only its final closed day - the
|
|
38
|
+
* measured M1 bug (a month entry document carrying 9 rows where the equivalent
|
|
39
|
+
* ledger month carried the whole month).
|
|
40
|
+
*/
|
|
41
|
+
export const mergeMaterializedPrepTimeEntrySections = (stored, fresh) => {
|
|
42
|
+
const out = {};
|
|
43
|
+
const keys = new Set([...Object.keys(stored ?? {}), ...Object.keys(fresh ?? {})]);
|
|
44
|
+
for (const key of keys) {
|
|
45
|
+
const byIdentity = new Map();
|
|
46
|
+
for (const row of stored?.[key]?.rows ?? []) {
|
|
47
|
+
byIdentity.set(prepEntryRowIdentity(row), row);
|
|
48
|
+
}
|
|
49
|
+
// FRESH wins: a re-close of the same day overwrites its own rows.
|
|
50
|
+
for (const row of fresh?.[key]?.rows ?? []) {
|
|
51
|
+
byIdentity.set(prepEntryRowIdentity(row), row);
|
|
52
|
+
}
|
|
53
|
+
if (byIdentity.size > 0)
|
|
54
|
+
out[key] = { rows: [...byIdentity.values()] };
|
|
55
|
+
}
|
|
56
|
+
return out;
|
|
57
|
+
};
|
|
58
|
+
/** True when the document is one of the day scopes (replaced wholesale). */
|
|
59
|
+
export const isMaterializedPrepTimeDayScope = (scopeContext) => PREP_TIME_DAY_SCOPES.includes(scopeContext);
|
|
60
|
+
/**
|
|
61
|
+
* Updates a stored prep ENTRY document.
|
|
62
|
+
*
|
|
63
|
+
* DAY scopes (`localDate`) are REPLACED wholesale - the day's rows are the whole
|
|
64
|
+
* truth. PERIOD scopes MERGE, because the compile produces only ONE day of rows.
|
|
65
|
+
* Returns null when the documents disagree on schema/scope (a data issue the
|
|
66
|
+
* caller must surface).
|
|
67
|
+
*/
|
|
68
|
+
export function updateMaterializedPrepTimeEntries(existing, compiled, options = {}) {
|
|
69
|
+
if (existing == null || compiled == null)
|
|
70
|
+
return null;
|
|
71
|
+
if (existing.schema_version !== compiled.schema_version ||
|
|
72
|
+
existing.scope_context !== compiled.scope_context ||
|
|
73
|
+
existing.scope_field !== compiled.scope_field) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
const computedAt = options.computedAt ?? new Date();
|
|
77
|
+
const existingTime = new Date(existing.source_watermark ?? 0).getTime();
|
|
78
|
+
const compiledTime = new Date(compiled.source_watermark ?? 0).getTime();
|
|
79
|
+
const mergePeriodRows = !isMaterializedPrepTimeDayScope(String(compiled.scope_context));
|
|
80
|
+
return {
|
|
81
|
+
...existing,
|
|
82
|
+
prep_time_entries: mergePeriodRows
|
|
83
|
+
? mergeMaterializedPrepTimeEntrySections(existing.prep_time_entries, compiled.prep_time_entries)
|
|
84
|
+
: compiled.prep_time_entries,
|
|
85
|
+
source_watermark: compiledTime > existingTime ? compiled.source_watermark : existing.source_watermark,
|
|
86
|
+
computed_at: computedAt,
|
|
87
|
+
updatedAt: computedAt,
|
|
88
|
+
iteration: (existing.iteration ?? 1) + 1,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/** True when a stored prep entry document equals the compiled one (skip write). */
|
|
92
|
+
export function needsMaterializedPrepTimeEntriesWrite(existing, incoming) {
|
|
93
|
+
if (existing == null || incoming == null)
|
|
94
|
+
return true;
|
|
95
|
+
if (existing.schema_version !== incoming.schema_version)
|
|
96
|
+
return true;
|
|
97
|
+
if ((existing.sale_type_key_filters ?? []).join(':') !== (incoming.sale_type_key_filters ?? []).join(':')) {
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
const existingTime = new Date(existing.source_watermark ?? 0).getTime();
|
|
101
|
+
const incomingTime = new Date(incoming.source_watermark ?? 0).getTime();
|
|
102
|
+
if (Number.isNaN(existingTime) || Number.isNaN(incomingTime))
|
|
103
|
+
return true;
|
|
104
|
+
return incomingTime > existingTime;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Folds the day documents of ONE period scope into that period's counters.
|
|
108
|
+
*
|
|
109
|
+
* `dayDocuments` must be the AUTHORITATIVE day set for the period: every stored
|
|
110
|
+
* `localDate` document that maps to this period, PLUS the day being closed (which
|
|
111
|
+
* supersedes any stored document for the same day). The caller supplies it, so a
|
|
112
|
+
* re-close naturally replaces its own contribution.
|
|
113
|
+
*
|
|
114
|
+
* Returns null when the period fields cannot be resolved for any supplied day -
|
|
115
|
+
* the caller surfaces that instead of writing a silently short period.
|
|
116
|
+
*/
|
|
117
|
+
export function foldMaterializedPrepTimePeriodCounters({ periodScopeField, periodScope, dayDocuments, periodFieldsOfDay, }) {
|
|
118
|
+
const folded = {};
|
|
119
|
+
for (const dayDoc of dayDocuments) {
|
|
120
|
+
if (dayDoc.scope_context !== 'localDate')
|
|
121
|
+
continue;
|
|
122
|
+
const fields = periodFieldsOfDay(String(dayDoc.scope_field));
|
|
123
|
+
if (fields == null)
|
|
124
|
+
return null;
|
|
125
|
+
if (fields[periodScope] !== periodScopeField)
|
|
126
|
+
continue;
|
|
127
|
+
for (const [key, counters] of Object.entries(dayDoc.prep_time_counters ?? {})) {
|
|
128
|
+
const bucket = (folded[key] ?? (folded[key] = freshMaterializedPrepTimeCounters()));
|
|
129
|
+
mergeMaterializedPrepTimeCounters(bucket, counters);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return folded;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Folds the day documents of ONE period into that period's ENTRY rows, using the
|
|
136
|
+
* same authoritative day set as the counters. Rows are keyed by
|
|
137
|
+
* `(order_id, entry_key)` so a re-closed day replaces its own rows.
|
|
138
|
+
*/
|
|
139
|
+
export function foldMaterializedPrepTimePeriodRows({ periodScopeField, periodScope, dayDocuments, periodFieldsOfDay, }) {
|
|
140
|
+
const sections = {};
|
|
141
|
+
for (const dayDoc of dayDocuments) {
|
|
142
|
+
if (dayDoc.scope_context !== 'localDate')
|
|
143
|
+
continue;
|
|
144
|
+
const fields = periodFieldsOfDay(String(dayDoc.scope_field));
|
|
145
|
+
if (fields == null)
|
|
146
|
+
continue;
|
|
147
|
+
if (fields[periodScope] !== periodScopeField)
|
|
148
|
+
continue;
|
|
149
|
+
const merged = mergeMaterializedPrepTimeEntrySections(sections, dayDoc.prep_time_entries);
|
|
150
|
+
for (const key of Object.keys(merged))
|
|
151
|
+
sections[key] = merged[key];
|
|
152
|
+
}
|
|
153
|
+
return sections;
|
|
154
|
+
}
|
|
155
|
+
/** The period scope contexts (everything except the day scope). */
|
|
156
|
+
export const MATERIALIZED_PREP_TIME_PERIOD_SCOPES = MATERIALIZED_PREP_TIME_REPORT_SCOPES.filter((scope) => !isMaterializedPrepTimeDayScope(String(scope)));
|
|
157
|
+
/** True when a stored prep counter document equals the incoming one (skip write). */
|
|
158
|
+
export function needsMaterializedPrepTimeReportWrite(existing, incoming) {
|
|
159
|
+
if (existing == null || incoming == null)
|
|
160
|
+
return true;
|
|
161
|
+
if (existing.schema_version !== incoming.schema_version)
|
|
162
|
+
return true;
|
|
163
|
+
if ((existing.sale_type_key_filters ?? []).join(':') !== (incoming.sale_type_key_filters ?? []).join(':')) {
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
const existingTime = new Date(existing.source_watermark ?? 0).getTime();
|
|
167
|
+
const incomingTime = new Date(incoming.source_watermark ?? 0).getTime();
|
|
168
|
+
if (Number.isNaN(existingTime) || Number.isNaN(incomingTime))
|
|
169
|
+
return true;
|
|
170
|
+
return incomingTime > existingTime;
|
|
171
|
+
}
|
|
172
|
+
const prepScopeKey = (doc) => doc.scope_context + '|' + doc.scope_field;
|
|
173
|
+
/**
|
|
174
|
+
* Builds the close-day plan for ONE tenant-day.
|
|
175
|
+
*
|
|
176
|
+
* The DAY scope is written from the compile. Every PERIOD scope the day touches
|
|
177
|
+
* is RE-FOLDED from its whole day set - including periods that contained a day
|
|
178
|
+
* that just became empty, which is why the touched set is the union of the closed
|
|
179
|
+
* day's periods and every removed day's periods. Without that, emptying a day
|
|
180
|
+
* would leave its contribution stranded in the period forever.
|
|
181
|
+
*
|
|
182
|
+
* Returns null on malformed input or a data issue the caller must surface.
|
|
183
|
+
*/
|
|
184
|
+
export function buildTenantPrepTimeCloseDayPlan(input) {
|
|
185
|
+
if (input == null)
|
|
186
|
+
return null;
|
|
187
|
+
const { tenantId, reports, entries, reason } = input;
|
|
188
|
+
if (typeof tenantId !== 'string' || tenantId.length === 0)
|
|
189
|
+
return null;
|
|
190
|
+
if (typeof reason !== 'string' || reason.length === 0)
|
|
191
|
+
return null;
|
|
192
|
+
if (!Array.isArray(reports) || !Array.isArray(entries))
|
|
193
|
+
return null;
|
|
194
|
+
if (reports.some((doc) => doc == null || doc.tenant_id !== tenantId))
|
|
195
|
+
return null;
|
|
196
|
+
const computedAt = input.computedAt ?? new Date();
|
|
197
|
+
const existing = input.existing ?? [];
|
|
198
|
+
const existingEntries = input.existingEntries ?? [];
|
|
199
|
+
const dateDoc = reports.find((doc) => doc.scope_context === 'localDate') ?? null;
|
|
200
|
+
const localDate = dateDoc?.scope_field ?? input.localDate ?? null;
|
|
201
|
+
if (typeof localDate !== 'string' || localDate.length === 0)
|
|
202
|
+
return null;
|
|
203
|
+
const periodFieldsOfDay = (day) => getMaterializedPeriodScopeFields(day);
|
|
204
|
+
const closedDayFields = periodFieldsOfDay(localDate);
|
|
205
|
+
if (closedDayFields == null)
|
|
206
|
+
return null;
|
|
207
|
+
const writes = [];
|
|
208
|
+
const entryWrites = [];
|
|
209
|
+
const staleDocuments = [];
|
|
210
|
+
const staleEntryDocuments = [];
|
|
211
|
+
const skippedDocuments = [];
|
|
212
|
+
const skippedEntryDocuments = [];
|
|
213
|
+
const addWrite = (report) => {
|
|
214
|
+
const persisted = report.iteration == null ? { ...report, iteration: 1 } : report;
|
|
215
|
+
const iteration = buildMaterializedTenantReportIteration(persisted, {
|
|
216
|
+
reportType: MATERIALIZED_REPORT_TYPE_ENUM.TENANT_PREP_TIME_REPORTS,
|
|
217
|
+
reason,
|
|
218
|
+
computedAt,
|
|
219
|
+
});
|
|
220
|
+
if (iteration == null)
|
|
221
|
+
return false;
|
|
222
|
+
writes.push({ report: persisted, iteration: iteration });
|
|
223
|
+
return true;
|
|
224
|
+
};
|
|
225
|
+
const addEntryWrite = (report) => {
|
|
226
|
+
const persisted = report.iteration == null ? { ...report, iteration: 1 } : report;
|
|
227
|
+
const iteration = buildMaterializedTenantReportIteration(persisted, {
|
|
228
|
+
reportType: MATERIALIZED_REPORT_TYPE_ENUM.TENANT_PREP_TIME_ENTRIES,
|
|
229
|
+
reason,
|
|
230
|
+
computedAt,
|
|
231
|
+
});
|
|
232
|
+
if (iteration == null)
|
|
233
|
+
return false;
|
|
234
|
+
entryWrites.push({ report: persisted, iteration: iteration });
|
|
235
|
+
return true;
|
|
236
|
+
};
|
|
237
|
+
const existingByScope = new Map();
|
|
238
|
+
for (const doc of existing)
|
|
239
|
+
existingByScope.set(prepScopeKey(doc), doc);
|
|
240
|
+
const existingEntriesByScope = new Map();
|
|
241
|
+
for (const doc of existingEntries)
|
|
242
|
+
existingEntriesByScope.set(prepScopeKey(doc), doc);
|
|
243
|
+
const compiledByScope = new Map();
|
|
244
|
+
for (const doc of reports) {
|
|
245
|
+
const key = prepScopeKey(doc);
|
|
246
|
+
if (compiledByScope.has(key))
|
|
247
|
+
return null; // duplicate - data issue
|
|
248
|
+
compiledByScope.set(key, doc);
|
|
249
|
+
}
|
|
250
|
+
// ---- the authoritative DAY set after this close --------------------------
|
|
251
|
+
// Stored day documents, minus the day being closed, plus the compiled day.
|
|
252
|
+
const removedDays = [];
|
|
253
|
+
const nextDayDocs = [];
|
|
254
|
+
for (const doc of existing) {
|
|
255
|
+
if (doc.scope_context !== 'localDate')
|
|
256
|
+
continue;
|
|
257
|
+
if (String(doc.scope_field) === localDate)
|
|
258
|
+
continue;
|
|
259
|
+
nextDayDocs.push(doc);
|
|
260
|
+
}
|
|
261
|
+
const compiledDateDocs = reports.filter((doc) => doc.scope_context === 'localDate');
|
|
262
|
+
for (const doc of compiledDateDocs)
|
|
263
|
+
nextDayDocs.push(doc);
|
|
264
|
+
// ONLY THE DAY BEING CLOSED can become stale here. Every other day document is
|
|
265
|
+
// owned by ITS OWN close - treating them as stale would delete the whole history
|
|
266
|
+
// on the next close.
|
|
267
|
+
for (const doc of existing) {
|
|
268
|
+
if (doc.scope_context !== 'localDate')
|
|
269
|
+
continue;
|
|
270
|
+
if (String(doc.scope_field) !== localDate)
|
|
271
|
+
continue;
|
|
272
|
+
if (compiledByScope.has(prepScopeKey(doc)))
|
|
273
|
+
continue;
|
|
274
|
+
// The closed day compiled nothing: its stored document (and its contribution
|
|
275
|
+
// to every period) must go.
|
|
276
|
+
staleDocuments.push(doc);
|
|
277
|
+
removedDays.push(localDate);
|
|
278
|
+
}
|
|
279
|
+
// ---- PERIOD scopes: re-fold every period the closed/removed days touch ---
|
|
280
|
+
const touchedPeriods = new Map();
|
|
281
|
+
const noteDay = (day) => {
|
|
282
|
+
const fields = periodFieldsOfDay(day);
|
|
283
|
+
if (fields == null)
|
|
284
|
+
return false;
|
|
285
|
+
for (const scope of MATERIALIZED_PREP_TIME_PERIOD_SCOPES) {
|
|
286
|
+
const field = fields[scope];
|
|
287
|
+
if (field == null)
|
|
288
|
+
continue;
|
|
289
|
+
touchedPeriods.set(String(scope) + '|' + field, { scope: String(scope), field });
|
|
290
|
+
}
|
|
291
|
+
return true;
|
|
292
|
+
};
|
|
293
|
+
if (!noteDay(localDate))
|
|
294
|
+
return null;
|
|
295
|
+
for (const removed of removedDays)
|
|
296
|
+
if (!noteDay(removed))
|
|
297
|
+
return null;
|
|
298
|
+
for (const { scope, field } of touchedPeriods.values()) {
|
|
299
|
+
const folded = foldMaterializedPrepTimePeriodCounters({
|
|
300
|
+
periodScope: scope,
|
|
301
|
+
periodScopeField: field,
|
|
302
|
+
dayDocuments: nextDayDocs,
|
|
303
|
+
periodFieldsOfDay,
|
|
304
|
+
});
|
|
305
|
+
if (folded == null)
|
|
306
|
+
return null;
|
|
307
|
+
const existingDoc = existingByScope.get(scope + '|' + field) ?? null;
|
|
308
|
+
const keys = Object.keys(folded);
|
|
309
|
+
if (keys.length === 0) {
|
|
310
|
+
// Nothing left in the period - an empty period document must not survive.
|
|
311
|
+
if (existingDoc != null)
|
|
312
|
+
staleDocuments.push(existingDoc);
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
const counters = {};
|
|
316
|
+
const counterRows = [];
|
|
317
|
+
let watermark = null;
|
|
318
|
+
for (const key of keys) {
|
|
319
|
+
counters[key] = folded[key];
|
|
320
|
+
counterRows.push({ key, counters: folded[key] });
|
|
321
|
+
}
|
|
322
|
+
for (const dayDoc of nextDayDocs) {
|
|
323
|
+
const fields = periodFieldsOfDay(String(dayDoc.scope_field));
|
|
324
|
+
if (fields == null)
|
|
325
|
+
continue;
|
|
326
|
+
if (fields[scope] !== field)
|
|
327
|
+
continue;
|
|
328
|
+
const time = new Date(dayDoc.source_watermark ?? 0).getTime();
|
|
329
|
+
if (Number.isNaN(time))
|
|
330
|
+
continue;
|
|
331
|
+
if (watermark == null || time > watermark.getTime())
|
|
332
|
+
watermark = new Date(time);
|
|
333
|
+
}
|
|
334
|
+
const report = {
|
|
335
|
+
// A period document created by the fold gets a fresh id; an existing one keeps
|
|
336
|
+
// its identity so the upsert targets the same row.
|
|
337
|
+
_id: existingDoc?._id ?? new mongoose.Types.ObjectId().toHexString(),
|
|
338
|
+
tenant_id: tenantId,
|
|
339
|
+
brand_id: existingDoc?.brand_id ?? reports[0]?.brand_id ?? '',
|
|
340
|
+
scope_context: scope,
|
|
341
|
+
scope_field: field,
|
|
342
|
+
day_index: null,
|
|
343
|
+
sale_type_key_filters: existingDoc?.sale_type_key_filters ?? reports[0]?.sale_type_key_filters ?? [],
|
|
344
|
+
prep_time_counters: counters,
|
|
345
|
+
prep_time_counter_rows: counterRows,
|
|
346
|
+
iteration: existingDoc?.iteration,
|
|
347
|
+
schema_version: existingDoc?.schema_version ?? 1,
|
|
348
|
+
source_watermark: watermark ?? new Date(computedAt),
|
|
349
|
+
computed_at: computedAt,
|
|
350
|
+
createdAt: existingDoc?.createdAt ?? computedAt,
|
|
351
|
+
updatedAt: computedAt,
|
|
352
|
+
};
|
|
353
|
+
if (existingDoc != null && !needsMaterializedPrepTimeReportWrite(existingDoc, report)) {
|
|
354
|
+
skippedDocuments.push(existingDoc);
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
if (!addWrite(report))
|
|
358
|
+
return null;
|
|
359
|
+
}
|
|
360
|
+
// ---- the DAY scope: written straight from the compile --------------------
|
|
361
|
+
for (const doc of compiledDateDocs) {
|
|
362
|
+
const existingDoc = existingByScope.get(prepScopeKey(doc)) ?? null;
|
|
363
|
+
if (existingDoc != null && !needsMaterializedPrepTimeReportWrite(existingDoc, doc)) {
|
|
364
|
+
skippedDocuments.push(existingDoc);
|
|
365
|
+
continue;
|
|
366
|
+
}
|
|
367
|
+
if (!addWrite(doc))
|
|
368
|
+
return null;
|
|
369
|
+
}
|
|
370
|
+
// ---- entry documents ------------------------------------------------------
|
|
371
|
+
const compiledEntriesByScope = new Map();
|
|
372
|
+
for (const doc of entries) {
|
|
373
|
+
if (doc == null || doc.tenant_id !== tenantId)
|
|
374
|
+
return null;
|
|
375
|
+
const key = prepScopeKey(doc);
|
|
376
|
+
if (compiledEntriesByScope.has(key))
|
|
377
|
+
return null;
|
|
378
|
+
compiledEntriesByScope.set(key, doc);
|
|
379
|
+
}
|
|
380
|
+
const nextDayEntries = [];
|
|
381
|
+
for (const doc of existingEntries) {
|
|
382
|
+
if (doc.scope_context !== 'localDate')
|
|
383
|
+
continue;
|
|
384
|
+
if (String(doc.scope_field) === localDate)
|
|
385
|
+
continue;
|
|
386
|
+
nextDayEntries.push(doc);
|
|
387
|
+
}
|
|
388
|
+
for (const doc of entries) {
|
|
389
|
+
if (doc.scope_context === 'localDate')
|
|
390
|
+
nextDayEntries.push(doc);
|
|
391
|
+
}
|
|
392
|
+
for (const doc of existingEntries) {
|
|
393
|
+
if (doc.scope_context !== 'localDate')
|
|
394
|
+
continue;
|
|
395
|
+
if (String(doc.scope_field) !== localDate)
|
|
396
|
+
continue;
|
|
397
|
+
if (compiledEntriesByScope.has(prepScopeKey(doc)))
|
|
398
|
+
continue;
|
|
399
|
+
staleEntryDocuments.push(doc);
|
|
400
|
+
}
|
|
401
|
+
for (const { scope, field } of touchedPeriods.values()) {
|
|
402
|
+
const sections = foldMaterializedPrepTimePeriodRows({
|
|
403
|
+
periodScope: scope,
|
|
404
|
+
periodScopeField: field,
|
|
405
|
+
dayDocuments: nextDayEntries,
|
|
406
|
+
periodFieldsOfDay,
|
|
407
|
+
});
|
|
408
|
+
const existingDoc = existingEntriesByScope.get(scope + '|' + field) ?? null;
|
|
409
|
+
const keys = Object.keys(sections);
|
|
410
|
+
if (keys.length === 0) {
|
|
411
|
+
if (existingDoc != null)
|
|
412
|
+
staleEntryDocuments.push(existingDoc);
|
|
413
|
+
continue;
|
|
414
|
+
}
|
|
415
|
+
// The watermark MUST advance with the folded days. Inheriting the STORED
|
|
416
|
+
// document watermark would make the folded document look unchanged, and
|
|
417
|
+
// needsMaterializedPrepTimeEntriesWrite would then SKIP the write forever -
|
|
418
|
+
// freezing the period at its first closed day (measured: a month document
|
|
419
|
+
// holding 94 rows where its 30 days totalled 1726).
|
|
420
|
+
let entryWatermark = existingDoc?.source_watermark ?? null;
|
|
421
|
+
for (const dayDoc of nextDayEntries) {
|
|
422
|
+
const fields = periodFieldsOfDay(String(dayDoc.scope_field));
|
|
423
|
+
if (fields == null)
|
|
424
|
+
continue;
|
|
425
|
+
if (fields[scope] !== field)
|
|
426
|
+
continue;
|
|
427
|
+
const time = new Date(dayDoc.source_watermark ?? 0).getTime();
|
|
428
|
+
if (Number.isNaN(time))
|
|
429
|
+
continue;
|
|
430
|
+
if (entryWatermark == null || time > entryWatermark.getTime()) {
|
|
431
|
+
entryWatermark = new Date(time);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
const report = {
|
|
435
|
+
_id: existingDoc?._id ?? new mongoose.Types.ObjectId().toHexString(),
|
|
436
|
+
tenant_id: tenantId,
|
|
437
|
+
brand_id: existingDoc?.brand_id ?? entries[0]?.brand_id ?? '',
|
|
438
|
+
scope_context: scope,
|
|
439
|
+
scope_field: field,
|
|
440
|
+
day_index: null,
|
|
441
|
+
sale_type_key_filters: existingDoc?.sale_type_key_filters ?? entries[0]?.sale_type_key_filters ?? [],
|
|
442
|
+
prep_time_entries: sections,
|
|
443
|
+
iteration: existingDoc?.iteration,
|
|
444
|
+
schema_version: existingDoc?.schema_version ?? 1,
|
|
445
|
+
source_watermark: entryWatermark ?? new Date(computedAt),
|
|
446
|
+
computed_at: computedAt,
|
|
447
|
+
createdAt: existingDoc?.createdAt ?? computedAt,
|
|
448
|
+
updatedAt: computedAt,
|
|
449
|
+
};
|
|
450
|
+
if (existingDoc != null && !needsMaterializedPrepTimeEntriesWrite(existingDoc, report)) {
|
|
451
|
+
skippedEntryDocuments.push(existingDoc);
|
|
452
|
+
continue;
|
|
453
|
+
}
|
|
454
|
+
if (!addEntryWrite(report))
|
|
455
|
+
return null;
|
|
456
|
+
}
|
|
457
|
+
for (const doc of entries) {
|
|
458
|
+
if (doc.scope_context !== 'localDate')
|
|
459
|
+
continue;
|
|
460
|
+
const existingDoc = existingEntriesByScope.get(prepScopeKey(doc)) ?? null;
|
|
461
|
+
if (existingDoc != null && !needsMaterializedPrepTimeEntriesWrite(existingDoc, doc)) {
|
|
462
|
+
skippedEntryDocuments.push(existingDoc);
|
|
463
|
+
continue;
|
|
464
|
+
}
|
|
465
|
+
if (!addEntryWrite(doc))
|
|
466
|
+
return null;
|
|
467
|
+
}
|
|
468
|
+
return {
|
|
469
|
+
writes,
|
|
470
|
+
entryWrites,
|
|
471
|
+
staleDocuments,
|
|
472
|
+
staleEntryDocuments,
|
|
473
|
+
skippedDocuments,
|
|
474
|
+
skippedEntryDocuments,
|
|
475
|
+
};
|
|
476
|
+
}
|