@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.
Files changed (333) hide show
  1. package/esm/constants/MATERIALIZED_REPORTS.js +448 -0
  2. package/esm/helpers/index.js +3 -0
  3. package/esm/helpers/materialized-reports/index.js +32 -0
  4. package/esm/helpers/materialized-reports/materialized-cash-accumulator-helpers.js +114 -0
  5. package/esm/helpers/materialized-reports/materialized-cash-classification-helpers.js +286 -0
  6. package/esm/helpers/materialized-reports/materialized-cash-close-day-helpers.js +396 -0
  7. package/esm/helpers/materialized-reports/materialized-cash-compile-helpers.js +244 -0
  8. package/esm/helpers/materialized-reports/materialized-delivery-accumulator-helpers.js +170 -0
  9. package/esm/helpers/materialized-reports/materialized-delivery-classification-helpers.js +426 -0
  10. package/esm/helpers/materialized-reports/materialized-delivery-close-day-helpers.js +372 -0
  11. package/esm/helpers/materialized-reports/materialized-delivery-compile-helpers.js +214 -0
  12. package/esm/helpers/materialized-reports/materialized-discount-accumulator-helpers.js +318 -0
  13. package/esm/helpers/materialized-reports/materialized-discount-classification-helpers.js +213 -0
  14. package/esm/helpers/materialized-reports/materialized-discount-close-day-helpers.js +604 -0
  15. package/esm/helpers/materialized-reports/materialized-discount-compile-helpers.js +186 -0
  16. package/esm/helpers/materialized-reports/materialized-hourly-comparison-close-day-helpers.js +155 -0
  17. package/esm/helpers/materialized-reports/materialized-hourly-comparison-compile-helpers.js +199 -0
  18. package/esm/helpers/materialized-reports/materialized-hourly-comparison-selection-helpers.js +111 -0
  19. package/esm/helpers/materialized-reports/materialized-payments-comparison-accumulator-helpers.js +88 -0
  20. package/esm/helpers/materialized-reports/materialized-payments-comparison-close-day-helpers.js +394 -0
  21. package/esm/helpers/materialized-reports/materialized-payments-comparison-compile-helpers.js +167 -0
  22. package/esm/helpers/materialized-reports/materialized-prep-time-classification-helpers.js +215 -0
  23. package/esm/helpers/materialized-reports/materialized-prep-time-close-day-helpers.js +476 -0
  24. package/esm/helpers/materialized-reports/materialized-prep-time-compile-helpers.js +201 -0
  25. package/esm/helpers/materialized-reports/materialized-reports-selection-helpers.js +7 -0
  26. package/esm/helpers/materialized-reports/materialized-sales-comparison-accumulator-helpers.js +189 -0
  27. package/esm/helpers/materialized-reports/materialized-sales-comparison-baseline-helpers.js +157 -0
  28. package/esm/helpers/materialized-reports/materialized-sales-comparison-close-day-helpers.js +588 -0
  29. package/esm/helpers/materialized-reports/materialized-sales-comparison-compile-helpers.js +175 -0
  30. package/esm/helpers/materialized-reports/tenant-cash-in-out-formatter.js +156 -0
  31. package/esm/helpers/materialized-reports/tenant-delivery-formatter.js +230 -0
  32. package/esm/helpers/materialized-reports/tenant-discount-formatter.js +427 -0
  33. package/esm/helpers/materialized-reports/tenant-hourly-comparison-formatter.js +237 -0
  34. package/esm/helpers/materialized-reports/tenant-payments-comparison-formatter.js +279 -0
  35. package/esm/helpers/materialized-reports/tenant-prep-time-formatter.js +228 -0
  36. package/esm/helpers/materialized-reports/tenant-sales-comparison-formatter.js +343 -0
  37. package/esm/helpers/reporting-contract/index.js +2 -0
  38. package/esm/helpers/reporting-contract/overview-contract.js +122 -0
  39. package/esm/helpers/reporting-contract/report-contract.js +228 -0
  40. package/esm/helpers/rider-earnings/index.js +1 -0
  41. package/esm/helpers/rider-earnings/rider-earnings.js +59 -0
  42. package/esm/helpers/rider-reports/index.js +2 -0
  43. package/esm/helpers/rider-reports/rider-daily-report.js +90 -0
  44. package/esm/helpers/rider-reports/rider-report.js +67 -0
  45. package/esm/schemas/models/deliveries.js +75 -0
  46. package/esm/schemas/models/index.js +15 -0
  47. package/esm/schemas/models/materialized_rider_daily_reports.js +39 -0
  48. package/esm/schemas/models/materialized_tenant_cash_entries.js +95 -0
  49. package/esm/schemas/models/materialized_tenant_cash_reports.js +77 -0
  50. package/esm/schemas/models/materialized_tenant_delivery_entries.js +63 -0
  51. package/esm/schemas/models/materialized_tenant_delivery_reports.js +63 -0
  52. package/esm/schemas/models/materialized_tenant_discount_entries.js +156 -0
  53. package/esm/schemas/models/materialized_tenant_discount_reports.js +333 -0
  54. package/esm/schemas/models/materialized_tenant_hourly_comparison_entries.js +87 -0
  55. package/esm/schemas/models/materialized_tenant_hourly_comparison_reports.js +99 -0
  56. package/esm/schemas/models/materialized_tenant_payments_comparison_entries.js +71 -0
  57. package/esm/schemas/models/materialized_tenant_payments_comparison_reports.js +76 -0
  58. package/esm/schemas/models/materialized_tenant_prep_time_entries.js +130 -0
  59. package/esm/schemas/models/materialized_tenant_prep_time_reports.js +109 -0
  60. package/esm/schemas/models/materialized_tenant_sales_comparison_entries.js +130 -0
  61. package/esm/schemas/models/materialized_tenant_sales_comparison_reports.js +154 -0
  62. package/esm/schemas/types/index.js +15 -0
  63. package/esm/schemas/types/materialized_rider_daily_reports.js +1 -0
  64. package/esm/schemas/types/materialized_tenant_cash_entries.js +1 -0
  65. package/esm/schemas/types/materialized_tenant_cash_reports.js +1 -0
  66. package/esm/schemas/types/materialized_tenant_delivery_entries.js +1 -0
  67. package/esm/schemas/types/materialized_tenant_delivery_reports.js +1 -0
  68. package/esm/schemas/types/materialized_tenant_discount_entries.js +1 -0
  69. package/esm/schemas/types/materialized_tenant_discount_reports.js +2 -0
  70. package/esm/schemas/types/materialized_tenant_hourly_comparison_entries.js +1 -0
  71. package/esm/schemas/types/materialized_tenant_hourly_comparison_reports.js +1 -0
  72. package/esm/schemas/types/materialized_tenant_payments_comparison_entries.js +1 -0
  73. package/esm/schemas/types/materialized_tenant_payments_comparison_reports.js +11 -0
  74. package/esm/schemas/types/materialized_tenant_prep_time_entries.js +1 -0
  75. package/esm/schemas/types/materialized_tenant_prep_time_reports.js +1 -0
  76. package/esm/schemas/types/materialized_tenant_sales_comparison_entries.js +1 -0
  77. package/esm/schemas/types/materialized_tenant_sales_comparison_reports.js +14 -0
  78. package/lib/constants/MATERIALIZED_REPORTS.d.ts +339 -2
  79. package/lib/constants/MATERIALIZED_REPORTS.js +450 -1
  80. package/lib/helpers/index.d.ts +3 -0
  81. package/lib/helpers/index.js +3 -0
  82. package/lib/helpers/materialized-reports/index.d.ts +32 -0
  83. package/lib/helpers/materialized-reports/index.js +32 -0
  84. package/lib/helpers/materialized-reports/materialized-cash-accumulator-helpers.d.ts +18 -0
  85. package/lib/helpers/materialized-reports/materialized-cash-accumulator-helpers.js +118 -0
  86. package/lib/helpers/materialized-reports/materialized-cash-classification-helpers.d.ts +90 -0
  87. package/lib/helpers/materialized-reports/materialized-cash-classification-helpers.js +295 -0
  88. package/lib/helpers/materialized-reports/materialized-cash-close-day-helpers.d.ts +102 -0
  89. package/lib/helpers/materialized-reports/materialized-cash-close-day-helpers.js +409 -0
  90. package/lib/helpers/materialized-reports/materialized-cash-compile-helpers.d.ts +72 -0
  91. package/lib/helpers/materialized-reports/materialized-cash-compile-helpers.js +251 -0
  92. package/lib/helpers/materialized-reports/materialized-delivery-accumulator-helpers.d.ts +7 -0
  93. package/lib/helpers/materialized-reports/materialized-delivery-accumulator-helpers.js +173 -0
  94. package/lib/helpers/materialized-reports/materialized-delivery-classification-helpers.d.ts +84 -0
  95. package/lib/helpers/materialized-reports/materialized-delivery-classification-helpers.js +438 -0
  96. package/lib/helpers/materialized-reports/materialized-delivery-close-day-helpers.d.ts +97 -0
  97. package/lib/helpers/materialized-reports/materialized-delivery-close-day-helpers.js +385 -0
  98. package/lib/helpers/materialized-reports/materialized-delivery-compile-helpers.d.ts +40 -0
  99. package/lib/helpers/materialized-reports/materialized-delivery-compile-helpers.js +218 -0
  100. package/lib/helpers/materialized-reports/materialized-discount-accumulator-helpers.d.ts +52 -0
  101. package/lib/helpers/materialized-reports/materialized-discount-accumulator-helpers.js +324 -0
  102. package/lib/helpers/materialized-reports/materialized-discount-classification-helpers.d.ts +50 -0
  103. package/lib/helpers/materialized-reports/materialized-discount-classification-helpers.js +222 -0
  104. package/lib/helpers/materialized-reports/materialized-discount-close-day-helpers.d.ts +182 -0
  105. package/lib/helpers/materialized-reports/materialized-discount-close-day-helpers.js +615 -0
  106. package/lib/helpers/materialized-reports/materialized-discount-compile-helpers.d.ts +47 -0
  107. package/lib/helpers/materialized-reports/materialized-discount-compile-helpers.js +193 -0
  108. package/lib/helpers/materialized-reports/materialized-hourly-comparison-close-day-helpers.d.ts +64 -0
  109. package/lib/helpers/materialized-reports/materialized-hourly-comparison-close-day-helpers.js +163 -0
  110. package/lib/helpers/materialized-reports/materialized-hourly-comparison-compile-helpers.d.ts +61 -0
  111. package/lib/helpers/materialized-reports/materialized-hourly-comparison-compile-helpers.js +207 -0
  112. package/lib/helpers/materialized-reports/materialized-hourly-comparison-selection-helpers.d.ts +23 -0
  113. package/lib/helpers/materialized-reports/materialized-hourly-comparison-selection-helpers.js +116 -0
  114. package/lib/helpers/materialized-reports/materialized-payments-comparison-accumulator-helpers.d.ts +25 -0
  115. package/lib/helpers/materialized-reports/materialized-payments-comparison-accumulator-helpers.js +98 -0
  116. package/lib/helpers/materialized-reports/materialized-payments-comparison-close-day-helpers.d.ts +79 -0
  117. package/lib/helpers/materialized-reports/materialized-payments-comparison-close-day-helpers.js +407 -0
  118. package/lib/helpers/materialized-reports/materialized-payments-comparison-compile-helpers.d.ts +35 -0
  119. package/lib/helpers/materialized-reports/materialized-payments-comparison-compile-helpers.js +173 -0
  120. package/lib/helpers/materialized-reports/materialized-prep-time-classification-helpers.d.ts +66 -0
  121. package/lib/helpers/materialized-reports/materialized-prep-time-classification-helpers.js +224 -0
  122. package/lib/helpers/materialized-reports/materialized-prep-time-close-day-helpers.d.ts +128 -0
  123. package/lib/helpers/materialized-reports/materialized-prep-time-close-day-helpers.js +490 -0
  124. package/lib/helpers/materialized-reports/materialized-prep-time-compile-helpers.d.ts +46 -0
  125. package/lib/helpers/materialized-reports/materialized-prep-time-compile-helpers.js +208 -0
  126. package/lib/helpers/materialized-reports/materialized-reports-selection-helpers.d.ts +8 -0
  127. package/lib/helpers/materialized-reports/materialized-reports-selection-helpers.js +8 -1
  128. package/lib/helpers/materialized-reports/materialized-sales-comparison-accumulator-helpers.d.ts +48 -0
  129. package/lib/helpers/materialized-reports/materialized-sales-comparison-accumulator-helpers.js +204 -0
  130. package/lib/helpers/materialized-reports/materialized-sales-comparison-baseline-helpers.d.ts +22 -0
  131. package/lib/helpers/materialized-reports/materialized-sales-comparison-baseline-helpers.js +161 -0
  132. package/lib/helpers/materialized-reports/materialized-sales-comparison-close-day-helpers.d.ts +163 -0
  133. package/lib/helpers/materialized-reports/materialized-sales-comparison-close-day-helpers.js +603 -0
  134. package/lib/helpers/materialized-reports/materialized-sales-comparison-compile-helpers.d.ts +68 -0
  135. package/lib/helpers/materialized-reports/materialized-sales-comparison-compile-helpers.js +182 -0
  136. package/lib/helpers/materialized-reports/tenant-cash-in-out-formatter.d.ts +98 -0
  137. package/lib/helpers/materialized-reports/tenant-cash-in-out-formatter.js +159 -0
  138. package/lib/helpers/materialized-reports/tenant-delivery-formatter.d.ts +133 -0
  139. package/lib/helpers/materialized-reports/tenant-delivery-formatter.js +233 -0
  140. package/lib/helpers/materialized-reports/tenant-discount-formatter.d.ts +114 -0
  141. package/lib/helpers/materialized-reports/tenant-discount-formatter.js +431 -0
  142. package/lib/helpers/materialized-reports/tenant-hourly-comparison-formatter.d.ts +60 -0
  143. package/lib/helpers/materialized-reports/tenant-hourly-comparison-formatter.js +243 -0
  144. package/lib/helpers/materialized-reports/tenant-payments-comparison-formatter.d.ts +75 -0
  145. package/lib/helpers/materialized-reports/tenant-payments-comparison-formatter.js +286 -0
  146. package/lib/helpers/materialized-reports/tenant-prep-time-formatter.d.ts +97 -0
  147. package/lib/helpers/materialized-reports/tenant-prep-time-formatter.js +232 -0
  148. package/lib/helpers/materialized-reports/tenant-sales-comparison-formatter.d.ts +105 -0
  149. package/lib/helpers/materialized-reports/tenant-sales-comparison-formatter.js +349 -0
  150. package/lib/helpers/reporting-contract/index.d.ts +2 -0
  151. package/lib/helpers/reporting-contract/index.js +18 -0
  152. package/lib/helpers/reporting-contract/overview-contract.d.ts +55 -0
  153. package/lib/helpers/reporting-contract/overview-contract.js +126 -0
  154. package/lib/helpers/reporting-contract/report-contract.d.ts +159 -0
  155. package/lib/helpers/reporting-contract/report-contract.js +239 -0
  156. package/lib/helpers/rider-earnings/index.d.ts +1 -0
  157. package/lib/helpers/rider-earnings/index.js +17 -0
  158. package/lib/helpers/rider-earnings/rider-earnings.d.ts +58 -0
  159. package/lib/helpers/rider-earnings/rider-earnings.js +64 -0
  160. package/lib/helpers/rider-reports/index.d.ts +2 -0
  161. package/lib/helpers/rider-reports/index.js +18 -0
  162. package/lib/helpers/rider-reports/rider-daily-report.d.ts +26 -0
  163. package/lib/helpers/rider-reports/rider-daily-report.js +93 -0
  164. package/lib/helpers/rider-reports/rider-report.d.ts +49 -0
  165. package/lib/helpers/rider-reports/rider-report.js +70 -0
  166. package/lib/helpers/types/materialized-reports-apis.d.ts +297 -1
  167. package/lib/schemas/models/deliveries.d.ts +54 -0
  168. package/lib/schemas/models/deliveries.js +75 -0
  169. package/lib/schemas/models/expense_details.d.ts +3 -3
  170. package/lib/schemas/models/index.d.ts +15 -0
  171. package/lib/schemas/models/index.js +15 -0
  172. package/lib/schemas/models/materialized_rider_daily_reports.d.ts +27 -0
  173. package/lib/schemas/models/materialized_rider_daily_reports.js +42 -0
  174. package/lib/schemas/models/materialized_tenant_cash_entries.d.ts +181 -0
  175. package/lib/schemas/models/materialized_tenant_cash_entries.js +98 -0
  176. package/lib/schemas/models/materialized_tenant_cash_reports.d.ts +111 -0
  177. package/lib/schemas/models/materialized_tenant_cash_reports.js +80 -0
  178. package/lib/schemas/models/materialized_tenant_delivery_entries.d.ts +98 -0
  179. package/lib/schemas/models/materialized_tenant_delivery_entries.js +66 -0
  180. package/lib/schemas/models/materialized_tenant_delivery_reports.d.ts +98 -0
  181. package/lib/schemas/models/materialized_tenant_delivery_reports.js +66 -0
  182. package/lib/schemas/models/materialized_tenant_discount_entries.d.ts +199 -0
  183. package/lib/schemas/models/materialized_tenant_discount_entries.js +159 -0
  184. package/lib/schemas/models/materialized_tenant_discount_reports.d.ts +216 -0
  185. package/lib/schemas/models/materialized_tenant_discount_reports.js +336 -0
  186. package/lib/schemas/models/materialized_tenant_hourly_comparison_entries.d.ts +95 -0
  187. package/lib/schemas/models/materialized_tenant_hourly_comparison_entries.js +82 -0
  188. package/lib/schemas/models/materialized_tenant_hourly_comparison_reports.d.ts +105 -0
  189. package/lib/schemas/models/materialized_tenant_hourly_comparison_reports.js +91 -0
  190. package/lib/schemas/models/materialized_tenant_payments_comparison_entries.d.ts +91 -0
  191. package/lib/schemas/models/materialized_tenant_payments_comparison_entries.js +70 -0
  192. package/lib/schemas/models/materialized_tenant_payments_comparison_reports.d.ts +98 -0
  193. package/lib/schemas/models/materialized_tenant_payments_comparison_reports.js +71 -0
  194. package/lib/schemas/models/materialized_tenant_prep_time_entries.d.ts +181 -0
  195. package/lib/schemas/models/materialized_tenant_prep_time_entries.js +133 -0
  196. package/lib/schemas/models/materialized_tenant_prep_time_reports.d.ts +118 -0
  197. package/lib/schemas/models/materialized_tenant_prep_time_reports.js +112 -0
  198. package/lib/schemas/models/materialized_tenant_sales_comparison_entries.d.ts +139 -0
  199. package/lib/schemas/models/materialized_tenant_sales_comparison_entries.js +120 -0
  200. package/lib/schemas/models/materialized_tenant_sales_comparison_reports.d.ts +167 -0
  201. package/lib/schemas/models/materialized_tenant_sales_comparison_reports.js +137 -0
  202. package/lib/schemas/models/tenant_purchase_order_vendor_returns.d.ts +3 -3
  203. package/lib/schemas/models/warehouse_internal_movements.d.ts +6 -6
  204. package/lib/schemas/models/warehouse_purchase_order_receipts.d.ts +3 -3
  205. package/lib/schemas/models/warehouse_purchase_order_vendor_returns.d.ts +3 -3
  206. package/lib/schemas/models/warehouse_sale_deliveries.d.ts +6 -6
  207. package/lib/schemas/models/warehouse_sale_invoices.d.ts +3 -3
  208. package/lib/schemas/types/deliveries.d.ts +40 -1
  209. package/lib/schemas/types/index.d.ts +15 -0
  210. package/lib/schemas/types/index.js +15 -0
  211. package/lib/schemas/types/materialized_rider_daily_reports.d.ts +37 -0
  212. package/lib/schemas/types/materialized_rider_daily_reports.js +2 -0
  213. package/lib/schemas/types/materialized_tenant_cash_entries.d.ts +87 -0
  214. package/lib/schemas/types/materialized_tenant_cash_entries.js +2 -0
  215. package/lib/schemas/types/materialized_tenant_cash_reports.d.ts +144 -0
  216. package/lib/schemas/types/materialized_tenant_cash_reports.js +2 -0
  217. package/lib/schemas/types/materialized_tenant_delivery_entries.d.ts +98 -0
  218. package/lib/schemas/types/materialized_tenant_delivery_entries.js +2 -0
  219. package/lib/schemas/types/materialized_tenant_delivery_reports.d.ts +179 -0
  220. package/lib/schemas/types/materialized_tenant_delivery_reports.js +2 -0
  221. package/lib/schemas/types/materialized_tenant_discount_entries.d.ts +81 -0
  222. package/lib/schemas/types/materialized_tenant_discount_entries.js +2 -0
  223. package/lib/schemas/types/materialized_tenant_discount_reports.d.ts +209 -0
  224. package/lib/schemas/types/materialized_tenant_discount_reports.js +3 -0
  225. package/lib/schemas/types/materialized_tenant_hourly_comparison_entries.d.ts +33 -0
  226. package/lib/schemas/types/materialized_tenant_hourly_comparison_entries.js +2 -0
  227. package/lib/schemas/types/materialized_tenant_hourly_comparison_reports.d.ts +40 -0
  228. package/lib/schemas/types/materialized_tenant_hourly_comparison_reports.js +2 -0
  229. package/lib/schemas/types/materialized_tenant_payments_comparison_entries.d.ts +48 -0
  230. package/lib/schemas/types/materialized_tenant_payments_comparison_entries.js +2 -0
  231. package/lib/schemas/types/materialized_tenant_payments_comparison_reports.d.ts +51 -0
  232. package/lib/schemas/types/materialized_tenant_payments_comparison_reports.js +14 -0
  233. package/lib/schemas/types/materialized_tenant_prep_time_entries.d.ts +88 -0
  234. package/lib/schemas/types/materialized_tenant_prep_time_entries.js +2 -0
  235. package/lib/schemas/types/materialized_tenant_prep_time_reports.d.ts +132 -0
  236. package/lib/schemas/types/materialized_tenant_prep_time_reports.js +2 -0
  237. package/lib/schemas/types/materialized_tenant_sales_comparison_entries.d.ts +43 -0
  238. package/lib/schemas/types/materialized_tenant_sales_comparison_entries.js +2 -0
  239. package/lib/schemas/types/materialized_tenant_sales_comparison_reports.d.ts +74 -0
  240. package/lib/schemas/types/materialized_tenant_sales_comparison_reports.js +17 -0
  241. package/lib/tests/materialized-reports/analytics-growth-helpers.test.d.ts +1 -0
  242. package/lib/tests/materialized-reports/analytics-overview-helpers.test.d.ts +1 -0
  243. package/lib/tests/materialized-reports/analytics-performance-helpers.test.d.ts +1 -0
  244. package/lib/tests/materialized-reports/fixtures.d.ts +15 -1
  245. package/lib/tests/materialized-reports/fixtures.js +1 -0
  246. package/lib/tests/materialized-reports/materialized-cash-compile.test.d.ts +1 -0
  247. package/lib/tests/materialized-reports/materialized-cash-compile.test.js +196 -0
  248. package/lib/tests/materialized-reports/materialized-cash-fold.test.d.ts +1 -0
  249. package/lib/tests/materialized-reports/materialized-cash-fold.test.js +116 -0
  250. package/lib/tests/materialized-reports/materialized-cash-formatter.test.d.ts +1 -0
  251. package/lib/tests/materialized-reports/materialized-cash-formatter.test.js +152 -0
  252. package/lib/tests/materialized-reports/materialized-cash-plan.test.d.ts +1 -0
  253. package/lib/tests/materialized-reports/materialized-cash-plan.test.js +168 -0
  254. package/lib/tests/materialized-reports/materialized-cash-reconciliation.test.d.ts +1 -0
  255. package/lib/tests/materialized-reports/materialized-cash-reconciliation.test.js +267 -0
  256. package/lib/tests/materialized-reports/materialized-delivery-accumulation.test.d.ts +1 -0
  257. package/lib/tests/materialized-reports/materialized-delivery-accumulation.test.js +147 -0
  258. package/lib/tests/materialized-reports/materialized-delivery-compile.test.d.ts +1 -0
  259. package/lib/tests/materialized-reports/materialized-delivery-compile.test.js +241 -0
  260. package/lib/tests/materialized-reports/materialized-delivery-fold.test.d.ts +1 -0
  261. package/lib/tests/materialized-reports/materialized-delivery-fold.test.js +109 -0
  262. package/lib/tests/materialized-reports/materialized-delivery-formatter.test.d.ts +1 -0
  263. package/lib/tests/materialized-reports/materialized-delivery-formatter.test.js +141 -0
  264. package/lib/tests/materialized-reports/materialized-delivery-plan.test.d.ts +1 -0
  265. package/lib/tests/materialized-reports/materialized-delivery-plan.test.js +198 -0
  266. package/lib/tests/materialized-reports/materialized-discount-aggregated-formatter.test.d.ts +1 -0
  267. package/lib/tests/materialized-reports/materialized-discount-aggregated-formatter.test.js +173 -0
  268. package/lib/tests/materialized-reports/materialized-discount-classification.test.d.ts +1 -0
  269. package/lib/tests/materialized-reports/materialized-discount-classification.test.js +339 -0
  270. package/lib/tests/materialized-reports/materialized-discount-close-day.test.d.ts +1 -0
  271. package/lib/tests/materialized-reports/materialized-discount-close-day.test.js +506 -0
  272. package/lib/tests/materialized-reports/materialized-discount-compile.test.d.ts +1 -0
  273. package/lib/tests/materialized-reports/materialized-discount-compile.test.js +161 -0
  274. package/lib/tests/materialized-reports/materialized-discount-counter-rows.test.d.ts +1 -0
  275. package/lib/tests/materialized-reports/materialized-discount-counter-rows.test.js +107 -0
  276. package/lib/tests/materialized-reports/materialized-discount-entries-accumulation.test.d.ts +1 -0
  277. package/lib/tests/materialized-reports/materialized-discount-entries-accumulation.test.js +125 -0
  278. package/lib/tests/materialized-reports/materialized-hourly-comparison-compile.test.d.ts +1 -0
  279. package/lib/tests/materialized-reports/materialized-hourly-comparison-compile.test.js +146 -0
  280. package/lib/tests/materialized-reports/materialized-hourly-comparison-formatter.test.d.ts +1 -0
  281. package/lib/tests/materialized-reports/materialized-hourly-comparison-formatter.test.js +127 -0
  282. package/lib/tests/materialized-reports/materialized-hourly-comparison-plan.test.d.ts +1 -0
  283. package/lib/tests/materialized-reports/materialized-hourly-comparison-plan.test.js +138 -0
  284. package/lib/tests/materialized-reports/materialized-hourly-comparison-selection.test.d.ts +1 -0
  285. package/lib/tests/materialized-reports/materialized-hourly-comparison-selection.test.js +90 -0
  286. package/lib/tests/materialized-reports/materialized-payments-comparison-compile.test.d.ts +1 -0
  287. package/lib/tests/materialized-reports/materialized-payments-comparison-compile.test.js +164 -0
  288. package/lib/tests/materialized-reports/materialized-payments-comparison-formatter.test.d.ts +1 -0
  289. package/lib/tests/materialized-reports/materialized-payments-comparison-formatter.test.js +117 -0
  290. package/lib/tests/materialized-reports/materialized-payments-comparison-plan.test.d.ts +1 -0
  291. package/lib/tests/materialized-reports/materialized-payments-comparison-plan.test.js +149 -0
  292. package/lib/tests/materialized-reports/materialized-prep-time-classification.test.d.ts +1 -0
  293. package/lib/tests/materialized-reports/materialized-prep-time-classification.test.js +273 -0
  294. package/lib/tests/materialized-reports/materialized-prep-time-close-day.test.d.ts +1 -0
  295. package/lib/tests/materialized-reports/materialized-prep-time-close-day.test.js +270 -0
  296. package/lib/tests/materialized-reports/materialized-prep-time-compile.test.d.ts +1 -0
  297. package/lib/tests/materialized-reports/materialized-prep-time-compile.test.js +217 -0
  298. package/lib/tests/materialized-reports/materialized-prep-time-constants.test.d.ts +1 -0
  299. package/lib/tests/materialized-reports/materialized-prep-time-constants.test.js +84 -0
  300. package/lib/tests/materialized-reports/materialized-prep-time-plan.test.d.ts +1 -0
  301. package/lib/tests/materialized-reports/materialized-prep-time-plan.test.js +176 -0
  302. package/lib/tests/materialized-reports/materialized-sales-comparison-baseline.test.d.ts +1 -0
  303. package/lib/tests/materialized-reports/materialized-sales-comparison-baseline.test.js +126 -0
  304. package/lib/tests/materialized-reports/materialized-sales-comparison-compile.test.d.ts +1 -0
  305. package/lib/tests/materialized-reports/materialized-sales-comparison-compile.test.js +206 -0
  306. package/lib/tests/materialized-reports/materialized-sales-comparison-formatter.test.d.ts +1 -0
  307. package/lib/tests/materialized-reports/materialized-sales-comparison-formatter.test.js +179 -0
  308. package/lib/tests/materialized-reports/materialized-sales-comparison-parity.test.d.ts +1 -0
  309. package/lib/tests/materialized-reports/materialized-sales-comparison-parity.test.js +196 -0
  310. package/lib/tests/materialized-reports/materialized-sales-comparison-plan.test.d.ts +1 -0
  311. package/lib/tests/materialized-reports/materialized-sales-comparison-plan.test.js +241 -0
  312. package/lib/tests/materialized-reports/materialized-tenant-hourly-comparison-schema.test.d.ts +1 -0
  313. package/lib/tests/materialized-reports/materialized-tenant-hourly-comparison-schema.test.js +96 -0
  314. package/lib/tests/materialized-reports/materialized-tenant-payments-comparison-schema.test.d.ts +1 -0
  315. package/lib/tests/materialized-reports/materialized-tenant-payments-comparison-schema.test.js +112 -0
  316. package/lib/tests/materialized-reports/materialized-tenant-sales-comparison-schema.test.d.ts +1 -0
  317. package/lib/tests/materialized-reports/materialized-tenant-sales-comparison-schema.test.js +142 -0
  318. package/lib/tests/materialized-reports/materialized-tenant-sales-overview-reports-schema.test.js +8 -1
  319. package/lib/tests/materialized-reports/sales-comparison-reference.d.ts +55 -0
  320. package/lib/tests/materialized-reports/sales-comparison-reference.js +86 -0
  321. package/lib/tests/materialized-reports/tenant-discount-formatter.test.d.ts +1 -0
  322. package/lib/tests/materialized-reports/tenant-discount-formatter.test.js +289 -0
  323. package/lib/tests/materialized-reports/tenant-prep-time-formatter.test.d.ts +1 -0
  324. package/lib/tests/materialized-reports/tenant-prep-time-formatter.test.js +354 -0
  325. package/lib/tests/reporting-contract.test.d.ts +1 -0
  326. package/lib/tests/reporting-contract.test.js +267 -0
  327. package/lib/tests/rider-daily-report.test.d.ts +1 -0
  328. package/lib/tests/rider-daily-report.test.js +86 -0
  329. package/lib/tests/rider-earnings.test.d.ts +1 -0
  330. package/lib/tests/rider-earnings.test.js +65 -0
  331. package/lib/tests/rider-report.test.d.ts +1 -0
  332. package/lib/tests/rider-report.test.js +98 -0
  333. package/package.json +10 -1
