@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
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const materialized_cash_classification_helpers_1 = require("../../helpers/materialized-reports/materialized-cash-classification-helpers");
|
|
4
|
+
/**
|
|
5
|
+
* M3 reconciliation arithmetic.
|
|
6
|
+
*
|
|
7
|
+
* These cases are built from the SOURCE write path, not invented: the close routine
|
|
8
|
+
* (`cash-drawer-sessions.ts`) writes the count-out as a `CASH_OUT` of the COUNTED
|
|
9
|
+
* cash, and sweeps the residual with a `SYSTEM_ADJUSTMENT` - `CASH_IN` when OVER and
|
|
10
|
+
* `CASH_OUT` when SHORT. The float is a `CASH_IN` of the opening amount, and each
|
|
11
|
+
* reopen writes a `CASH_IN` re-baseline of the recounted balance.
|
|
12
|
+
*
|
|
13
|
+
* What is being pinned here is the set of identities the report promises:
|
|
14
|
+
*
|
|
15
|
+
* ledger_net = operator.net + float - countout + reopen + system.net
|
|
16
|
+
* operator.net == sessions.net_movements_amount
|
|
17
|
+
* system.net == -sessions.variance_amount
|
|
18
|
+
*
|
|
19
|
+
* and therefore `ledger_net == 0` for a fully closed drawer-day.
|
|
20
|
+
*/
|
|
21
|
+
const DRAWER = 'DRAWER';
|
|
22
|
+
const ORDER = 'ORDER';
|
|
23
|
+
const EXPENSE = 'EXPENSE';
|
|
24
|
+
const SYSTEM = 'SYSTEM_ADJUSTMENT';
|
|
25
|
+
const CASH_IN = 'CASH_IN';
|
|
26
|
+
const CASH_OUT = 'CASH_OUT';
|
|
27
|
+
let seq = 0;
|
|
28
|
+
const row = (over) => ({
|
|
29
|
+
cash_in_out_id: 'row-' + (seq += 1),
|
|
30
|
+
drawer_balance_before: 0,
|
|
31
|
+
drawer_balance_after: 0,
|
|
32
|
+
staff_id: 'staff-1',
|
|
33
|
+
note: null,
|
|
34
|
+
...over,
|
|
35
|
+
});
|
|
36
|
+
/** Mirrors what the close routine writes, in the order it writes it. */
|
|
37
|
+
function closeRows(expected, counted) {
|
|
38
|
+
const difference = expected - counted;
|
|
39
|
+
const rows = [];
|
|
40
|
+
if (difference < 0) {
|
|
41
|
+
rows.push(row({
|
|
42
|
+
ref_type: SYSTEM,
|
|
43
|
+
type: CASH_IN,
|
|
44
|
+
amount: -difference,
|
|
45
|
+
note: 'System adjustment - drawer closed OVER',
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
rows.push(row({
|
|
49
|
+
ref_type: DRAWER,
|
|
50
|
+
type: CASH_OUT,
|
|
51
|
+
amount: counted,
|
|
52
|
+
note: 'Drawer closed - Day 2026-09-14 (iteration 0)',
|
|
53
|
+
}));
|
|
54
|
+
if (difference > 0) {
|
|
55
|
+
rows.push(row({
|
|
56
|
+
ref_type: SYSTEM,
|
|
57
|
+
type: CASH_OUT,
|
|
58
|
+
amount: difference,
|
|
59
|
+
note: 'System adjustment - drawer closed SHORT',
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
return { difference, rows };
|
|
63
|
+
}
|
|
64
|
+
/** Asserts the three identities for one synthesized day. */
|
|
65
|
+
function assertReconciles(rows, sessions) {
|
|
66
|
+
const acc = (0, materialized_cash_classification_helpers_1.freshCashAccumulator)();
|
|
67
|
+
for (const r of rows)
|
|
68
|
+
(0, materialized_cash_classification_helpers_1.addCashMovement)(acc, r);
|
|
69
|
+
for (const s of sessions)
|
|
70
|
+
(0, materialized_cash_classification_helpers_1.addCashSession)(acc, s);
|
|
71
|
+
const counters = (0, materialized_cash_classification_helpers_1.finalizeCashAccumulator)(acc);
|
|
72
|
+
const m = counters.movements;
|
|
73
|
+
const s = counters.sessions;
|
|
74
|
+
// 1. the fundamental identity, WITH the float and count-out terms.
|
|
75
|
+
const identity = m.operator.net + m.lifecycle.float_amount - m.lifecycle.countout_amount + m.lifecycle.reopen_amount + m.system.net;
|
|
76
|
+
expect(round(m.ledger_net)).toBe(round(identity));
|
|
77
|
+
// 2. the movement-side float must agree with the SESSION-side float. This is what
|
|
78
|
+
// catches a note-less reopen being mislabelled as a float.
|
|
79
|
+
expect(round(m.lifecycle.float_amount)).toBe(round(s.opening_float_amount));
|
|
80
|
+
// 3. the two cross-collection checks.
|
|
81
|
+
expect(round(m.operator.net)).toBe(round(s.net_movements_amount));
|
|
82
|
+
expect(round(m.system.net)).toBe(round(-s.variance_amount));
|
|
83
|
+
// 3. a fully closed drawer-day nets to zero.
|
|
84
|
+
if (s.open_sessions_count === 0 && s.unmatched_close_count === 0) {
|
|
85
|
+
expect(round(m.ledger_net)).toBe(0);
|
|
86
|
+
}
|
|
87
|
+
return counters;
|
|
88
|
+
}
|
|
89
|
+
const round = (value) => {
|
|
90
|
+
// Normalizes -0 to 0: negating a zero variance yields -0, and Object.is(-0, 0)
|
|
91
|
+
// is false, which would fail an otherwise correct implementation.
|
|
92
|
+
const r = Math.round(value * 100) / 100;
|
|
93
|
+
return r === 0 ? 0 : r;
|
|
94
|
+
};
|
|
95
|
+
describe('M3 cash reconciliation', () => {
|
|
96
|
+
it('EXACT close: the ledger nets to zero with no sweep', () => {
|
|
97
|
+
const rows = [
|
|
98
|
+
row({ ref_type: DRAWER, type: CASH_IN, amount: 10000, note: 'Drawer opened - Day 2026-09-14 (iteration 0)' }),
|
|
99
|
+
row({ ref_type: ORDER, type: CASH_IN, amount: 5000 }),
|
|
100
|
+
row({ ref_type: EXPENSE, type: CASH_OUT, amount: 2000 }),
|
|
101
|
+
...closeRows(13000, 13000).rows,
|
|
102
|
+
];
|
|
103
|
+
const counters = assertReconciles(rows, [
|
|
104
|
+
{
|
|
105
|
+
status: 'CLOSED',
|
|
106
|
+
opening: { cash_amount: 10000 },
|
|
107
|
+
net_movements: 3000,
|
|
108
|
+
closing: { expected_cash_amount: 13000, cash_amount: 13000, difference: 0 },
|
|
109
|
+
},
|
|
110
|
+
]);
|
|
111
|
+
expect(counters.movements.system.count).toBe(0);
|
|
112
|
+
expect(counters.movements.operator.net).toBe(3000);
|
|
113
|
+
});
|
|
114
|
+
it('SHORT close: positive difference, swept with a CASH_OUT', () => {
|
|
115
|
+
const { difference, rows: closing } = closeRows(13000, 12000);
|
|
116
|
+
expect(difference).toBe(1000);
|
|
117
|
+
const rows = [
|
|
118
|
+
row({ ref_type: DRAWER, type: CASH_IN, amount: 10000, note: 'Drawer opened' }),
|
|
119
|
+
row({ ref_type: ORDER, type: CASH_IN, amount: 5000 }),
|
|
120
|
+
row({ ref_type: EXPENSE, type: CASH_OUT, amount: 2000 }),
|
|
121
|
+
...closing,
|
|
122
|
+
];
|
|
123
|
+
const counters = assertReconciles(rows, [
|
|
124
|
+
{
|
|
125
|
+
status: 'CLOSED',
|
|
126
|
+
opening: { cash_amount: 10000 },
|
|
127
|
+
net_movements: 3000,
|
|
128
|
+
closing: { expected_cash_amount: 13000, cash_amount: 12000, difference: 1000 },
|
|
129
|
+
},
|
|
130
|
+
]);
|
|
131
|
+
// POSITIVE difference = SHORT, and the sweep is an OUT.
|
|
132
|
+
expect(counters.movements.system.out_amount).toBe(1000);
|
|
133
|
+
expect(counters.movements.system.net).toBe(-1000);
|
|
134
|
+
expect(counters.sessions.variance_positive_count).toBe(1);
|
|
135
|
+
});
|
|
136
|
+
it('OVER close: negative difference, swept with a CASH_IN', () => {
|
|
137
|
+
const { difference, rows: closing } = closeRows(13000, 13500);
|
|
138
|
+
expect(difference).toBe(-500);
|
|
139
|
+
const rows = [
|
|
140
|
+
row({ ref_type: DRAWER, type: CASH_IN, amount: 10000, note: 'Drawer opened' }),
|
|
141
|
+
row({ ref_type: ORDER, type: CASH_IN, amount: 3000 }),
|
|
142
|
+
...closing,
|
|
143
|
+
];
|
|
144
|
+
const counters = assertReconciles(rows, [
|
|
145
|
+
{
|
|
146
|
+
status: 'CLOSED',
|
|
147
|
+
opening: { cash_amount: 10000 },
|
|
148
|
+
net_movements: 3000,
|
|
149
|
+
closing: { expected_cash_amount: 13000, cash_amount: 13500, difference: -500 },
|
|
150
|
+
},
|
|
151
|
+
]);
|
|
152
|
+
expect(counters.movements.system.in_amount).toBe(500);
|
|
153
|
+
expect(counters.sessions.variance_negative_count).toBe(1);
|
|
154
|
+
});
|
|
155
|
+
it('OVER + REOPEN: two lifecycles reconcile, and the float is counted ONCE', () => {
|
|
156
|
+
const first = closeRows(12000, 12000);
|
|
157
|
+
const second = closeRows(8000, 7500);
|
|
158
|
+
const rows = [
|
|
159
|
+
row({ ref_type: DRAWER, type: CASH_IN, amount: 10000, note: 'Drawer opened' }),
|
|
160
|
+
row({ ref_type: ORDER, type: CASH_IN, amount: 2000 }),
|
|
161
|
+
...first.rows,
|
|
162
|
+
// the reopen re-baseline: a CASH_IN of the recounted balance.
|
|
163
|
+
row({
|
|
164
|
+
ref_type: DRAWER,
|
|
165
|
+
type: CASH_IN,
|
|
166
|
+
amount: 12000,
|
|
167
|
+
note: 'Drawer reopened - Day 2026-09-14 (iteration 1)',
|
|
168
|
+
drawer_balance_before: 0,
|
|
169
|
+
}),
|
|
170
|
+
row({ ref_type: EXPENSE, type: CASH_OUT, amount: 4000 }),
|
|
171
|
+
...second.rows,
|
|
172
|
+
];
|
|
173
|
+
const counters = assertReconciles(rows, [
|
|
174
|
+
{
|
|
175
|
+
status: 'CLOSED',
|
|
176
|
+
// preserved across the reopen - so the DAY float is 10000, not 22000.
|
|
177
|
+
opening: { cash_amount: 10000 },
|
|
178
|
+
// NOT reset by the reopen; excludes the float and the re-baseline.
|
|
179
|
+
net_movements: -2000,
|
|
180
|
+
reopened_times: 1,
|
|
181
|
+
closing: { expected_cash_amount: 8000, cash_amount: 7500, difference: 500 },
|
|
182
|
+
},
|
|
183
|
+
]);
|
|
184
|
+
expect(counters.movements.lifecycle.reopen_count).toBe(1);
|
|
185
|
+
expect(counters.movements.lifecycle.reopen_amount).toBe(12000);
|
|
186
|
+
expect(counters.movements.lifecycle.float_count).toBe(1);
|
|
187
|
+
expect(counters.movements.lifecycle.float_amount).toBe(10000);
|
|
188
|
+
expect(counters.sessions.opening_float_amount).toBe(10000);
|
|
189
|
+
expect(counters.sessions.reopened_session_count).toBe(1);
|
|
190
|
+
expect(counters.movements.operator.net).toBe(-2000);
|
|
191
|
+
});
|
|
192
|
+
it('SUMS the variance of EVERY lifecycle of a reopened session', () => {
|
|
193
|
+
// Found by the demo dataset, not by reading the source. A reopened session has two
|
|
194
|
+
// lifecycles and the ledger holds a SWEEP for each, but `closing.difference` only
|
|
195
|
+
// describes the LAST one. Summing just that undercounted the day and broke
|
|
196
|
+
// `system.net == -variance_amount` on every reopened drawer-day (measured 120 vs
|
|
197
|
+
// -300 for a drawer that was 420 OVER then 300 SHORT, netting to 120).
|
|
198
|
+
const acc = (0, materialized_cash_classification_helpers_1.freshCashAccumulator)();
|
|
199
|
+
(0, materialized_cash_classification_helpers_1.addCashSession)(acc, {
|
|
200
|
+
status: 'CLOSED',
|
|
201
|
+
opening: { cash_amount: 10000 },
|
|
202
|
+
net_movements: 0,
|
|
203
|
+
// the FINAL lifecycle: 300 SHORT
|
|
204
|
+
closing: { expected_cash_amount: 10300, cash_amount: 10000, difference: 300 },
|
|
205
|
+
reopened_times: 1,
|
|
206
|
+
// the EARLIER lifecycle, snapshotted: 420 OVER
|
|
207
|
+
reopened_iterations: [{ expected_cash_amount: 9580, cash_amount: 10000, difference: -420 }],
|
|
208
|
+
});
|
|
209
|
+
const counters = (0, materialized_cash_classification_helpers_1.finalizeCashAccumulator)(acc);
|
|
210
|
+
// -420 + 300 = -120, which is what the ledger's sweeps net to.
|
|
211
|
+
expect(counters.sessions.variance_amount).toBe(-120);
|
|
212
|
+
// and both signs are counted, one per lifecycle.
|
|
213
|
+
expect(counters.sessions.variance_positive_count).toBe(1);
|
|
214
|
+
expect(counters.sessions.variance_negative_count).toBe(1);
|
|
215
|
+
// both counts are summed too - the drawer was counted twice that day.
|
|
216
|
+
expect(counters.sessions.expected_close_amount).toBe(19880);
|
|
217
|
+
expect(counters.sessions.counted_close_amount).toBe(20000);
|
|
218
|
+
});
|
|
219
|
+
it('counts an open session as open, not as an integrity problem', () => {
|
|
220
|
+
const acc = (0, materialized_cash_classification_helpers_1.freshCashAccumulator)();
|
|
221
|
+
(0, materialized_cash_classification_helpers_1.addCashSession)(acc, { status: 'IN_USE', opening: { cash_amount: 5000 }, net_movements: 0, closing: null });
|
|
222
|
+
const counters = (0, materialized_cash_classification_helpers_1.finalizeCashAccumulator)(acc);
|
|
223
|
+
expect(counters.sessions.open_sessions_count).toBe(1);
|
|
224
|
+
expect(counters.sessions.unmatched_close_count).toBe(0);
|
|
225
|
+
});
|
|
226
|
+
it('counts a CLOSED session with no closing record as an integrity problem', () => {
|
|
227
|
+
const acc = (0, materialized_cash_classification_helpers_1.freshCashAccumulator)();
|
|
228
|
+
(0, materialized_cash_classification_helpers_1.addCashSession)(acc, { status: 'CLOSED', opening: { cash_amount: 5000 }, net_movements: 0, closing: null });
|
|
229
|
+
const counters = (0, materialized_cash_classification_helpers_1.finalizeCashAccumulator)(acc);
|
|
230
|
+
expect(counters.sessions.unmatched_close_count).toBe(1);
|
|
231
|
+
expect(counters.sessions.open_sessions_count).toBe(0);
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
describe('M3 lifecycle classification', () => {
|
|
235
|
+
it('classifies by note prefix', () => {
|
|
236
|
+
expect((0, materialized_cash_classification_helpers_1.classifyCashMovement)({ ref_type: DRAWER, type: CASH_IN, note: 'Drawer opened - Day x' }).is_opening_float).toBe(true);
|
|
237
|
+
expect((0, materialized_cash_classification_helpers_1.classifyCashMovement)({ ref_type: DRAWER, type: CASH_IN, note: 'Drawer reopened - Day x' }).is_reopen).toBe(true);
|
|
238
|
+
expect((0, materialized_cash_classification_helpers_1.classifyCashMovement)({ ref_type: DRAWER, type: CASH_OUT, note: 'Drawer closed - Day x' }).is_count_out).toBe(true);
|
|
239
|
+
expect((0, materialized_cash_classification_helpers_1.classifyCashMovement)({ ref_type: SYSTEM, type: CASH_IN, note: 'System adjustment - x' }).is_system_adjustment).toBe(true);
|
|
240
|
+
});
|
|
241
|
+
it('treats ordinary movements as operator movement', () => {
|
|
242
|
+
for (const ref of [ORDER, EXPENSE, 'NONE']) {
|
|
243
|
+
const p = (0, materialized_cash_classification_helpers_1.classifyCashMovement)({ ref_type: ref, type: CASH_IN, note: null, drawer_balance_before: 500 });
|
|
244
|
+
expect(p.is_operator).toBe(true);
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
it('FALLS BACK to the balance shape when the note is missing', () => {
|
|
248
|
+
// A lifecycle cash-in always opens from zero; an operator cash-in never does.
|
|
249
|
+
const floatLike = (0, materialized_cash_classification_helpers_1.classifyCashMovement)({ ref_type: DRAWER, type: CASH_IN, note: null, drawer_balance_before: 0 });
|
|
250
|
+
expect(floatLike.is_opening_float).toBe(true);
|
|
251
|
+
expect(floatLike.is_operator).toBe(false);
|
|
252
|
+
const operatorLike = (0, materialized_cash_classification_helpers_1.classifyCashMovement)({
|
|
253
|
+
ref_type: DRAWER,
|
|
254
|
+
type: CASH_IN,
|
|
255
|
+
note: null,
|
|
256
|
+
drawer_balance_before: 900,
|
|
257
|
+
});
|
|
258
|
+
expect(operatorLike.is_operator).toBe(true);
|
|
259
|
+
});
|
|
260
|
+
it('does NOT double-count a row seen twice', () => {
|
|
261
|
+
const acc = (0, materialized_cash_classification_helpers_1.freshCashAccumulator)();
|
|
262
|
+
const r = row({ ref_type: ORDER, type: CASH_IN, amount: 700 });
|
|
263
|
+
expect((0, materialized_cash_classification_helpers_1.addCashMovement)(acc, r)).toBe(true);
|
|
264
|
+
expect((0, materialized_cash_classification_helpers_1.addCashMovement)(acc, r)).toBe(false);
|
|
265
|
+
expect((0, materialized_cash_classification_helpers_1.finalizeCashAccumulator)(acc).movements.in_amount).toBe(700);
|
|
266
|
+
});
|
|
267
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const materialized_delivery_classification_helpers_1 = require("../../helpers/materialized-reports/materialized-delivery-classification-helpers");
|
|
4
|
+
/**
|
|
5
|
+
* M4 delivery accumulation.
|
|
6
|
+
*
|
|
7
|
+
* ADOPTION IS THE POINT. The `deliveries` collection is rider-app-only, so for a tenant
|
|
8
|
+
* that does not use the app it is EMPTY - and an empty collection reads as "no
|
|
9
|
+
* deliveries" rather than "no visibility". The counters must therefore carry the
|
|
10
|
+
* ORDER population from the orders stage beside the delivery population, and derive the
|
|
11
|
+
* gap as the pool the app can win. These tests pin exactly that, plus the reassignment
|
|
12
|
+
* case a naive count would get wrong.
|
|
13
|
+
*/
|
|
14
|
+
const order = (id, over = {}) => ({
|
|
15
|
+
_id: id,
|
|
16
|
+
createdAt: new Date('2026-09-14T10:00:00.000Z'),
|
|
17
|
+
net_sale_amount: 5000,
|
|
18
|
+
amount_collected: 5000,
|
|
19
|
+
delivery_details: { delivery_charge: 300 },
|
|
20
|
+
localDate: '2026-09-14',
|
|
21
|
+
...over,
|
|
22
|
+
});
|
|
23
|
+
const delivery = (over = {}) => ({
|
|
24
|
+
_id: 'delivery-1',
|
|
25
|
+
order_id: 'order-1',
|
|
26
|
+
rider_id: 'rider-1',
|
|
27
|
+
rider_name: 'Sam',
|
|
28
|
+
status: 'COMPLETED',
|
|
29
|
+
createdAt: new Date('2026-09-14T10:05:00.000Z'),
|
|
30
|
+
updatedAt: new Date('2026-09-14T10:35:00.000Z'),
|
|
31
|
+
delivered_at: null,
|
|
32
|
+
distance_in_meters_from_store: 3000,
|
|
33
|
+
rider_revenue: 700,
|
|
34
|
+
tracking_enabled: false,
|
|
35
|
+
localHour: 10,
|
|
36
|
+
...over,
|
|
37
|
+
});
|
|
38
|
+
const KEY = 'POS_WALK-IN:Istanbul';
|
|
39
|
+
describe('M4 key grammar', () => {
|
|
40
|
+
it('round-trips platform:city', () => {
|
|
41
|
+
expect((0, materialized_delivery_classification_helpers_1.buildMaterializedDeliveryKey)('POS', 'Istanbul')).toBe('POS:Istanbul');
|
|
42
|
+
expect((0, materialized_delivery_classification_helpers_1.parseMaterializedDeliveryKey)('POS:Istanbul')).toEqual({ platform: 'POS', city: 'Istanbul' });
|
|
43
|
+
});
|
|
44
|
+
it('falls back to UNKNOWN rather than dropping a row with no dimension', () => {
|
|
45
|
+
expect((0, materialized_delivery_classification_helpers_1.buildMaterializedDeliveryKey)(null, 'Istanbul')).toBe('UNKNOWN:Istanbul');
|
|
46
|
+
expect((0, materialized_delivery_classification_helpers_1.buildMaterializedDeliveryKey)('POS', '')).toBe('POS:UNKNOWN');
|
|
47
|
+
expect((0, materialized_delivery_classification_helpers_1.buildMaterializedDeliveryKey)(undefined, undefined)).toBe('UNKNOWN:UNKNOWN');
|
|
48
|
+
});
|
|
49
|
+
it('never lets the separator inside a component', () => {
|
|
50
|
+
const key = (0, materialized_delivery_classification_helpers_1.buildMaterializedDeliveryKey)('PO:S', 'Is:tanbul');
|
|
51
|
+
expect((0, materialized_delivery_classification_helpers_1.parseMaterializedDeliveryKey)(key)).toEqual({ platform: 'PO-S', city: 'Is-tanbul' });
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
describe('M4 adoption', () => {
|
|
55
|
+
it('counts off-app orders as the pool to win, not as an error', () => {
|
|
56
|
+
const acc = (0, materialized_delivery_classification_helpers_1.freshDeliveryAccumulator)();
|
|
57
|
+
// THREE delivery orders, but the rider app only saw one of them.
|
|
58
|
+
(0, materialized_delivery_classification_helpers_1.addDeliveryOrder)(acc, order('order-1'));
|
|
59
|
+
(0, materialized_delivery_classification_helpers_1.addDeliveryOrder)(acc, order('order-2'));
|
|
60
|
+
(0, materialized_delivery_classification_helpers_1.addDeliveryOrder)(acc, order('order-3'));
|
|
61
|
+
(0, materialized_delivery_classification_helpers_1.addDelivery)(acc, delivery({ order_id: 'order-1' }), order('order-1'), KEY);
|
|
62
|
+
const counters = (0, materialized_delivery_classification_helpers_1.finalizeDeliveryAccumulator)(acc);
|
|
63
|
+
expect(counters.adoption.delivery_order_count).toBe(3);
|
|
64
|
+
expect(counters.adoption.delivered_via_app_count).toBe(1);
|
|
65
|
+
expect(counters.adoption.off_app_count).toBe(2);
|
|
66
|
+
});
|
|
67
|
+
it('counts a REASSIGNED order once, however many deliveries it has', () => {
|
|
68
|
+
const acc = (0, materialized_delivery_classification_helpers_1.freshDeliveryAccumulator)();
|
|
69
|
+
(0, materialized_delivery_classification_helpers_1.addDeliveryOrder)(acc, order('order-1'));
|
|
70
|
+
// the same order, two riders - two ATTEMPTS, one ORDER.
|
|
71
|
+
(0, materialized_delivery_classification_helpers_1.addDelivery)(acc, delivery({ _id: 'd-1', rider_id: 'rider-1', status: 'CANCELLED' }), order('order-1'), KEY);
|
|
72
|
+
(0, materialized_delivery_classification_helpers_1.addDelivery)(acc, delivery({ _id: 'd-2', rider_id: 'rider-2', status: 'COMPLETED' }), order('order-1'), KEY);
|
|
73
|
+
const counters = (0, materialized_delivery_classification_helpers_1.finalizeDeliveryAccumulator)(acc);
|
|
74
|
+
expect(counters.deliveries.count).toBe(2);
|
|
75
|
+
expect(counters.adoption.delivery_order_count).toBe(1);
|
|
76
|
+
// NOT off-app: the order DID reach the app, just twice.
|
|
77
|
+
expect(counters.adoption.off_app_count).toBe(0);
|
|
78
|
+
expect(counters.adoption.delivered_via_app_count).toBe(1);
|
|
79
|
+
});
|
|
80
|
+
it('does not claim adoption for a delivery whose order was never staged', () => {
|
|
81
|
+
const acc = (0, materialized_delivery_classification_helpers_1.freshDeliveryAccumulator)();
|
|
82
|
+
// no addDeliveryOrder call: the order is outside the staged scope.
|
|
83
|
+
(0, materialized_delivery_classification_helpers_1.addDelivery)(acc, delivery({ order_id: 'order-outside' }), null, KEY);
|
|
84
|
+
const counters = (0, materialized_delivery_classification_helpers_1.finalizeDeliveryAccumulator)(acc);
|
|
85
|
+
expect(counters.deliveries.count).toBe(1);
|
|
86
|
+
expect(counters.adoption.delivery_order_count).toBe(0);
|
|
87
|
+
expect(counters.adoption.delivered_via_app_count).toBe(0);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
describe('M4 accumulation', () => {
|
|
91
|
+
it('buckets distance and totals it', () => {
|
|
92
|
+
const acc = (0, materialized_delivery_classification_helpers_1.freshDeliveryAccumulator)();
|
|
93
|
+
(0, materialized_delivery_classification_helpers_1.addDelivery)(acc, delivery({ _id: 'a', distance_in_meters_from_store: 1500 }), null, KEY);
|
|
94
|
+
(0, materialized_delivery_classification_helpers_1.addDelivery)(acc, delivery({ _id: 'b', distance_in_meters_from_store: 3000 }), null, KEY);
|
|
95
|
+
(0, materialized_delivery_classification_helpers_1.addDelivery)(acc, delivery({ _id: 'c', distance_in_meters_from_store: 26000 }), null, KEY);
|
|
96
|
+
const counters = (0, materialized_delivery_classification_helpers_1.finalizeDeliveryAccumulator)(acc);
|
|
97
|
+
expect(counters.distance.sum_meters).toBe(30500);
|
|
98
|
+
expect(counters.distance.count).toBe(3);
|
|
99
|
+
expect(counters.distance.under_2km).toBe(1);
|
|
100
|
+
expect(counters.distance.between_2_5km).toBe(1);
|
|
101
|
+
expect(counters.distance.over_25km).toBe(1);
|
|
102
|
+
});
|
|
103
|
+
it('places a bucket boundary in the UPPER bucket', () => {
|
|
104
|
+
// inclusive lower, EXCLUSIVE upper.
|
|
105
|
+
expect((0, materialized_delivery_classification_helpers_1.deliveryDistanceBucketKey)(2000)).toBe('between_2_5km');
|
|
106
|
+
expect((0, materialized_delivery_classification_helpers_1.deliveryDistanceBucketKey)(1999)).toBe('under_2km');
|
|
107
|
+
expect((0, materialized_delivery_classification_helpers_1.deliveryDistanceBucketKey)(25000)).toBe('over_25km');
|
|
108
|
+
});
|
|
109
|
+
it('builds the rider leaderboard and the area hour heat map', () => {
|
|
110
|
+
const acc = (0, materialized_delivery_classification_helpers_1.freshDeliveryAccumulator)();
|
|
111
|
+
(0, materialized_delivery_classification_helpers_1.addDelivery)(acc, delivery({ _id: 'a', localHour: 10 }), null, KEY);
|
|
112
|
+
(0, materialized_delivery_classification_helpers_1.addDelivery)(acc, delivery({ _id: 'b', localHour: 10 }), null, KEY);
|
|
113
|
+
(0, materialized_delivery_classification_helpers_1.addDelivery)(acc, delivery({ _id: 'c', localHour: 14 }), null, 'POS:Ankara');
|
|
114
|
+
const counters = (0, materialized_delivery_classification_helpers_1.finalizeDeliveryAccumulator)(acc);
|
|
115
|
+
expect(counters.riders['rider-1'].count).toBe(3);
|
|
116
|
+
expect(counters.riders['rider-1'].rider_revenue_amount).toBe(2100);
|
|
117
|
+
// areas are keyed by CITY from the JOINED key.
|
|
118
|
+
expect(counters.areas['Istanbul'].by_hour['10']).toBe(2);
|
|
119
|
+
expect(counters.areas['Ankara'].by_hour['14']).toBe(1);
|
|
120
|
+
expect(counters.areas['Istanbul'].count).toBe(2);
|
|
121
|
+
});
|
|
122
|
+
it('marks a proxy completion as NOT exact, and an explicit one as exact', () => {
|
|
123
|
+
const proxy = (0, materialized_delivery_classification_helpers_1.freshDeliveryAccumulator)();
|
|
124
|
+
// delivered_at null -> falls back to updatedAt, which moves on ANY later mutation.
|
|
125
|
+
(0, materialized_delivery_classification_helpers_1.addDelivery)(proxy, delivery({ delivered_at: null }), order('order-1'), KEY);
|
|
126
|
+
const proxyCounters = (0, materialized_delivery_classification_helpers_1.finalizeDeliveryAccumulator)(proxy);
|
|
127
|
+
expect(proxyCounters.timing.graded_count).toBe(1);
|
|
128
|
+
expect(proxyCounters.timing.complete_sum_minutes).toBe(30);
|
|
129
|
+
expect(proxyCounters.timing.exact_completion_count).toBe(0);
|
|
130
|
+
const exact = (0, materialized_delivery_classification_helpers_1.freshDeliveryAccumulator)();
|
|
131
|
+
(0, materialized_delivery_classification_helpers_1.addDelivery)(exact, delivery({ delivered_at: new Date('2026-09-14T10:32:00.000Z') }), order('order-1'), KEY);
|
|
132
|
+
const exactCounters = (0, materialized_delivery_classification_helpers_1.finalizeDeliveryAccumulator)(exact);
|
|
133
|
+
expect(exactCounters.timing.complete_sum_minutes).toBe(27);
|
|
134
|
+
expect(exactCounters.timing.exact_completion_count).toBe(1);
|
|
135
|
+
});
|
|
136
|
+
it('counts order money from the join, and a cancelled delivery keeps it', () => {
|
|
137
|
+
const acc = (0, materialized_delivery_classification_helpers_1.freshDeliveryAccumulator)();
|
|
138
|
+
(0, materialized_delivery_classification_helpers_1.addDeliveryOrder)(acc, order('order-1'));
|
|
139
|
+
(0, materialized_delivery_classification_helpers_1.addDelivery)(acc, delivery({ status: 'CANCELLED', cancel_reason: 'no answer' }), order('order-1'), KEY);
|
|
140
|
+
const counters = (0, materialized_delivery_classification_helpers_1.finalizeDeliveryAccumulator)(acc);
|
|
141
|
+
expect(counters.deliveries.cancelled_count).toBe(1);
|
|
142
|
+
expect(counters.deliveries.cancel_reason_count).toBe(1);
|
|
143
|
+
expect(counters.money.net_sale_amount).toBe(5000);
|
|
144
|
+
expect(counters.money.delivery_charge_amount).toBe(300);
|
|
145
|
+
expect(counters.money.delivery_charge_count).toBe(1);
|
|
146
|
+
});
|
|
147
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const materialized_delivery_compile_helpers_1 = require("../../helpers/materialized-reports/materialized-delivery-compile-helpers");
|
|
4
|
+
/**
|
|
5
|
+
* M4 day compile.
|
|
6
|
+
*
|
|
7
|
+
* The case that defines this report: a tenant that does NOT use the rider app produces
|
|
8
|
+
* delivery ORDERS and ZERO deliveries. If the compile treated an empty deliveries set as
|
|
9
|
+
* an empty day, that tenant would see NOTHING - when the truthful answer is "every order
|
|
10
|
+
* was off-app", which is the most important thing the page can tell them.
|
|
11
|
+
*/
|
|
12
|
+
const TENANT = 'tenant-1';
|
|
13
|
+
const BRAND = 'brand-1';
|
|
14
|
+
const DAY = '2026-09-14';
|
|
15
|
+
const order = (id, over = {}) => ({
|
|
16
|
+
_id: id,
|
|
17
|
+
tenant_id: TENANT,
|
|
18
|
+
platform: 'POS_WALK-IN',
|
|
19
|
+
order_number: 100,
|
|
20
|
+
createdAt: new Date('2026-09-14T10:00:00.000Z'),
|
|
21
|
+
net_sale_amount: 5000,
|
|
22
|
+
amount_collected: 5000,
|
|
23
|
+
delivery_details: { city: 'Istanbul', state: 'Istanbul', delivery_cost: 300 },
|
|
24
|
+
localDate: DAY,
|
|
25
|
+
...over,
|
|
26
|
+
});
|
|
27
|
+
const delivery = (over = {}) => ({
|
|
28
|
+
_id: 'd-1',
|
|
29
|
+
tenant_id: TENANT,
|
|
30
|
+
order_id: 'order-1',
|
|
31
|
+
rider_id: 'rider-1',
|
|
32
|
+
rider_name: 'Sam',
|
|
33
|
+
status: 'COMPLETED',
|
|
34
|
+
createdAt: new Date('2026-09-14T10:05:00.000Z'),
|
|
35
|
+
updatedAt: new Date('2026-09-14T10:35:00.000Z'),
|
|
36
|
+
delivered_at: new Date('2026-09-14T10:32:00.000Z'),
|
|
37
|
+
distance_in_meters_from_store: 3000,
|
|
38
|
+
rider_revenue: 700,
|
|
39
|
+
polyline: [
|
|
40
|
+
[1, 2],
|
|
41
|
+
[3, 4],
|
|
42
|
+
],
|
|
43
|
+
localHour: 10,
|
|
44
|
+
localDate: DAY,
|
|
45
|
+
...over,
|
|
46
|
+
});
|
|
47
|
+
const compile = (over = {}) => (0, materialized_delivery_compile_helpers_1.compileTenantDeliveryReports)({
|
|
48
|
+
tenantId: TENANT,
|
|
49
|
+
brandId: BRAND,
|
|
50
|
+
localDate: DAY,
|
|
51
|
+
orders: [],
|
|
52
|
+
deliveries: [],
|
|
53
|
+
computedAt: new Date('2026-09-14T23:00:00.000Z'),
|
|
54
|
+
...over,
|
|
55
|
+
});
|
|
56
|
+
describe('M4 day compile', () => {
|
|
57
|
+
it('returns null only when there is NEITHER an order NOR a delivery', () => {
|
|
58
|
+
expect(compile()).toBeNull();
|
|
59
|
+
expect(compile({ orders: [order('o')] })).not.toBeNull();
|
|
60
|
+
expect(compile({ deliveries: [delivery()] })).not.toBeNull();
|
|
61
|
+
expect((0, materialized_delivery_compile_helpers_1.compileTenantDeliveryReports)(null)).toBeNull();
|
|
62
|
+
expect(compile({ tenantId: '' })).toBeNull();
|
|
63
|
+
});
|
|
64
|
+
it('reports an adoption-POOR day: orders, no deliveries', () => {
|
|
65
|
+
const compiled = compile({ orders: [order('o1'), order('o2')] });
|
|
66
|
+
const counters = compiled.reports[0].delivery_counters['POS_WALK-IN:Istanbul'];
|
|
67
|
+
expect(counters.adoption.delivery_order_count).toBe(2);
|
|
68
|
+
expect(counters.adoption.delivered_via_app_count).toBe(0);
|
|
69
|
+
// the app has won NOTHING yet - the pool is the whole day.
|
|
70
|
+
expect(counters.adoption.off_app_count).toBe(2);
|
|
71
|
+
expect(counters.deliveries.count).toBe(0);
|
|
72
|
+
// and the entries document carries the count, because off-app orders are not rows.
|
|
73
|
+
expect(compiled.entries[0].off_app_order_count).toBe(2);
|
|
74
|
+
expect(compiled.entries[0].delivery_entries).toBeNull();
|
|
75
|
+
});
|
|
76
|
+
it('reports an adoption-RICH day', () => {
|
|
77
|
+
const compiled = compile({
|
|
78
|
+
orders: [order('o1'), order('o2')],
|
|
79
|
+
deliveries: [delivery({ _id: 'd1', order_id: 'o1' }), delivery({ _id: 'd2', order_id: 'o2' })],
|
|
80
|
+
});
|
|
81
|
+
const counters = compiled.reports[0].delivery_counters['POS_WALK-IN:Istanbul'];
|
|
82
|
+
expect(counters.adoption.delivery_order_count).toBe(2);
|
|
83
|
+
expect(counters.adoption.delivered_via_app_count).toBe(2);
|
|
84
|
+
expect(counters.adoption.off_app_count).toBe(0);
|
|
85
|
+
expect(compiled.entries[0].off_app_order_count).toBe(0);
|
|
86
|
+
});
|
|
87
|
+
it('keys a delivery on its ORDER, not on the delivery', () => {
|
|
88
|
+
const compiled = compile({
|
|
89
|
+
orders: [order('o1', { platform: 'DELIVEROO', delivery_details: { city: 'Ankara', delivery_cost: 500 } })],
|
|
90
|
+
deliveries: [delivery({ order_id: 'o1' })],
|
|
91
|
+
});
|
|
92
|
+
expect(Object.keys(compiled.reports[0].delivery_counters)).toEqual(['DELIVEROO:Ankara']);
|
|
93
|
+
});
|
|
94
|
+
it('puts a delivery with an unstaged order in UNKNOWN rather than dropping it', () => {
|
|
95
|
+
const compiled = compile({ deliveries: [delivery({ order_id: 'not-staged' })] });
|
|
96
|
+
const keys = Object.keys(compiled.reports[0].delivery_counters);
|
|
97
|
+
expect(keys).toEqual(['UNKNOWN:UNKNOWN']);
|
|
98
|
+
// it is a real row a rider performed, so it counts as a delivery...
|
|
99
|
+
expect(compiled.reports[0].delivery_counters['UNKNOWN:UNKNOWN'].deliveries.count).toBe(1);
|
|
100
|
+
// ...but it cannot claim adoption for an order we never staged.
|
|
101
|
+
expect(compiled.reports[0].delivery_counters['UNKNOWN:UNKNOWN'].adoption.delivery_order_count).toBe(0);
|
|
102
|
+
});
|
|
103
|
+
it('builds statement rows with the joined order fields', () => {
|
|
104
|
+
const compiled = compile({
|
|
105
|
+
orders: [order('o1')],
|
|
106
|
+
deliveries: [delivery({ order_id: 'o1' })],
|
|
107
|
+
});
|
|
108
|
+
const rows = Object.values(compiled.entries[0].delivery_entries).flatMap((section) => section.rows);
|
|
109
|
+
expect(rows).toHaveLength(1);
|
|
110
|
+
const row = rows[0];
|
|
111
|
+
expect(row.order_id).toBe('o1');
|
|
112
|
+
expect(row.city).toBe('Istanbul');
|
|
113
|
+
expect(row.platform).toBe('POS_WALK-IN');
|
|
114
|
+
expect(row.net_sale_amount).toBe(5000);
|
|
115
|
+
expect(row.delivery_charge).toBe(300);
|
|
116
|
+
// the trace itself is NOT stored - only its size.
|
|
117
|
+
expect(row.polyline_point_count).toBe(2);
|
|
118
|
+
expect(row.completion_is_exact).toBe(true);
|
|
119
|
+
expect(row.complete_minutes).toBe(27);
|
|
120
|
+
});
|
|
121
|
+
it('aggregates the captured stage timings, churn and order economics', () => {
|
|
122
|
+
const compiled = compile({
|
|
123
|
+
orders: [
|
|
124
|
+
order('o1', {
|
|
125
|
+
tip_amount: 500,
|
|
126
|
+
total_discount_applied: 200,
|
|
127
|
+
amount_refunded: 100,
|
|
128
|
+
gst_amount: 300,
|
|
129
|
+
tax_amount: 100,
|
|
130
|
+
delivery_details: {
|
|
131
|
+
city: 'Istanbul',
|
|
132
|
+
state: 'Istanbul',
|
|
133
|
+
delivery_cost: 300,
|
|
134
|
+
estimated_delivery_time: new Date('2026-09-14T10:30:00.000Z'),
|
|
135
|
+
},
|
|
136
|
+
}),
|
|
137
|
+
],
|
|
138
|
+
deliveries: [
|
|
139
|
+
delivery({
|
|
140
|
+
order_id: 'o1',
|
|
141
|
+
assigned_at: new Date('2026-09-14T10:07:00.000Z'),
|
|
142
|
+
picked_up_at: new Date('2026-09-14T10:15:00.000Z'),
|
|
143
|
+
delivered_at: new Date('2026-09-14T10:32:00.000Z'),
|
|
144
|
+
status_updated_count: 3,
|
|
145
|
+
}),
|
|
146
|
+
],
|
|
147
|
+
});
|
|
148
|
+
const counters = compiled.reports[0].delivery_counters['POS_WALK-IN:Istanbul'];
|
|
149
|
+
expect(counters.money.tip_amount).toBe(500);
|
|
150
|
+
expect(counters.money.discount_amount).toBe(200);
|
|
151
|
+
expect(counters.money.refund_amount).toBe(100);
|
|
152
|
+
expect(counters.money.tax_amount).toBe(400);
|
|
153
|
+
expect(counters.timing).toMatchObject({
|
|
154
|
+
assignment_sum_minutes: 2,
|
|
155
|
+
assignment_count: 1,
|
|
156
|
+
pickup_wait_sum_minutes: 8,
|
|
157
|
+
pickup_wait_count: 1,
|
|
158
|
+
transit_sum_minutes: 17,
|
|
159
|
+
transit_count: 1,
|
|
160
|
+
promise_known_count: 1,
|
|
161
|
+
on_time_count: 0,
|
|
162
|
+
late_count: 1,
|
|
163
|
+
late_minutes_sum: 2,
|
|
164
|
+
status_updates_sum: 3,
|
|
165
|
+
status_updates_count: 1,
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
it('prefers the frozen delivery promise over the order ETA', () => {
|
|
169
|
+
const compiled = compile({
|
|
170
|
+
orders: [
|
|
171
|
+
order('o1', {
|
|
172
|
+
delivery_details: {
|
|
173
|
+
city: 'Istanbul',
|
|
174
|
+
state: 'Istanbul',
|
|
175
|
+
delivery_cost: 300,
|
|
176
|
+
estimated_delivery_time: new Date('2026-09-14T10:30:00.000Z'),
|
|
177
|
+
},
|
|
178
|
+
}),
|
|
179
|
+
],
|
|
180
|
+
deliveries: [
|
|
181
|
+
delivery({
|
|
182
|
+
order_id: 'o1',
|
|
183
|
+
expected_delivery_at: new Date('2026-09-14T10:40:00.000Z'),
|
|
184
|
+
delivered_at: new Date('2026-09-14T10:32:00.000Z'),
|
|
185
|
+
}),
|
|
186
|
+
],
|
|
187
|
+
});
|
|
188
|
+
const timing = compiled.reports[0].delivery_counters['POS_WALK-IN:Istanbul'].timing;
|
|
189
|
+
expect(timing.promise_known_count).toBe(1);
|
|
190
|
+
expect(timing.on_time_count).toBe(1);
|
|
191
|
+
expect(timing.late_count).toBe(0);
|
|
192
|
+
});
|
|
193
|
+
it('does not expose a pending rider estimate in the statement row', () => {
|
|
194
|
+
const snapshot = (status) => ({
|
|
195
|
+
amount: 900,
|
|
196
|
+
status,
|
|
197
|
+
rule_type: 'DISTANCE_ONE_WAY',
|
|
198
|
+
per_meter: 5000,
|
|
199
|
+
distance_step: 1000,
|
|
200
|
+
distance_meters: 3000,
|
|
201
|
+
delivery_charge: 0,
|
|
202
|
+
calculated_at: null,
|
|
203
|
+
version: 1,
|
|
204
|
+
});
|
|
205
|
+
const rowFor = (status) => {
|
|
206
|
+
const compiled = compile({
|
|
207
|
+
deliveries: [delivery({ rider_revenue: 900, rider_earnings: snapshot(status) })],
|
|
208
|
+
});
|
|
209
|
+
return Object.values(compiled.entries[0].delivery_entries).flatMap((section) => section.rows)[0];
|
|
210
|
+
};
|
|
211
|
+
expect(rowFor('PENDING').rider_revenue).toBeNull();
|
|
212
|
+
expect(rowFor('FINAL').rider_revenue).toBe(900);
|
|
213
|
+
});
|
|
214
|
+
it('counts only FINAL rider payouts, never a pending estimate', () => {
|
|
215
|
+
const snapshot = (status) => ({
|
|
216
|
+
amount: 900,
|
|
217
|
+
status,
|
|
218
|
+
rule_type: 'DISTANCE_ONE_WAY',
|
|
219
|
+
per_meter: 5000,
|
|
220
|
+
distance_step: 1000,
|
|
221
|
+
distance_meters: 3000,
|
|
222
|
+
delivery_charge: 0,
|
|
223
|
+
calculated_at: null,
|
|
224
|
+
version: 1,
|
|
225
|
+
});
|
|
226
|
+
const pending = compile({
|
|
227
|
+
deliveries: [delivery({ rider_revenue: 900, rider_earnings: snapshot('PENDING') })],
|
|
228
|
+
});
|
|
229
|
+
expect(Object.values(pending.reports[0].delivery_counters)[0].money.rider_revenue_amount).toBe(0);
|
|
230
|
+
const final = compile({
|
|
231
|
+
deliveries: [delivery({ rider_revenue: 900, rider_earnings: snapshot('FINAL') })],
|
|
232
|
+
});
|
|
233
|
+
expect(Object.values(final.reports[0].delivery_counters)[0].money.rider_revenue_amount).toBe(900);
|
|
234
|
+
});
|
|
235
|
+
it('never lets a FOREIGN tenant into the documents', () => {
|
|
236
|
+
const compiled = compile({
|
|
237
|
+
orders: [order('o1'), order('o2', { tenant_id: 'someone-else' })],
|
|
238
|
+
});
|
|
239
|
+
expect(compiled.reports[0].delivery_counters['POS_WALK-IN:Istanbul'].adoption.delivery_order_count).toBe(1);
|
|
240
|
+
});
|
|
241
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|