@@ -0,0 +1,159 @@
1
+ /**
2
+ * Shared report API contract — the single response shape used by BOTH source
3
+ * modes:
4
+ *
5
+ * - `LIVE` — aggregated from the raw collections (orders / deliveries /
6
+ * cash ledger) for a range that may include the open day;
7
+ * - `HISTORICAL` — read from the materialized collections for a closed range.
8
+ *
9
+ * The mode changes the SOURCE and the freshness metadata only. The `current` /
10
+ * `comparison` / `rows` payloads are the SAME type in both modes, so the admin
11
+ * panel uses one slice and one formatter and only switches the URL.
12
+ */
13
+ export declare const REPORT_API_VERSION = 1;
14
+ export declare enum REPORT_MODE_ENUM {
15
+ LIVE = "LIVE",
16
+ HISTORICAL = "HISTORICAL"
17
+ }
18
+ export declare const ALL_REPORT_MODES: REPORT_MODE_ENUM[];
19
+ /**
20
+ * Every report the operations service can serve. The list is deliberately
21
+ * complete including reports that are still being built, so the capability
22
+ * matrix is the single place the frontend asks "does this report have a Live
23
+ * view?".
24
+ */
25
+ export declare enum REPORT_KEY_ENUM {
26
+ OVERVIEW = "OVERVIEW",
27
+ DISCOUNTS = "DISCOUNTS",
28
+ PREP_TIME = "PREP_TIME",
29
+ CASH_IN_OUT = "CASH_IN_OUT",
30
+ DELIVERY = "DELIVERY",
31
+ SALES_COMPARISON = "SALES_COMPARISON",
32
+ HOURLY_COMPARISON = "HOURLY_COMPARISON",
33
+ PAYMENTS_COMPARISON = "PAYMENTS_COMPARISON",
34
+ CREDIT_BILLS = "CREDIT_BILLS",
35
+ ITERATIONS = "ITERATIONS",
36
+ SUMMARY = "SUMMARY",
37
+ X_REPORT = "X_REPORT",
38
+ Z_REPORT = "Z_REPORT",
39
+ ITEMS = "ITEMS",
40
+ ITEMS_COMPARISON = "ITEMS_COMPARISON",
41
+ VOID_ITEMS = "VOID_ITEMS",
42
+ REVIEWS_RATINGS = "REVIEWS_RATINGS"
43
+ }
44
+ export declare const ALL_REPORT_KEYS: REPORT_KEY_ENUM[];
45
+ /** URL segment of each report under `/reports` (shared by ops + admin). */
46
+ export declare const REPORT_ROUTE_SEGMENTS: Record<REPORT_KEY_ENUM, string>;
47
+ export interface IReportCapabilities {
48
+ live: boolean;
49
+ historical: boolean;
50
+ details: boolean;
51
+ }
52
+ /**
53
+ * The one capability matrix. `live: false` means the frontend MUST NOT render
54
+ * a Live switch for that report; the backend enforces the same flag.
55
+ *
56
+ * Reports that are not implemented yet are explicitly false. Do not advertise
57
+ * a mode before its routes exist.
58
+ */
59
+ export declare const REPORT_CAPABILITIES: Record<REPORT_KEY_ENUM, IReportCapabilities>;
60
+ export declare enum REPORT_ERROR_CODE_ENUM {
61
+ INVALID_REQUEST = "INVALID_REQUEST",
62
+ SELECTION_TOO_LARGE = "SELECTION_TOO_LARGE",
63
+ TOO_MANY_TENANTS = "TOO_MANY_TENANTS",
64
+ LIVE_NOT_SUPPORTED = "LIVE_NOT_SUPPORTED",
65
+ HISTORICAL_THROUGH_LAST_CLOSE = "HISTORICAL_THROUGH_LAST_CLOSE",
66
+ TIME_WINDOW_NOT_SUPPORTED_LIVE = "TIME_WINDOW_NOT_SUPPORTED_LIVE",
67
+ INVALID_BASELINE = "INVALID_BASELINE",
68
+ INVALID_CURSOR = "INVALID_CURSOR"
69
+ }
70
+ export interface IReportErrorResponse {
71
+ error: {
72
+ code: REPORT_ERROR_CODE_ENUM;
73
+ message: string;
74
+ details?: unknown;
75
+ };
76
+ }
77
+ /**
78
+ * Freshness / provenance of one response. `schema_version` and
79
+ * `source_watermark` are `null` for a live read — live data has no
80
+ * materialized schema or watermark.
81
+ */
82
+ export interface IReportResponseMeta {
83
+ api_version: number;
84
+ mode: REPORT_MODE_ENUM;
85
+ as_of: string;
86
+ /** Tenant-local business day the read is anchored on, when known. */
87
+ business_date: string | null;
88
+ /** Last fully closed day, when known. */
89
+ last_closed_date: string | null;
90
+ /** True when every input day is closed. */
91
+ final: boolean;
92
+ schema_version: number | null;
93
+ source_watermark: string | null;
94
+ }
95
+ export interface IReportResponse<T> {
96
+ report: REPORT_KEY_ENUM;
97
+ meta: IReportResponseMeta;
98
+ tenants: string[];
99
+ current: T[];
100
+ comparison: T[] | null;
101
+ }
102
+ export interface IReportDetailsResponse<T, TCursor = unknown> {
103
+ report: REPORT_KEY_ENUM;
104
+ meta: IReportResponseMeta;
105
+ rows: T[];
106
+ next_cursor: TCursor | null;
107
+ }
108
+ /**
109
+ * Analytics response family. Live and historical of the SAME analytics
110
+ * endpoint share this one shape; different analytics endpoints only change
111
+ * `data`.
112
+ */
113
+ export interface IReportAnalyticsResponse<T> {
114
+ analytics: string;
115
+ meta: IReportResponseMeta;
116
+ tenants: string[];
117
+ data: T;
118
+ }
119
+ export interface IBuildReportMetaInput {
120
+ mode: REPORT_MODE_ENUM | string;
121
+ asOf: Date | string;
122
+ businessDate?: string | null;
123
+ lastClosedDate?: string | null;
124
+ final: boolean;
125
+ schemaVersion?: number | null;
126
+ sourceWatermark?: Date | string | null;
127
+ }
128
+ /** Pure builder for the shared meta block. Returns null on invalid input. */
129
+ export declare function buildReportMeta(input: IBuildReportMetaInput | null | undefined): IReportResponseMeta | null;
130
+ export interface IBuildReportResponseInput<T> {
131
+ report: REPORT_KEY_ENUM | string;
132
+ meta: IReportResponseMeta | null | undefined;
133
+ tenants: string[];
134
+ current: T[];
135
+ comparison: T[] | null;
136
+ }
137
+ /** Pure builder for the shared report envelope. Returns null on invalid input. */
138
+ export declare function buildReportResponse<T>(input: IBuildReportResponseInput<T> | null | undefined): IReportResponse<T> | null;
139
+ export interface IBuildReportDetailsResponseInput<T, TCursor = unknown> {
140
+ report: REPORT_KEY_ENUM | string;
141
+ meta: IReportResponseMeta | null | undefined;
142
+ rows: T[];
143
+ nextCursor?: TCursor | null;
144
+ }
145
+ export declare function buildReportDetailsResponse<T, TCursor = unknown>(input: IBuildReportDetailsResponseInput<T, TCursor> | null | undefined): IReportDetailsResponse<T, TCursor> | null;
146
+ export interface IBuildReportAnalyticsResponseInput<T> {
147
+ analytics: string;
148
+ meta: IReportResponseMeta | null | undefined;
149
+ tenants: string[];
150
+ data: T;
151
+ }
152
+ export declare function buildReportAnalyticsResponse<T>(input: IBuildReportAnalyticsResponseInput<T> | null | undefined): IReportAnalyticsResponse<T> | null;
153
+ export declare function getReportCapabilities(report: REPORT_KEY_ENUM | string): IReportCapabilities | null;
154
+ export declare function isReportModeSupported(report: REPORT_KEY_ENUM | string, mode: REPORT_MODE_ENUM | string): boolean;
155
+ /** Shared URL builder — ops routes and admin fetchers use the same segments. */
156
+ export declare function buildReportPath(report: REPORT_KEY_ENUM | string, mode: REPORT_MODE_ENUM | string, options?: {
157
+ details?: boolean;
158
+ }): string | null;
159
+ export declare function buildReportError(code: REPORT_ERROR_CODE_ENUM, message: string, details?: unknown): IReportErrorResponse;
@@ -0,0 +1,239 @@
1
+ "use strict";
2
+ /**
3
+ * Shared report API contract — the single response shape used by BOTH source
4
+ * modes:
5
+ *
6
+ * - `LIVE` — aggregated from the raw collections (orders / deliveries /
7
+ * cash ledger) for a range that may include the open day;
8
+ * - `HISTORICAL` — read from the materialized collections for a closed range.
9
+ *
10
+ * The mode changes the SOURCE and the freshness metadata only. The `current` /
11
+ * `comparison` / `rows` payloads are the SAME type in both modes, so the admin
12
+ * panel uses one slice and one formatter and only switches the URL.
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.REPORT_ERROR_CODE_ENUM = exports.REPORT_CAPABILITIES = exports.REPORT_ROUTE_SEGMENTS = exports.ALL_REPORT_KEYS = exports.REPORT_KEY_ENUM = exports.ALL_REPORT_MODES = exports.REPORT_MODE_ENUM = exports.REPORT_API_VERSION = void 0;
16
+ exports.buildReportMeta = buildReportMeta;
17
+ exports.buildReportResponse = buildReportResponse;
18
+ exports.buildReportDetailsResponse = buildReportDetailsResponse;
19
+ exports.buildReportAnalyticsResponse = buildReportAnalyticsResponse;
20
+ exports.getReportCapabilities = getReportCapabilities;
21
+ exports.isReportModeSupported = isReportModeSupported;
22
+ exports.buildReportPath = buildReportPath;
23
+ exports.buildReportError = buildReportError;
24
+ exports.REPORT_API_VERSION = 1;
25
+ var REPORT_MODE_ENUM;
26
+ (function (REPORT_MODE_ENUM) {
27
+ REPORT_MODE_ENUM["LIVE"] = "LIVE";
28
+ REPORT_MODE_ENUM["HISTORICAL"] = "HISTORICAL";
29
+ })(REPORT_MODE_ENUM || (exports.REPORT_MODE_ENUM = REPORT_MODE_ENUM = {}));
30
+ exports.ALL_REPORT_MODES = Object.values(REPORT_MODE_ENUM);
31
+ /**
32
+ * Every report the operations service can serve. The list is deliberately
33
+ * complete including reports that are still being built, so the capability
34
+ * matrix is the single place the frontend asks "does this report have a Live
35
+ * view?".
36
+ */
37
+ var REPORT_KEY_ENUM;
38
+ (function (REPORT_KEY_ENUM) {
39
+ REPORT_KEY_ENUM["OVERVIEW"] = "OVERVIEW";
40
+ REPORT_KEY_ENUM["DISCOUNTS"] = "DISCOUNTS";
41
+ REPORT_KEY_ENUM["PREP_TIME"] = "PREP_TIME";
42
+ REPORT_KEY_ENUM["CASH_IN_OUT"] = "CASH_IN_OUT";
43
+ REPORT_KEY_ENUM["DELIVERY"] = "DELIVERY";
44
+ REPORT_KEY_ENUM["SALES_COMPARISON"] = "SALES_COMPARISON";
45
+ REPORT_KEY_ENUM["HOURLY_COMPARISON"] = "HOURLY_COMPARISON";
46
+ REPORT_KEY_ENUM["PAYMENTS_COMPARISON"] = "PAYMENTS_COMPARISON";
47
+ REPORT_KEY_ENUM["CREDIT_BILLS"] = "CREDIT_BILLS";
48
+ REPORT_KEY_ENUM["ITERATIONS"] = "ITERATIONS";
49
+ REPORT_KEY_ENUM["SUMMARY"] = "SUMMARY";
50
+ REPORT_KEY_ENUM["X_REPORT"] = "X_REPORT";
51
+ REPORT_KEY_ENUM["Z_REPORT"] = "Z_REPORT";
52
+ REPORT_KEY_ENUM["ITEMS"] = "ITEMS";
53
+ REPORT_KEY_ENUM["ITEMS_COMPARISON"] = "ITEMS_COMPARISON";
54
+ REPORT_KEY_ENUM["VOID_ITEMS"] = "VOID_ITEMS";
55
+ REPORT_KEY_ENUM["REVIEWS_RATINGS"] = "REVIEWS_RATINGS";
56
+ })(REPORT_KEY_ENUM || (exports.REPORT_KEY_ENUM = REPORT_KEY_ENUM = {}));
57
+ exports.ALL_REPORT_KEYS = Object.values(REPORT_KEY_ENUM);
58
+ /** URL segment of each report under `/reports` (shared by ops + admin). */
59
+ exports.REPORT_ROUTE_SEGMENTS = {
60
+ [REPORT_KEY_ENUM.OVERVIEW]: 'overview',
61
+ [REPORT_KEY_ENUM.DISCOUNTS]: 'discounts',
62
+ [REPORT_KEY_ENUM.PREP_TIME]: 'prep-time',
63
+ [REPORT_KEY_ENUM.CASH_IN_OUT]: 'cash-in-out',
64
+ [REPORT_KEY_ENUM.DELIVERY]: 'delivery',
65
+ [REPORT_KEY_ENUM.SALES_COMPARISON]: 'sales-comparison',
66
+ [REPORT_KEY_ENUM.HOURLY_COMPARISON]: 'hourly-comparison',
67
+ [REPORT_KEY_ENUM.PAYMENTS_COMPARISON]: 'payments-comparison',
68
+ [REPORT_KEY_ENUM.CREDIT_BILLS]: 'credit-bills',
69
+ [REPORT_KEY_ENUM.ITERATIONS]: 'iterations',
70
+ [REPORT_KEY_ENUM.SUMMARY]: 'summary',
71
+ [REPORT_KEY_ENUM.X_REPORT]: 'x-report',
72
+ [REPORT_KEY_ENUM.Z_REPORT]: 'z-report',
73
+ [REPORT_KEY_ENUM.ITEMS]: 'items',
74
+ [REPORT_KEY_ENUM.ITEMS_COMPARISON]: 'items-comparison',
75
+ [REPORT_KEY_ENUM.VOID_ITEMS]: 'void-items',
76
+ [REPORT_KEY_ENUM.REVIEWS_RATINGS]: 'reviews-ratings',
77
+ };
78
+ /**
79
+ * The one capability matrix. `live: false` means the frontend MUST NOT render
80
+ * a Live switch for that report; the backend enforces the same flag.
81
+ *
82
+ * Reports that are not implemented yet are explicitly false. Do not advertise
83
+ * a mode before its routes exist.
84
+ */
85
+ exports.REPORT_CAPABILITIES = {
86
+ // Contract routes that are implemented today. Everything else keeps its
87
+ // legacy single-mode route until the live/historical pair lands; the UI must
88
+ // not offer a mode that is not in this matrix.
89
+ [REPORT_KEY_ENUM.OVERVIEW]: { live: true, historical: true, details: false },
90
+ [REPORT_KEY_ENUM.SALES_COMPARISON]: { live: true, historical: true, details: true },
91
+ [REPORT_KEY_ENUM.DISCOUNTS]: { live: true, historical: true, details: true },
92
+ [REPORT_KEY_ENUM.PREP_TIME]: { live: true, historical: true, details: true },
93
+ [REPORT_KEY_ENUM.CASH_IN_OUT]: { live: true, historical: true, details: true },
94
+ [REPORT_KEY_ENUM.DELIVERY]: { live: true, historical: true, details: true },
95
+ [REPORT_KEY_ENUM.HOURLY_COMPARISON]: { live: true, historical: true, details: true },
96
+ [REPORT_KEY_ENUM.PAYMENTS_COMPARISON]: { live: true, historical: true, details: true },
97
+ [REPORT_KEY_ENUM.CREDIT_BILLS]: { live: false, historical: true, details: true },
98
+ [REPORT_KEY_ENUM.ITERATIONS]: { live: false, historical: false, details: false },
99
+ [REPORT_KEY_ENUM.SUMMARY]: { live: false, historical: false, details: false },
100
+ [REPORT_KEY_ENUM.X_REPORT]: { live: false, historical: false, details: false },
101
+ [REPORT_KEY_ENUM.Z_REPORT]: { live: false, historical: false, details: false },
102
+ [REPORT_KEY_ENUM.ITEMS]: { live: false, historical: false, details: false },
103
+ [REPORT_KEY_ENUM.ITEMS_COMPARISON]: { live: false, historical: false, details: false },
104
+ [REPORT_KEY_ENUM.VOID_ITEMS]: { live: false, historical: false, details: false },
105
+ [REPORT_KEY_ENUM.REVIEWS_RATINGS]: { live: false, historical: false, details: false },
106
+ };
107
+ var REPORT_ERROR_CODE_ENUM;
108
+ (function (REPORT_ERROR_CODE_ENUM) {
109
+ REPORT_ERROR_CODE_ENUM["INVALID_REQUEST"] = "INVALID_REQUEST";
110
+ REPORT_ERROR_CODE_ENUM["SELECTION_TOO_LARGE"] = "SELECTION_TOO_LARGE";
111
+ REPORT_ERROR_CODE_ENUM["TOO_MANY_TENANTS"] = "TOO_MANY_TENANTS";
112
+ REPORT_ERROR_CODE_ENUM["LIVE_NOT_SUPPORTED"] = "LIVE_NOT_SUPPORTED";
113
+ REPORT_ERROR_CODE_ENUM["HISTORICAL_THROUGH_LAST_CLOSE"] = "HISTORICAL_THROUGH_LAST_CLOSE";
114
+ REPORT_ERROR_CODE_ENUM["TIME_WINDOW_NOT_SUPPORTED_LIVE"] = "TIME_WINDOW_NOT_SUPPORTED_LIVE";
115
+ REPORT_ERROR_CODE_ENUM["INVALID_BASELINE"] = "INVALID_BASELINE";
116
+ REPORT_ERROR_CODE_ENUM["INVALID_CURSOR"] = "INVALID_CURSOR";
117
+ })(REPORT_ERROR_CODE_ENUM || (exports.REPORT_ERROR_CODE_ENUM = REPORT_ERROR_CODE_ENUM = {}));
118
+ const isNonEmptyString = (value) => typeof value === 'string' && value.trim() !== '';
119
+ const toIsoString = (value) => {
120
+ if (value == null)
121
+ return null;
122
+ const date = value instanceof Date ? value : new Date(value);
123
+ if (Number.isNaN(date.getTime()))
124
+ return null;
125
+ return date.toISOString();
126
+ };
127
+ const isReportKey = (value) => typeof value === 'string' && exports.ALL_REPORT_KEYS.includes(value);
128
+ const isReportMode = (value) => typeof value === 'string' && exports.ALL_REPORT_MODES.includes(value);
129
+ /** Pure builder for the shared meta block. Returns null on invalid input. */
130
+ function buildReportMeta(input) {
131
+ if (input == null || !isReportMode(input.mode))
132
+ return null;
133
+ const asOf = toIsoString(input.asOf);
134
+ if (asOf == null)
135
+ return null;
136
+ if (typeof input.final !== 'boolean')
137
+ return null;
138
+ const isLive = input.mode === REPORT_MODE_ENUM.LIVE;
139
+ const schemaVersion = input.schemaVersion ?? null;
140
+ const watermark = toIsoString(input.sourceWatermark ?? null);
141
+ // Live data never carries a materialized schema version / watermark.
142
+ if (isLive && (schemaVersion != null || input.sourceWatermark != null))
143
+ return null;
144
+ return {
145
+ api_version: exports.REPORT_API_VERSION,
146
+ mode: input.mode,
147
+ as_of: asOf,
148
+ business_date: input.businessDate ?? null,
149
+ last_closed_date: input.lastClosedDate ?? null,
150
+ final: input.final,
151
+ schema_version: isLive ? null : schemaVersion,
152
+ source_watermark: isLive ? null : watermark,
153
+ };
154
+ }
155
+ /** Pure builder for the shared report envelope. Returns null on invalid input. */
156
+ function buildReportResponse(input) {
157
+ if (input == null || !isReportKey(input.report))
158
+ return null;
159
+ if (input.meta == null || input.meta.api_version !== exports.REPORT_API_VERSION)
160
+ return null;
161
+ if (!Array.isArray(input.tenants) || input.tenants.length === 0)
162
+ return null;
163
+ if (input.tenants.some((tenant) => !isNonEmptyString(tenant)))
164
+ return null;
165
+ if (!Array.isArray(input.current))
166
+ return null;
167
+ if (input.comparison !== null && !Array.isArray(input.comparison))
168
+ return null;
169
+ return {
170
+ report: input.report,
171
+ meta: input.meta,
172
+ tenants: input.tenants.map((tenant) => tenant.trim()),
173
+ current: input.current,
174
+ comparison: input.comparison,
175
+ };
176
+ }
177
+ function buildReportDetailsResponse(input) {
178
+ if (input == null || !isReportKey(input.report))
179
+ return null;
180
+ if (input.meta == null || input.meta.api_version !== exports.REPORT_API_VERSION)
181
+ return null;
182
+ if (!Array.isArray(input.rows))
183
+ return null;
184
+ return {
185
+ report: input.report,
186
+ meta: input.meta,
187
+ rows: input.rows,
188
+ next_cursor: input.nextCursor ?? null,
189
+ };
190
+ }
191
+ function buildReportAnalyticsResponse(input) {
192
+ if (input == null || !isNonEmptyString(input.analytics))
193
+ return null;
194
+ if (input.meta == null || input.meta.api_version !== exports.REPORT_API_VERSION)
195
+ return null;
196
+ if (!Array.isArray(input.tenants) || input.tenants.length === 0)
197
+ return null;
198
+ if (input.tenants.some((tenant) => !isNonEmptyString(tenant)))
199
+ return null;
200
+ if (input.data === undefined)
201
+ return null;
202
+ return {
203
+ analytics: input.analytics.trim(),
204
+ meta: input.meta,
205
+ tenants: input.tenants.map((tenant) => tenant.trim()),
206
+ data: input.data,
207
+ };
208
+ }
209
+ function getReportCapabilities(report) {
210
+ if (!isReportKey(report))
211
+ return null;
212
+ return { ...exports.REPORT_CAPABILITIES[report] };
213
+ }
214
+ function isReportModeSupported(report, mode) {
215
+ const capabilities = getReportCapabilities(report);
216
+ if (capabilities == null || !isReportMode(mode))
217
+ return false;
218
+ return mode === REPORT_MODE_ENUM.LIVE ? capabilities.live : capabilities.historical;
219
+ }
220
+ /** Shared URL builder — ops routes and admin fetchers use the same segments. */
221
+ function buildReportPath(report, mode, options = {}) {
222
+ if (!isReportKey(report) || !isReportMode(mode))
223
+ return null;
224
+ if (!isReportModeSupported(report, mode))
225
+ return null;
226
+ if (options.details === true && !exports.REPORT_CAPABILITIES[report].details)
227
+ return null;
228
+ const segment = exports.REPORT_ROUTE_SEGMENTS[report];
229
+ return `/reports/${segment}${options.details === true ? '/details' : ''}/${mode.toLowerCase()}`;
230
+ }
231
+ function buildReportError(code, message, details) {
232
+ return {
233
+ error: {
234
+ code,
235
+ message,
236
+ ...(details === undefined ? {} : { details }),
237
+ },
238
+ };
239
+ }
@@ -0,0 +1 @@
1
+ export * from './rider-earnings';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./rider-earnings"), exports);
@@ -0,0 +1,58 @@
1
+ import { RIDER_FEE_TYPE_ENUM } from '../../constants/enums/delivery';
2
+ /**
3
+ * Rider fee calculation (owner-locked).
4
+ *
5
+ * This is a PAYOUT, never an order charge. The customer delivery fee and the
6
+ * rider fee are separate numbers:
7
+ *
8
+ * - DELIVERY_CHARGES_FULL: the rider receives the order's full delivery charge.
9
+ * - DISTANCE_ONE_WAY: distance * rider_revenue_per_meter.
10
+ * - DISTANCE_RETURN: 2 * distance * rider_revenue_per_meter.
11
+ * - NONE: zero.
12
+ *
13
+ * `rider_revenue_per_meter` is stored exactly like `delivery_cost_per_meter`
14
+ * (an integer scaled by 100000), and `static_rider_revenue_multiplier` is
15
+ * treated exactly like `static_delivery_cost_multiplier`: a DISTANCE ROUNDING
16
+ * STEP in metres, not an amount multiplier.
17
+ *
18
+ * Amounts are returned in CENTS. The calculator is pure; callers snapshot the
19
+ * rule and persist the result on the delivery.
20
+ */
21
+ export interface IRiderFeeRule {
22
+ rider_revenue_type: RIDER_FEE_TYPE_ENUM;
23
+ /** Raw tenant value, scaled by 100000 (same storage as delivery_cost_per_meter). */
24
+ rider_revenue_per_meter: number;
25
+ /** Distance rounding step in metres (same semantics as static_delivery_cost_multiplier). */
26
+ static_rider_revenue_multiplier: number;
27
+ }
28
+ export interface IRiderFeeInput {
29
+ rule: IRiderFeeRule;
30
+ /** Final delivery distance in metres. */
31
+ distance_meters: number | null | undefined;
32
+ /** Customer delivery fee in CENTS (order.delivery_details.delivery_cost). */
33
+ delivery_charge_cents: number | null | undefined;
34
+ }
35
+ export interface IRiderFeeResult {
36
+ amount_cents: number;
37
+ base_amount_cents: number;
38
+ /** Distance after applying the rounding step. */
39
+ rounded_distance_meters: number;
40
+ rule_type: RIDER_FEE_TYPE_ENUM;
41
+ per_meter: number;
42
+ distance_step: number;
43
+ delivery_charge_cents: number;
44
+ }
45
+ /**
46
+ * Rounds the distance UP to the configured step. A step of 0/negative means
47
+ * "do not round", matching the delivery-cost branch that only rounds when the
48
+ * setting is truthy.
49
+ */
50
+ export declare function roundRiderFeeDistance(distanceMeters: number, stepMeters: number): number;
51
+ export declare function calculateRiderFee(input: IRiderFeeInput): IRiderFeeResult;
52
+ /** Status written on a newly created delivery; amount is not final yet. */
53
+ export declare const RIDER_EARNINGS_STATUS: {
54
+ readonly PENDING: "PENDING";
55
+ readonly FINAL: "FINAL";
56
+ readonly VOID: "VOID";
57
+ };
58
+ export type TRiderEarningsStatus = (typeof RIDER_EARNINGS_STATUS)[keyof typeof RIDER_EARNINGS_STATUS];
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RIDER_EARNINGS_STATUS = void 0;
4
+ exports.roundRiderFeeDistance = roundRiderFeeDistance;
5
+ exports.calculateRiderFee = calculateRiderFee;
6
+ const delivery_1 = require("../../constants/enums/delivery");
7
+ const rawPerMeter = (value) => {
8
+ const numeric = Number(value);
9
+ return Number.isFinite(numeric) && numeric > 0 ? numeric : 0;
10
+ };
11
+ const nonNegative = (value) => {
12
+ const numeric = Number(value);
13
+ return Number.isFinite(numeric) && numeric > 0 ? numeric : 0;
14
+ };
15
+ /**
16
+ * Rounds the distance UP to the configured step. A step of 0/negative means
17
+ * "do not round", matching the delivery-cost branch that only rounds when the
18
+ * setting is truthy.
19
+ */
20
+ function roundRiderFeeDistance(distanceMeters, stepMeters) {
21
+ const distance = nonNegative(distanceMeters);
22
+ const step = nonNegative(stepMeters);
23
+ if (step <= 0 || distance <= 0)
24
+ return distance;
25
+ return Math.ceil(distance / step) * step;
26
+ }
27
+ function calculateRiderFee(input) {
28
+ const rule = input?.rule;
29
+ const type = rule?.rider_revenue_type ?? delivery_1.RIDER_FEE_TYPE_ENUM.NONE;
30
+ const perMeter = rawPerMeter(rule?.rider_revenue_per_meter);
31
+ const distanceStep = nonNegative(rule?.static_rider_revenue_multiplier);
32
+ const deliveryCharge = nonNegative(input?.delivery_charge_cents);
33
+ const roundedDistance = roundRiderFeeDistance(nonNegative(input?.distance_meters), distanceStep);
34
+ let baseAmount = 0;
35
+ if (type === delivery_1.RIDER_FEE_TYPE_ENUM.DELIVERY_CHARGES_FULL) {
36
+ baseAmount = deliveryCharge;
37
+ }
38
+ else if (type === delivery_1.RIDER_FEE_TYPE_ENUM.DISTANCE_ONE_WAY) {
39
+ // raw per-metre value is scaled by 100000; /1000 turns
40
+ // (metres * raw) into cents.
41
+ baseAmount = Math.round((roundedDistance * perMeter) / 1000);
42
+ }
43
+ else if (type === delivery_1.RIDER_FEE_TYPE_ENUM.DISTANCE_RETURN) {
44
+ baseAmount = Math.round((roundedDistance * perMeter * 2) / 1000);
45
+ }
46
+ else {
47
+ baseAmount = 0;
48
+ }
49
+ return {
50
+ amount_cents: baseAmount,
51
+ base_amount_cents: baseAmount,
52
+ rounded_distance_meters: roundedDistance,
53
+ rule_type: type,
54
+ per_meter: perMeter,
55
+ distance_step: distanceStep,
56
+ delivery_charge_cents: deliveryCharge,
57
+ };
58
+ }
59
+ /** Status written on a newly created delivery; amount is not final yet. */
60
+ exports.RIDER_EARNINGS_STATUS = {
61
+ PENDING: 'PENDING',
62
+ FINAL: 'FINAL',
63
+ VOID: 'VOID',
64
+ };
@@ -0,0 +1,2 @@
1
+ export * from './rider-daily-report';
2
+ export * from './rider-report';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./rider-daily-report"), exports);
18
+ __exportStar(require("./rider-report"), exports);
@@ -0,0 +1,26 @@
1
+ import { IMaterializedRiderDailyReport } from '../../schemas/types/materialized_rider_daily_reports';
2
+ /**
3
+ * Builds one rider-day materialized document from delivery source rows.
4
+ *
5
+ * Pure on purpose: the rider daily writer is a thin DB adapter around this, so
6
+ * the payout/totals/tenant-breakdown rules are unit-testable without Mongo.
7
+ */
8
+ export interface IRiderDailySourceDelivery {
9
+ status?: string | null;
10
+ tenant_id?: string | null;
11
+ createdAt?: Date | string | null;
12
+ distance_in_meters_from_store?: number | null;
13
+ expected_delivery_at?: Date | string | null;
14
+ delivered_at?: Date | string | null;
15
+ rider_revenue?: number | null;
16
+ rider_earnings?: {
17
+ amount?: number | null;
18
+ status?: string | null;
19
+ } | null;
20
+ }
21
+ export declare function buildRiderDailyReport({ rider_id, local_date, deliveries, computedAt, }: {
22
+ rider_id: string;
23
+ local_date: string;
24
+ deliveries: IRiderDailySourceDelivery[];
25
+ computedAt?: Date;
26
+ }): IMaterializedRiderDailyReport | null;