@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.
Files changed (336) hide show
  1. package/esm/constants/MATERIALIZED_REPORTS.js +448 -0
  2. package/esm/constants/enums/communications.js +1 -0
  3. package/esm/helpers/index.js +3 -0
  4. package/esm/helpers/materialized-reports/index.js +32 -0
  5. package/esm/helpers/materialized-reports/materialized-cash-accumulator-helpers.js +114 -0
  6. package/esm/helpers/materialized-reports/materialized-cash-classification-helpers.js +286 -0
  7. package/esm/helpers/materialized-reports/materialized-cash-close-day-helpers.js +396 -0
  8. package/esm/helpers/materialized-reports/materialized-cash-compile-helpers.js +244 -0
  9. package/esm/helpers/materialized-reports/materialized-delivery-accumulator-helpers.js +170 -0
  10. package/esm/helpers/materialized-reports/materialized-delivery-classification-helpers.js +426 -0
  11. package/esm/helpers/materialized-reports/materialized-delivery-close-day-helpers.js +372 -0
  12. package/esm/helpers/materialized-reports/materialized-delivery-compile-helpers.js +214 -0
  13. package/esm/helpers/materialized-reports/materialized-discount-accumulator-helpers.js +318 -0
  14. package/esm/helpers/materialized-reports/materialized-discount-classification-helpers.js +213 -0
  15. package/esm/helpers/materialized-reports/materialized-discount-close-day-helpers.js +604 -0
  16. package/esm/helpers/materialized-reports/materialized-discount-compile-helpers.js +186 -0
  17. package/esm/helpers/materialized-reports/materialized-hourly-comparison-close-day-helpers.js +155 -0
  18. package/esm/helpers/materialized-reports/materialized-hourly-comparison-compile-helpers.js +199 -0
  19. package/esm/helpers/materialized-reports/materialized-hourly-comparison-selection-helpers.js +111 -0
  20. package/esm/helpers/materialized-reports/materialized-payments-comparison-accumulator-helpers.js +88 -0
  21. package/esm/helpers/materialized-reports/materialized-payments-comparison-close-day-helpers.js +394 -0
  22. package/esm/helpers/materialized-reports/materialized-payments-comparison-compile-helpers.js +167 -0
  23. package/esm/helpers/materialized-reports/materialized-prep-time-classification-helpers.js +215 -0
  24. package/esm/helpers/materialized-reports/materialized-prep-time-close-day-helpers.js +476 -0
  25. package/esm/helpers/materialized-reports/materialized-prep-time-compile-helpers.js +201 -0
  26. package/esm/helpers/materialized-reports/materialized-reports-selection-helpers.js +7 -0
  27. package/esm/helpers/materialized-reports/materialized-sales-comparison-accumulator-helpers.js +189 -0
  28. package/esm/helpers/materialized-reports/materialized-sales-comparison-baseline-helpers.js +157 -0
  29. package/esm/helpers/materialized-reports/materialized-sales-comparison-close-day-helpers.js +588 -0
  30. package/esm/helpers/materialized-reports/materialized-sales-comparison-compile-helpers.js +175 -0
  31. package/esm/helpers/materialized-reports/tenant-cash-in-out-formatter.js +156 -0
  32. package/esm/helpers/materialized-reports/tenant-delivery-formatter.js +230 -0
  33. package/esm/helpers/materialized-reports/tenant-discount-formatter.js +427 -0
  34. package/esm/helpers/materialized-reports/tenant-hourly-comparison-formatter.js +237 -0
  35. package/esm/helpers/materialized-reports/tenant-payments-comparison-formatter.js +279 -0
  36. package/esm/helpers/materialized-reports/tenant-prep-time-formatter.js +228 -0
  37. package/esm/helpers/materialized-reports/tenant-sales-comparison-formatter.js +343 -0
  38. package/esm/helpers/reporting-contract/index.js +2 -0
  39. package/esm/helpers/reporting-contract/overview-contract.js +122 -0
  40. package/esm/helpers/reporting-contract/report-contract.js +228 -0
  41. package/esm/helpers/rider-earnings/index.js +1 -0
  42. package/esm/helpers/rider-earnings/rider-earnings.js +59 -0
  43. package/esm/helpers/rider-reports/index.js +2 -0
  44. package/esm/helpers/rider-reports/rider-daily-report.js +90 -0
  45. package/esm/helpers/rider-reports/rider-report.js +67 -0
  46. package/esm/schemas/models/deliveries.js +75 -0
  47. package/esm/schemas/models/index.js +15 -0
  48. package/esm/schemas/models/materialized_rider_daily_reports.js +39 -0
  49. package/esm/schemas/models/materialized_tenant_cash_entries.js +95 -0
  50. package/esm/schemas/models/materialized_tenant_cash_reports.js +77 -0
  51. package/esm/schemas/models/materialized_tenant_delivery_entries.js +63 -0
  52. package/esm/schemas/models/materialized_tenant_delivery_reports.js +63 -0
  53. package/esm/schemas/models/materialized_tenant_discount_entries.js +156 -0
  54. package/esm/schemas/models/materialized_tenant_discount_reports.js +333 -0
  55. package/esm/schemas/models/materialized_tenant_hourly_comparison_entries.js +87 -0
  56. package/esm/schemas/models/materialized_tenant_hourly_comparison_reports.js +99 -0
  57. package/esm/schemas/models/materialized_tenant_payments_comparison_entries.js +71 -0
  58. package/esm/schemas/models/materialized_tenant_payments_comparison_reports.js +76 -0
  59. package/esm/schemas/models/materialized_tenant_prep_time_entries.js +130 -0
  60. package/esm/schemas/models/materialized_tenant_prep_time_reports.js +109 -0
  61. package/esm/schemas/models/materialized_tenant_sales_comparison_entries.js +130 -0
  62. package/esm/schemas/models/materialized_tenant_sales_comparison_reports.js +154 -0
  63. package/esm/schemas/types/index.js +15 -0
  64. package/esm/schemas/types/materialized_rider_daily_reports.js +1 -0
  65. package/esm/schemas/types/materialized_tenant_cash_entries.js +1 -0
  66. package/esm/schemas/types/materialized_tenant_cash_reports.js +1 -0
  67. package/esm/schemas/types/materialized_tenant_delivery_entries.js +1 -0
  68. package/esm/schemas/types/materialized_tenant_delivery_reports.js +1 -0
  69. package/esm/schemas/types/materialized_tenant_discount_entries.js +1 -0
  70. package/esm/schemas/types/materialized_tenant_discount_reports.js +2 -0
  71. package/esm/schemas/types/materialized_tenant_hourly_comparison_entries.js +1 -0
  72. package/esm/schemas/types/materialized_tenant_hourly_comparison_reports.js +1 -0
  73. package/esm/schemas/types/materialized_tenant_payments_comparison_entries.js +1 -0
  74. package/esm/schemas/types/materialized_tenant_payments_comparison_reports.js +11 -0
  75. package/esm/schemas/types/materialized_tenant_prep_time_entries.js +1 -0
  76. package/esm/schemas/types/materialized_tenant_prep_time_reports.js +1 -0
  77. package/esm/schemas/types/materialized_tenant_sales_comparison_entries.js +1 -0
  78. package/esm/schemas/types/materialized_tenant_sales_comparison_reports.js +14 -0
  79. package/lib/constants/MATERIALIZED_REPORTS.d.ts +339 -2
  80. package/lib/constants/MATERIALIZED_REPORTS.js +450 -1
  81. package/lib/constants/enums/communications.d.ts +1 -0
  82. package/lib/constants/enums/communications.js +2 -1
  83. package/lib/helpers/index.d.ts +3 -0
  84. package/lib/helpers/index.js +3 -0
  85. package/lib/helpers/materialized-reports/index.d.ts +32 -0
  86. package/lib/helpers/materialized-reports/index.js +32 -0
  87. package/lib/helpers/materialized-reports/materialized-cash-accumulator-helpers.d.ts +18 -0
  88. package/lib/helpers/materialized-reports/materialized-cash-accumulator-helpers.js +118 -0
  89. package/lib/helpers/materialized-reports/materialized-cash-classification-helpers.d.ts +90 -0
  90. package/lib/helpers/materialized-reports/materialized-cash-classification-helpers.js +295 -0
  91. package/lib/helpers/materialized-reports/materialized-cash-close-day-helpers.d.ts +102 -0
  92. package/lib/helpers/materialized-reports/materialized-cash-close-day-helpers.js +409 -0
  93. package/lib/helpers/materialized-reports/materialized-cash-compile-helpers.d.ts +72 -0
  94. package/lib/helpers/materialized-reports/materialized-cash-compile-helpers.js +251 -0
  95. package/lib/helpers/materialized-reports/materialized-delivery-accumulator-helpers.d.ts +7 -0
  96. package/lib/helpers/materialized-reports/materialized-delivery-accumulator-helpers.js +173 -0
  97. package/lib/helpers/materialized-reports/materialized-delivery-classification-helpers.d.ts +84 -0
  98. package/lib/helpers/materialized-reports/materialized-delivery-classification-helpers.js +438 -0
  99. package/lib/helpers/materialized-reports/materialized-delivery-close-day-helpers.d.ts +97 -0
  100. package/lib/helpers/materialized-reports/materialized-delivery-close-day-helpers.js +385 -0
  101. package/lib/helpers/materialized-reports/materialized-delivery-compile-helpers.d.ts +40 -0
  102. package/lib/helpers/materialized-reports/materialized-delivery-compile-helpers.js +218 -0
  103. package/lib/helpers/materialized-reports/materialized-discount-accumulator-helpers.d.ts +52 -0
  104. package/lib/helpers/materialized-reports/materialized-discount-accumulator-helpers.js +324 -0
  105. package/lib/helpers/materialized-reports/materialized-discount-classification-helpers.d.ts +50 -0
  106. package/lib/helpers/materialized-reports/materialized-discount-classification-helpers.js +222 -0
  107. package/lib/helpers/materialized-reports/materialized-discount-close-day-helpers.d.ts +182 -0
  108. package/lib/helpers/materialized-reports/materialized-discount-close-day-helpers.js +615 -0
  109. package/lib/helpers/materialized-reports/materialized-discount-compile-helpers.d.ts +47 -0
  110. package/lib/helpers/materialized-reports/materialized-discount-compile-helpers.js +193 -0
  111. package/lib/helpers/materialized-reports/materialized-hourly-comparison-close-day-helpers.d.ts +64 -0
  112. package/lib/helpers/materialized-reports/materialized-hourly-comparison-close-day-helpers.js +163 -0
  113. package/lib/helpers/materialized-reports/materialized-hourly-comparison-compile-helpers.d.ts +61 -0
  114. package/lib/helpers/materialized-reports/materialized-hourly-comparison-compile-helpers.js +207 -0
  115. package/lib/helpers/materialized-reports/materialized-hourly-comparison-selection-helpers.d.ts +23 -0
  116. package/lib/helpers/materialized-reports/materialized-hourly-comparison-selection-helpers.js +116 -0
  117. package/lib/helpers/materialized-reports/materialized-payments-comparison-accumulator-helpers.d.ts +25 -0
  118. package/lib/helpers/materialized-reports/materialized-payments-comparison-accumulator-helpers.js +98 -0
  119. package/lib/helpers/materialized-reports/materialized-payments-comparison-close-day-helpers.d.ts +79 -0
  120. package/lib/helpers/materialized-reports/materialized-payments-comparison-close-day-helpers.js +407 -0
  121. package/lib/helpers/materialized-reports/materialized-payments-comparison-compile-helpers.d.ts +35 -0
  122. package/lib/helpers/materialized-reports/materialized-payments-comparison-compile-helpers.js +173 -0
  123. package/lib/helpers/materialized-reports/materialized-prep-time-classification-helpers.d.ts +66 -0
  124. package/lib/helpers/materialized-reports/materialized-prep-time-classification-helpers.js +224 -0
  125. package/lib/helpers/materialized-reports/materialized-prep-time-close-day-helpers.d.ts +128 -0
  126. package/lib/helpers/materialized-reports/materialized-prep-time-close-day-helpers.js +490 -0
  127. package/lib/helpers/materialized-reports/materialized-prep-time-compile-helpers.d.ts +46 -0
  128. package/lib/helpers/materialized-reports/materialized-prep-time-compile-helpers.js +208 -0
  129. package/lib/helpers/materialized-reports/materialized-reports-selection-helpers.d.ts +8 -0
  130. package/lib/helpers/materialized-reports/materialized-reports-selection-helpers.js +8 -1
  131. package/lib/helpers/materialized-reports/materialized-sales-comparison-accumulator-helpers.d.ts +48 -0
  132. package/lib/helpers/materialized-reports/materialized-sales-comparison-accumulator-helpers.js +204 -0
  133. package/lib/helpers/materialized-reports/materialized-sales-comparison-baseline-helpers.d.ts +22 -0
  134. package/lib/helpers/materialized-reports/materialized-sales-comparison-baseline-helpers.js +161 -0
  135. package/lib/helpers/materialized-reports/materialized-sales-comparison-close-day-helpers.d.ts +163 -0
  136. package/lib/helpers/materialized-reports/materialized-sales-comparison-close-day-helpers.js +603 -0
  137. package/lib/helpers/materialized-reports/materialized-sales-comparison-compile-helpers.d.ts +68 -0
  138. package/lib/helpers/materialized-reports/materialized-sales-comparison-compile-helpers.js +182 -0
  139. package/lib/helpers/materialized-reports/tenant-cash-in-out-formatter.d.ts +98 -0
  140. package/lib/helpers/materialized-reports/tenant-cash-in-out-formatter.js +159 -0
  141. package/lib/helpers/materialized-reports/tenant-delivery-formatter.d.ts +133 -0
  142. package/lib/helpers/materialized-reports/tenant-delivery-formatter.js +233 -0
  143. package/lib/helpers/materialized-reports/tenant-discount-formatter.d.ts +114 -0
  144. package/lib/helpers/materialized-reports/tenant-discount-formatter.js +431 -0
  145. package/lib/helpers/materialized-reports/tenant-hourly-comparison-formatter.d.ts +60 -0
  146. package/lib/helpers/materialized-reports/tenant-hourly-comparison-formatter.js +243 -0
  147. package/lib/helpers/materialized-reports/tenant-payments-comparison-formatter.d.ts +75 -0
  148. package/lib/helpers/materialized-reports/tenant-payments-comparison-formatter.js +286 -0
  149. package/lib/helpers/materialized-reports/tenant-prep-time-formatter.d.ts +97 -0
  150. package/lib/helpers/materialized-reports/tenant-prep-time-formatter.js +232 -0
  151. package/lib/helpers/materialized-reports/tenant-sales-comparison-formatter.d.ts +105 -0
  152. package/lib/helpers/materialized-reports/tenant-sales-comparison-formatter.js +349 -0
  153. package/lib/helpers/reporting-contract/index.d.ts +2 -0
  154. package/lib/helpers/reporting-contract/index.js +18 -0
  155. package/lib/helpers/reporting-contract/overview-contract.d.ts +55 -0
  156. package/lib/helpers/reporting-contract/overview-contract.js +126 -0
  157. package/lib/helpers/reporting-contract/report-contract.d.ts +159 -0
  158. package/lib/helpers/reporting-contract/report-contract.js +239 -0
  159. package/lib/helpers/rider-earnings/index.d.ts +1 -0
  160. package/lib/helpers/rider-earnings/index.js +17 -0
  161. package/lib/helpers/rider-earnings/rider-earnings.d.ts +58 -0
  162. package/lib/helpers/rider-earnings/rider-earnings.js +64 -0
  163. package/lib/helpers/rider-reports/index.d.ts +2 -0
  164. package/lib/helpers/rider-reports/index.js +18 -0
  165. package/lib/helpers/rider-reports/rider-daily-report.d.ts +26 -0
  166. package/lib/helpers/rider-reports/rider-daily-report.js +93 -0
  167. package/lib/helpers/rider-reports/rider-report.d.ts +49 -0
  168. package/lib/helpers/rider-reports/rider-report.js +70 -0
  169. package/lib/helpers/types/materialized-reports-apis.d.ts +297 -1
  170. package/lib/schemas/models/deliveries.d.ts +54 -0
  171. package/lib/schemas/models/deliveries.js +75 -0
  172. package/lib/schemas/models/expense_details.d.ts +3 -3
  173. package/lib/schemas/models/index.d.ts +15 -0
  174. package/lib/schemas/models/index.js +15 -0
  175. package/lib/schemas/models/materialized_rider_daily_reports.d.ts +27 -0
  176. package/lib/schemas/models/materialized_rider_daily_reports.js +42 -0
  177. package/lib/schemas/models/materialized_tenant_cash_entries.d.ts +181 -0
  178. package/lib/schemas/models/materialized_tenant_cash_entries.js +98 -0
  179. package/lib/schemas/models/materialized_tenant_cash_reports.d.ts +111 -0
  180. package/lib/schemas/models/materialized_tenant_cash_reports.js +80 -0
  181. package/lib/schemas/models/materialized_tenant_delivery_entries.d.ts +98 -0
  182. package/lib/schemas/models/materialized_tenant_delivery_entries.js +66 -0
  183. package/lib/schemas/models/materialized_tenant_delivery_reports.d.ts +98 -0
  184. package/lib/schemas/models/materialized_tenant_delivery_reports.js +66 -0
  185. package/lib/schemas/models/materialized_tenant_discount_entries.d.ts +199 -0
  186. package/lib/schemas/models/materialized_tenant_discount_entries.js +159 -0
  187. package/lib/schemas/models/materialized_tenant_discount_reports.d.ts +216 -0
  188. package/lib/schemas/models/materialized_tenant_discount_reports.js +336 -0
  189. package/lib/schemas/models/materialized_tenant_hourly_comparison_entries.d.ts +95 -0
  190. package/lib/schemas/models/materialized_tenant_hourly_comparison_entries.js +82 -0
  191. package/lib/schemas/models/materialized_tenant_hourly_comparison_reports.d.ts +105 -0
  192. package/lib/schemas/models/materialized_tenant_hourly_comparison_reports.js +91 -0
  193. package/lib/schemas/models/materialized_tenant_payments_comparison_entries.d.ts +91 -0
  194. package/lib/schemas/models/materialized_tenant_payments_comparison_entries.js +70 -0
  195. package/lib/schemas/models/materialized_tenant_payments_comparison_reports.d.ts +98 -0
  196. package/lib/schemas/models/materialized_tenant_payments_comparison_reports.js +71 -0
  197. package/lib/schemas/models/materialized_tenant_prep_time_entries.d.ts +181 -0
  198. package/lib/schemas/models/materialized_tenant_prep_time_entries.js +133 -0
  199. package/lib/schemas/models/materialized_tenant_prep_time_reports.d.ts +118 -0
  200. package/lib/schemas/models/materialized_tenant_prep_time_reports.js +112 -0
  201. package/lib/schemas/models/materialized_tenant_sales_comparison_entries.d.ts +139 -0
  202. package/lib/schemas/models/materialized_tenant_sales_comparison_entries.js +120 -0
  203. package/lib/schemas/models/materialized_tenant_sales_comparison_reports.d.ts +167 -0
  204. package/lib/schemas/models/materialized_tenant_sales_comparison_reports.js +137 -0
  205. package/lib/schemas/models/tenant_purchase_order_vendor_returns.d.ts +3 -3
  206. package/lib/schemas/models/warehouse_internal_movements.d.ts +6 -6
  207. package/lib/schemas/models/warehouse_purchase_order_receipts.d.ts +3 -3
  208. package/lib/schemas/models/warehouse_purchase_order_vendor_returns.d.ts +3 -3
  209. package/lib/schemas/models/warehouse_sale_deliveries.d.ts +6 -6
  210. package/lib/schemas/models/warehouse_sale_invoices.d.ts +3 -3
  211. package/lib/schemas/types/deliveries.d.ts +40 -1
  212. package/lib/schemas/types/index.d.ts +15 -0
  213. package/lib/schemas/types/index.js +15 -0
  214. package/lib/schemas/types/materialized_rider_daily_reports.d.ts +37 -0
  215. package/lib/schemas/types/materialized_rider_daily_reports.js +2 -0
  216. package/lib/schemas/types/materialized_tenant_cash_entries.d.ts +87 -0
  217. package/lib/schemas/types/materialized_tenant_cash_entries.js +2 -0
  218. package/lib/schemas/types/materialized_tenant_cash_reports.d.ts +144 -0
  219. package/lib/schemas/types/materialized_tenant_cash_reports.js +2 -0
  220. package/lib/schemas/types/materialized_tenant_delivery_entries.d.ts +98 -0
  221. package/lib/schemas/types/materialized_tenant_delivery_entries.js +2 -0
  222. package/lib/schemas/types/materialized_tenant_delivery_reports.d.ts +179 -0
  223. package/lib/schemas/types/materialized_tenant_delivery_reports.js +2 -0
  224. package/lib/schemas/types/materialized_tenant_discount_entries.d.ts +81 -0
  225. package/lib/schemas/types/materialized_tenant_discount_entries.js +2 -0
  226. package/lib/schemas/types/materialized_tenant_discount_reports.d.ts +209 -0
  227. package/lib/schemas/types/materialized_tenant_discount_reports.js +3 -0
  228. package/lib/schemas/types/materialized_tenant_hourly_comparison_entries.d.ts +33 -0
  229. package/lib/schemas/types/materialized_tenant_hourly_comparison_entries.js +2 -0
  230. package/lib/schemas/types/materialized_tenant_hourly_comparison_reports.d.ts +40 -0
  231. package/lib/schemas/types/materialized_tenant_hourly_comparison_reports.js +2 -0
  232. package/lib/schemas/types/materialized_tenant_payments_comparison_entries.d.ts +48 -0
  233. package/lib/schemas/types/materialized_tenant_payments_comparison_entries.js +2 -0
  234. package/lib/schemas/types/materialized_tenant_payments_comparison_reports.d.ts +51 -0
  235. package/lib/schemas/types/materialized_tenant_payments_comparison_reports.js +14 -0
  236. package/lib/schemas/types/materialized_tenant_prep_time_entries.d.ts +88 -0
  237. package/lib/schemas/types/materialized_tenant_prep_time_entries.js +2 -0
  238. package/lib/schemas/types/materialized_tenant_prep_time_reports.d.ts +132 -0
  239. package/lib/schemas/types/materialized_tenant_prep_time_reports.js +2 -0
  240. package/lib/schemas/types/materialized_tenant_sales_comparison_entries.d.ts +43 -0
  241. package/lib/schemas/types/materialized_tenant_sales_comparison_entries.js +2 -0
  242. package/lib/schemas/types/materialized_tenant_sales_comparison_reports.d.ts +74 -0
  243. package/lib/schemas/types/materialized_tenant_sales_comparison_reports.js +17 -0
  244. package/lib/tests/materialized-reports/analytics-growth-helpers.test.d.ts +1 -0
  245. package/lib/tests/materialized-reports/analytics-overview-helpers.test.d.ts +1 -0
  246. package/lib/tests/materialized-reports/analytics-performance-helpers.test.d.ts +1 -0
  247. package/lib/tests/materialized-reports/fixtures.d.ts +15 -1
  248. package/lib/tests/materialized-reports/fixtures.js +1 -0
  249. package/lib/tests/materialized-reports/materialized-cash-compile.test.d.ts +1 -0
  250. package/lib/tests/materialized-reports/materialized-cash-compile.test.js +196 -0
  251. package/lib/tests/materialized-reports/materialized-cash-fold.test.d.ts +1 -0
  252. package/lib/tests/materialized-reports/materialized-cash-fold.test.js +116 -0
  253. package/lib/tests/materialized-reports/materialized-cash-formatter.test.d.ts +1 -0
  254. package/lib/tests/materialized-reports/materialized-cash-formatter.test.js +152 -0
  255. package/lib/tests/materialized-reports/materialized-cash-plan.test.d.ts +1 -0
  256. package/lib/tests/materialized-reports/materialized-cash-plan.test.js +168 -0
  257. package/lib/tests/materialized-reports/materialized-cash-reconciliation.test.d.ts +1 -0
  258. package/lib/tests/materialized-reports/materialized-cash-reconciliation.test.js +267 -0
  259. package/lib/tests/materialized-reports/materialized-delivery-accumulation.test.d.ts +1 -0
  260. package/lib/tests/materialized-reports/materialized-delivery-accumulation.test.js +147 -0
  261. package/lib/tests/materialized-reports/materialized-delivery-compile.test.d.ts +1 -0
  262. package/lib/tests/materialized-reports/materialized-delivery-compile.test.js +241 -0
  263. package/lib/tests/materialized-reports/materialized-delivery-fold.test.d.ts +1 -0
  264. package/lib/tests/materialized-reports/materialized-delivery-fold.test.js +109 -0
  265. package/lib/tests/materialized-reports/materialized-delivery-formatter.test.d.ts +1 -0
  266. package/lib/tests/materialized-reports/materialized-delivery-formatter.test.js +141 -0
  267. package/lib/tests/materialized-reports/materialized-delivery-plan.test.d.ts +1 -0
  268. package/lib/tests/materialized-reports/materialized-delivery-plan.test.js +198 -0
  269. package/lib/tests/materialized-reports/materialized-discount-aggregated-formatter.test.d.ts +1 -0
  270. package/lib/tests/materialized-reports/materialized-discount-aggregated-formatter.test.js +173 -0
  271. package/lib/tests/materialized-reports/materialized-discount-classification.test.d.ts +1 -0
  272. package/lib/tests/materialized-reports/materialized-discount-classification.test.js +339 -0
  273. package/lib/tests/materialized-reports/materialized-discount-close-day.test.d.ts +1 -0
  274. package/lib/tests/materialized-reports/materialized-discount-close-day.test.js +506 -0
  275. package/lib/tests/materialized-reports/materialized-discount-compile.test.d.ts +1 -0
  276. package/lib/tests/materialized-reports/materialized-discount-compile.test.js +161 -0
  277. package/lib/tests/materialized-reports/materialized-discount-counter-rows.test.d.ts +1 -0
  278. package/lib/tests/materialized-reports/materialized-discount-counter-rows.test.js +107 -0
  279. package/lib/tests/materialized-reports/materialized-discount-entries-accumulation.test.d.ts +1 -0
  280. package/lib/tests/materialized-reports/materialized-discount-entries-accumulation.test.js +125 -0
  281. package/lib/tests/materialized-reports/materialized-hourly-comparison-compile.test.d.ts +1 -0
  282. package/lib/tests/materialized-reports/materialized-hourly-comparison-compile.test.js +146 -0
  283. package/lib/tests/materialized-reports/materialized-hourly-comparison-formatter.test.d.ts +1 -0
  284. package/lib/tests/materialized-reports/materialized-hourly-comparison-formatter.test.js +127 -0
  285. package/lib/tests/materialized-reports/materialized-hourly-comparison-plan.test.d.ts +1 -0
  286. package/lib/tests/materialized-reports/materialized-hourly-comparison-plan.test.js +138 -0
  287. package/lib/tests/materialized-reports/materialized-hourly-comparison-selection.test.d.ts +1 -0
  288. package/lib/tests/materialized-reports/materialized-hourly-comparison-selection.test.js +90 -0
  289. package/lib/tests/materialized-reports/materialized-payments-comparison-compile.test.d.ts +1 -0
  290. package/lib/tests/materialized-reports/materialized-payments-comparison-compile.test.js +164 -0
  291. package/lib/tests/materialized-reports/materialized-payments-comparison-formatter.test.d.ts +1 -0
  292. package/lib/tests/materialized-reports/materialized-payments-comparison-formatter.test.js +117 -0
  293. package/lib/tests/materialized-reports/materialized-payments-comparison-plan.test.d.ts +1 -0
  294. package/lib/tests/materialized-reports/materialized-payments-comparison-plan.test.js +149 -0
  295. package/lib/tests/materialized-reports/materialized-prep-time-classification.test.d.ts +1 -0
  296. package/lib/tests/materialized-reports/materialized-prep-time-classification.test.js +273 -0
  297. package/lib/tests/materialized-reports/materialized-prep-time-close-day.test.d.ts +1 -0
  298. package/lib/tests/materialized-reports/materialized-prep-time-close-day.test.js +270 -0
  299. package/lib/tests/materialized-reports/materialized-prep-time-compile.test.d.ts +1 -0
  300. package/lib/tests/materialized-reports/materialized-prep-time-compile.test.js +217 -0
  301. package/lib/tests/materialized-reports/materialized-prep-time-constants.test.d.ts +1 -0
  302. package/lib/tests/materialized-reports/materialized-prep-time-constants.test.js +84 -0
  303. package/lib/tests/materialized-reports/materialized-prep-time-plan.test.d.ts +1 -0
  304. package/lib/tests/materialized-reports/materialized-prep-time-plan.test.js +176 -0
  305. package/lib/tests/materialized-reports/materialized-sales-comparison-baseline.test.d.ts +1 -0
  306. package/lib/tests/materialized-reports/materialized-sales-comparison-baseline.test.js +126 -0
  307. package/lib/tests/materialized-reports/materialized-sales-comparison-compile.test.d.ts +1 -0
  308. package/lib/tests/materialized-reports/materialized-sales-comparison-compile.test.js +206 -0
  309. package/lib/tests/materialized-reports/materialized-sales-comparison-formatter.test.d.ts +1 -0
  310. package/lib/tests/materialized-reports/materialized-sales-comparison-formatter.test.js +179 -0
  311. package/lib/tests/materialized-reports/materialized-sales-comparison-parity.test.d.ts +1 -0
  312. package/lib/tests/materialized-reports/materialized-sales-comparison-parity.test.js +196 -0
  313. package/lib/tests/materialized-reports/materialized-sales-comparison-plan.test.d.ts +1 -0
  314. package/lib/tests/materialized-reports/materialized-sales-comparison-plan.test.js +241 -0
  315. package/lib/tests/materialized-reports/materialized-tenant-hourly-comparison-schema.test.d.ts +1 -0
  316. package/lib/tests/materialized-reports/materialized-tenant-hourly-comparison-schema.test.js +96 -0
  317. package/lib/tests/materialized-reports/materialized-tenant-payments-comparison-schema.test.d.ts +1 -0
  318. package/lib/tests/materialized-reports/materialized-tenant-payments-comparison-schema.test.js +112 -0
  319. package/lib/tests/materialized-reports/materialized-tenant-sales-comparison-schema.test.d.ts +1 -0
  320. package/lib/tests/materialized-reports/materialized-tenant-sales-comparison-schema.test.js +142 -0
  321. package/lib/tests/materialized-reports/materialized-tenant-sales-overview-reports-schema.test.js +8 -1
  322. package/lib/tests/materialized-reports/sales-comparison-reference.d.ts +55 -0
  323. package/lib/tests/materialized-reports/sales-comparison-reference.js +86 -0
  324. package/lib/tests/materialized-reports/tenant-discount-formatter.test.d.ts +1 -0
  325. package/lib/tests/materialized-reports/tenant-discount-formatter.test.js +289 -0
  326. package/lib/tests/materialized-reports/tenant-prep-time-formatter.test.d.ts +1 -0
  327. package/lib/tests/materialized-reports/tenant-prep-time-formatter.test.js +354 -0
  328. package/lib/tests/reporting-contract.test.d.ts +1 -0
  329. package/lib/tests/reporting-contract.test.js +267 -0
  330. package/lib/tests/rider-daily-report.test.d.ts +1 -0
  331. package/lib/tests/rider-daily-report.test.js +86 -0
  332. package/lib/tests/rider-earnings.test.d.ts +1 -0
  333. package/lib/tests/rider-earnings.test.js +65 -0
  334. package/lib/tests/rider-report.test.d.ts +1 -0
  335. package/lib/tests/rider-report.test.js +98 -0
  336. package/package.json +10 -1
@@ -0,0 +1,181 @@
1
+ import { Schema } from 'mongoose';
2
+ /**
3
+ * Mongoose schema for `materialized_tenant_prep_time_entries` - the ITEMIZED prep
4
+ * rows behind the prep time report's drill-down (owner decision (a2): SPLIT).
5
+ * See `schemas/types/materialized_tenant_prep_time_entries.ts` and
6
+ * `docs/report-prep-time-concept.md`.
7
+ *
8
+ * Scopes are capped at `LOCAL_MONTH` so a document can never grow unboundedly.
9
+ * Rows are slim; each carries `entry_key`, its stable identity INSIDE an order,
10
+ * so the `(time, order_id, entry_key)` cursor can never collide.
11
+ *
12
+ * Rows are ALSO the only place a fallback-anchored item can be inspected, so
13
+ * each row states its `anchor` - a degenerate 0-minute fallback row is visibly
14
+ * different from a genuinely instant measured one.
15
+ */
16
+ /**
17
+ * Version of the prep time ENTRY rules of this collection. Bump when row
18
+ * semantics change (new fields, different identity, different duration rule) -
19
+ * historical documents must then be re-materialized. PRE-RELEASE: folds into
20
+ * version `1`.
21
+ */
22
+ export declare const MATERIALIZED_TENANT_PREP_TIME_ENTRIES_SCHEMA_VERSION = 1;
23
+ declare const PrepTimeEntrySchema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
24
+ _id: false;
25
+ }, {
26
+ order_id: string;
27
+ platform: string;
28
+ staff_id: string;
29
+ staff_name: string;
30
+ anchor: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_PREP_TIME_ANCHOR_ENUM;
31
+ order_number: number;
32
+ order_status: string;
33
+ item_id: string;
34
+ is_ready: boolean;
35
+ prep_started_at: NativeDate;
36
+ entry_key: string;
37
+ item_name: string;
38
+ created_at: NativeDate;
39
+ local_hour: string;
40
+ target_at: NativeDate;
41
+ target_source: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_PREP_TIME_TARGET_ENUM | null;
42
+ category_name: string;
43
+ duration_minutes: number;
44
+ ready_at: NativeDate;
45
+ delta_minutes: number;
46
+ }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
47
+ order_id: string;
48
+ platform: string;
49
+ staff_id: string;
50
+ staff_name: string;
51
+ anchor: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_PREP_TIME_ANCHOR_ENUM;
52
+ order_number: number;
53
+ order_status: string;
54
+ item_id: string;
55
+ is_ready: boolean;
56
+ prep_started_at: NativeDate;
57
+ entry_key: string;
58
+ item_name: string;
59
+ created_at: NativeDate;
60
+ local_hour: string;
61
+ target_at: NativeDate;
62
+ target_source: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_PREP_TIME_TARGET_ENUM | null;
63
+ category_name: string;
64
+ duration_minutes: number;
65
+ ready_at: NativeDate;
66
+ delta_minutes: number;
67
+ }>> & import("mongoose").FlatRecord<{
68
+ order_id: string;
69
+ platform: string;
70
+ staff_id: string;
71
+ staff_name: string;
72
+ anchor: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_PREP_TIME_ANCHOR_ENUM;
73
+ order_number: number;
74
+ order_status: string;
75
+ item_id: string;
76
+ is_ready: boolean;
77
+ prep_started_at: NativeDate;
78
+ entry_key: string;
79
+ item_name: string;
80
+ created_at: NativeDate;
81
+ local_hour: string;
82
+ target_at: NativeDate;
83
+ target_source: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_PREP_TIME_TARGET_ENUM | null;
84
+ category_name: string;
85
+ duration_minutes: number;
86
+ ready_at: NativeDate;
87
+ delta_minutes: number;
88
+ }> & {
89
+ _id: import("mongoose").Types.ObjectId;
90
+ } & {
91
+ __v: number;
92
+ }>;
93
+ export { PrepTimeEntrySchema };
94
+ export declare const MaterializedTenantPrepTimeEntriesSchema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
95
+ timestamps: true;
96
+ versionKey: false;
97
+ minimize: false;
98
+ }, {
99
+ createdAt: NativeDate;
100
+ updatedAt: NativeDate;
101
+ } & {
102
+ tenant_id: string;
103
+ createdAt: NativeDate;
104
+ updatedAt: NativeDate;
105
+ brand_id: string;
106
+ day_index: import("../../constants/ENUMS").DAY_INDEX_ENUM | null;
107
+ iteration: number;
108
+ scope_context: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_REPORT_SCOPE_ENUM;
109
+ scope_field: string;
110
+ sale_type_key_filters: string[];
111
+ schema_version: number;
112
+ source_watermark: NativeDate;
113
+ computed_at: NativeDate;
114
+ prep_time_entries: any;
115
+ }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
116
+ createdAt: NativeDate;
117
+ updatedAt: NativeDate;
118
+ } & {
119
+ tenant_id: string;
120
+ createdAt: NativeDate;
121
+ updatedAt: NativeDate;
122
+ brand_id: string;
123
+ day_index: import("../../constants/ENUMS").DAY_INDEX_ENUM | null;
124
+ iteration: number;
125
+ scope_context: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_REPORT_SCOPE_ENUM;
126
+ scope_field: string;
127
+ sale_type_key_filters: string[];
128
+ schema_version: number;
129
+ source_watermark: NativeDate;
130
+ computed_at: NativeDate;
131
+ prep_time_entries: any;
132
+ }>> & import("mongoose").FlatRecord<{
133
+ createdAt: NativeDate;
134
+ updatedAt: NativeDate;
135
+ } & {
136
+ tenant_id: string;
137
+ createdAt: NativeDate;
138
+ updatedAt: NativeDate;
139
+ brand_id: string;
140
+ day_index: import("../../constants/ENUMS").DAY_INDEX_ENUM | null;
141
+ iteration: number;
142
+ scope_context: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_REPORT_SCOPE_ENUM;
143
+ scope_field: string;
144
+ sale_type_key_filters: string[];
145
+ schema_version: number;
146
+ source_watermark: NativeDate;
147
+ computed_at: NativeDate;
148
+ prep_time_entries: any;
149
+ }> & {
150
+ _id: import("mongoose").Types.ObjectId;
151
+ } & {
152
+ __v: number;
153
+ }>;
154
+ export declare const MATERIALIZED_TENANT_PREP_TIME_ENTRIES_COLLECTION_NAME = "materialized_tenant_prep_time_entries";
155
+ /**
156
+ * Indexes for `materialized_tenant_prep_time_entries` - the same single UNIQUE
157
+ * compound identity index as every materialized report collection. The
158
+ * `{ tenant_id, scope_context, scope_field }` prefix also serves the
159
+ * drill-down's month-document resolution.
160
+ */
161
+ export declare const MATERIALIZED_TENANT_PREP_TIME_ENTRIES_COLLECTION_INDEXES: {
162
+ _id: {
163
+ _id: number;
164
+ };
165
+ tenant_id__scope_context__scope_field__day_index: {
166
+ tenant_id: number;
167
+ scope_context: number;
168
+ scope_field: number;
169
+ day_index: number;
170
+ };
171
+ };
172
+ export declare const MATERIALIZED_TENANT_PREP_TIME_ENTRIES_INDEX_OPTIONS: {
173
+ key: {
174
+ tenant_id: number;
175
+ scope_context: number;
176
+ scope_field: number;
177
+ day_index: number;
178
+ };
179
+ name: string;
180
+ unique: boolean;
181
+ }[];
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MATERIALIZED_TENANT_PREP_TIME_ENTRIES_INDEX_OPTIONS = exports.MATERIALIZED_TENANT_PREP_TIME_ENTRIES_COLLECTION_INDEXES = exports.MATERIALIZED_TENANT_PREP_TIME_ENTRIES_COLLECTION_NAME = exports.MaterializedTenantPrepTimeEntriesSchema = exports.PrepTimeEntrySchema = exports.MATERIALIZED_TENANT_PREP_TIME_ENTRIES_SCHEMA_VERSION = void 0;
4
+ const mongoose_1 = require("mongoose");
5
+ const ENUMS_1 = require("../../constants/ENUMS");
6
+ const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
7
+ /**
8
+ * Mongoose schema for `materialized_tenant_prep_time_entries` - the ITEMIZED prep
9
+ * rows behind the prep time report's drill-down (owner decision (a2): SPLIT).
10
+ * See `schemas/types/materialized_tenant_prep_time_entries.ts` and
11
+ * `docs/report-prep-time-concept.md`.
12
+ *
13
+ * Scopes are capped at `LOCAL_MONTH` so a document can never grow unboundedly.
14
+ * Rows are slim; each carries `entry_key`, its stable identity INSIDE an order,
15
+ * so the `(time, order_id, entry_key)` cursor can never collide.
16
+ *
17
+ * Rows are ALSO the only place a fallback-anchored item can be inspected, so
18
+ * each row states its `anchor` - a degenerate 0-minute fallback row is visibly
19
+ * different from a genuinely instant measured one.
20
+ */
21
+ /**
22
+ * Version of the prep time ENTRY rules of this collection. Bump when row
23
+ * semantics change (new fields, different identity, different duration rule) -
24
+ * historical documents must then be re-materialized. PRE-RELEASE: folds into
25
+ * version `1`.
26
+ */
27
+ exports.MATERIALIZED_TENANT_PREP_TIME_ENTRIES_SCHEMA_VERSION = 1;
28
+ const PrepTimeEntrySchema = new mongoose_1.Schema({
29
+ entry_key: { type: String, required: true },
30
+ order_id: { type: String, required: true },
31
+ order_number: { type: Number, default: null },
32
+ item_id: { type: String, default: null },
33
+ item_name: { type: String, default: null },
34
+ category_name: { type: String, default: null },
35
+ // ---- measurement ----
36
+ anchor: { type: String, required: true, enum: MATERIALIZED_REPORTS_1.ALL_MATERIALIZED_PREP_TIME_ANCHORS },
37
+ duration_minutes: { type: Number, default: null },
38
+ prep_started_at: { type: mongoose_1.Schema.Types.Date, default: null },
39
+ // Reconstructed (= prep_started_at + ready_minutes), MEASURED rows only.
40
+ ready_at: { type: mongoose_1.Schema.Types.Date, default: null },
41
+ is_ready: { type: Boolean, required: true, default: false },
42
+ // ---- promise ----
43
+ target_at: { type: mongoose_1.Schema.Types.Date, default: null },
44
+ target_source: {
45
+ type: String,
46
+ default: null,
47
+ enum: [...MATERIALIZED_REPORTS_1.ALL_MATERIALIZED_PREP_TIME_TARGETS, null],
48
+ },
49
+ // SIGNED: positive means the item was ready AFTER its target.
50
+ delta_minutes: { type: Number, default: null },
51
+ // ---- attribution ----
52
+ staff_id: { type: String, default: null },
53
+ staff_name: { type: String, default: null },
54
+ order_status: { type: String, required: true, default: '' },
55
+ platform: { type: String, required: true, default: '' },
56
+ created_at: { type: mongoose_1.Schema.Types.Date, required: true },
57
+ local_hour: { type: String, default: null },
58
+ }, { _id: false });
59
+ exports.PrepTimeEntrySchema = PrepTimeEntrySchema;
60
+ exports.MaterializedTenantPrepTimeEntriesSchema = new mongoose_1.Schema({
61
+ tenant_id: { type: String, required: true },
62
+ brand_id: { type: String, required: true },
63
+ scope_context: {
64
+ type: String,
65
+ required: true,
66
+ enum: MATERIALIZED_REPORTS_1.MATERIALIZED_PREP_TIME_REPORT_SCOPES,
67
+ },
68
+ scope_field: { type: String, required: true },
69
+ day_index: {
70
+ type: String,
71
+ default: null,
72
+ enum: [...ENUMS_1.ALL_DAY_INDEX, null],
73
+ },
74
+ sale_type_key_filters: {
75
+ type: [String],
76
+ required: true,
77
+ default: () => [...MATERIALIZED_REPORTS_1.PREP_TIME_KEY_FILTERS],
78
+ validate: {
79
+ validator: (value) => value.length > 0 &&
80
+ value.every((entry) => MATERIALIZED_REPORTS_1.ALL_MATERIALIZED_REPORT_KEY_FILTERS.includes(entry)),
81
+ message: 'sale_type_key_filters must be a non-empty subset of the known key filters',
82
+ },
83
+ },
84
+ // { [sale_type_key]: { rows: [...] } } - pruned when a key has no rows.
85
+ prep_time_entries: {
86
+ type: mongoose_1.Schema.Types.Mixed,
87
+ required: true,
88
+ default: null,
89
+ },
90
+ iteration: { type: Number, required: true, min: 1, default: 1 },
91
+ schema_version: {
92
+ type: Number,
93
+ required: true,
94
+ immutable: true,
95
+ default: exports.MATERIALIZED_TENANT_PREP_TIME_ENTRIES_SCHEMA_VERSION,
96
+ },
97
+ source_watermark: { type: mongoose_1.Schema.Types.Date, required: true },
98
+ computed_at: { type: mongoose_1.Schema.Types.Date, required: true },
99
+ createdAt: {
100
+ type: mongoose_1.Schema.Types.Date,
101
+ required: true,
102
+ default: () => new Date(),
103
+ immutable: true,
104
+ },
105
+ updatedAt: {
106
+ type: mongoose_1.Schema.Types.Date,
107
+ required: true,
108
+ default: () => new Date(),
109
+ },
110
+ }, { timestamps: true, versionKey: false, minimize: false });
111
+ exports.MATERIALIZED_TENANT_PREP_TIME_ENTRIES_COLLECTION_NAME = 'materialized_tenant_prep_time_entries';
112
+ /**
113
+ * Indexes for `materialized_tenant_prep_time_entries` - the same single UNIQUE
114
+ * compound identity index as every materialized report collection. The
115
+ * `{ tenant_id, scope_context, scope_field }` prefix also serves the
116
+ * drill-down's month-document resolution.
117
+ */
118
+ exports.MATERIALIZED_TENANT_PREP_TIME_ENTRIES_COLLECTION_INDEXES = {
119
+ _id: { _id: 1 },
120
+ tenant_id__scope_context__scope_field__day_index: {
121
+ tenant_id: 1,
122
+ scope_context: 1,
123
+ scope_field: 1,
124
+ day_index: 1,
125
+ },
126
+ };
127
+ exports.MATERIALIZED_TENANT_PREP_TIME_ENTRIES_INDEX_OPTIONS = [
128
+ {
129
+ key: { tenant_id: 1, scope_context: 1, scope_field: 1, day_index: 1 },
130
+ name: 'tenant_id__scope_context__scope_field__day_index',
131
+ unique: true,
132
+ },
133
+ ];
@@ -0,0 +1,118 @@
1
+ import { Schema } from 'mongoose';
2
+ /**
3
+ * Mongoose schema for `materialized_tenant_prep_time_reports` (M2).
4
+ *
5
+ * Counters ONLY - the itemized rows live in the SIBLING entries collection
6
+ * (`materialized_tenant_prep_time_entries`, owner decision (a2)). See
7
+ * `schemas/types/materialized_tenant_prep_time_reports.ts` and
8
+ * `docs/report-prep-time-concept.md`.
9
+ *
10
+ * The counters are stored TWICE on purpose: a key-addressed MAP
11
+ * (`prep_time_counters`, the store + formatter shape) and the SAME counters as
12
+ * an ARRAY OF ROWS (`prep_time_counter_rows`, the READ shape). Summing the map
13
+ * inside an aggregation needs nested `$getField` calls (a dotted field name
14
+ * silently matches nothing), `$literal` around every computed field name and an
15
+ * `$arrayToObject` rebuild; with rows the read is the canonical `$unwind` ->
16
+ * `$group` -> direct `$sum` pattern. Both are written from one accumulator pass,
17
+ * so they cannot disagree.
18
+ */
19
+ /**
20
+ * Version of the prep time report COUNTER rules. Bump when counter semantics
21
+ * change (new buckets, a different anchor rule) - historical documents must then
22
+ * be re-materialized. PRE-RELEASE: folds into version `1`.
23
+ */
24
+ export declare const MATERIALIZED_TENANT_PREP_TIME_REPORTS_SCHEMA_VERSION = 1;
25
+ export declare const MaterializedTenantPrepTimeReportSchema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
26
+ timestamps: true;
27
+ versionKey: false;
28
+ minimize: false;
29
+ }, {
30
+ createdAt: NativeDate;
31
+ updatedAt: NativeDate;
32
+ } & {
33
+ tenant_id: string;
34
+ createdAt: NativeDate;
35
+ updatedAt: NativeDate;
36
+ brand_id: string;
37
+ day_index: import("../../constants/ENUMS").DAY_INDEX_ENUM | null;
38
+ iteration: number;
39
+ scope_context: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_REPORT_SCOPE_ENUM;
40
+ scope_field: string;
41
+ sale_type_key_filters: string[];
42
+ schema_version: number;
43
+ source_watermark: NativeDate;
44
+ computed_at: NativeDate;
45
+ prep_time_counters: any;
46
+ prep_time_counter_rows: any;
47
+ }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
48
+ createdAt: NativeDate;
49
+ updatedAt: NativeDate;
50
+ } & {
51
+ tenant_id: string;
52
+ createdAt: NativeDate;
53
+ updatedAt: NativeDate;
54
+ brand_id: string;
55
+ day_index: import("../../constants/ENUMS").DAY_INDEX_ENUM | null;
56
+ iteration: number;
57
+ scope_context: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_REPORT_SCOPE_ENUM;
58
+ scope_field: string;
59
+ sale_type_key_filters: string[];
60
+ schema_version: number;
61
+ source_watermark: NativeDate;
62
+ computed_at: NativeDate;
63
+ prep_time_counters: any;
64
+ prep_time_counter_rows: any;
65
+ }>> & import("mongoose").FlatRecord<{
66
+ createdAt: NativeDate;
67
+ updatedAt: NativeDate;
68
+ } & {
69
+ tenant_id: string;
70
+ createdAt: NativeDate;
71
+ updatedAt: NativeDate;
72
+ brand_id: string;
73
+ day_index: import("../../constants/ENUMS").DAY_INDEX_ENUM | null;
74
+ iteration: number;
75
+ scope_context: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_REPORT_SCOPE_ENUM;
76
+ scope_field: string;
77
+ sale_type_key_filters: string[];
78
+ schema_version: number;
79
+ source_watermark: NativeDate;
80
+ computed_at: NativeDate;
81
+ prep_time_counters: any;
82
+ prep_time_counter_rows: any;
83
+ }> & {
84
+ _id: import("mongoose").Types.ObjectId;
85
+ } & {
86
+ __v: number;
87
+ }>;
88
+ export declare const MATERIALIZED_TENANT_PREP_TIME_REPORTS_COLLECTION_NAME = "materialized_tenant_prep_time_reports";
89
+ /**
90
+ * Indexes for `materialized_tenant_prep_time_reports` - the same single UNIQUE
91
+ * compound identity index as every materialized report collection. It serves the
92
+ * close-day identity upserts AND the read: the read pipeline's TOP-LEVEL `$match`
93
+ * gates on exactly this prefix, with equality or `$in` on the scope values.
94
+ *
95
+ * No `brand_id` index: a brand's tenants are resolved before the read, so
96
+ * `tenant_id` is always the leading key.
97
+ */
98
+ export declare const MATERIALIZED_TENANT_PREP_TIME_REPORTS_COLLECTION_INDEXES: {
99
+ _id: {
100
+ _id: number;
101
+ };
102
+ tenant_id__scope_context__scope_field__day_index: {
103
+ tenant_id: number;
104
+ scope_context: number;
105
+ scope_field: number;
106
+ day_index: number;
107
+ };
108
+ };
109
+ export declare const MATERIALIZED_TENANT_PREP_TIME_REPORTS_INDEX_OPTIONS: {
110
+ key: {
111
+ tenant_id: number;
112
+ scope_context: number;
113
+ scope_field: number;
114
+ day_index: number;
115
+ };
116
+ name: string;
117
+ unique: boolean;
118
+ }[];
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MATERIALIZED_TENANT_PREP_TIME_REPORTS_INDEX_OPTIONS = exports.MATERIALIZED_TENANT_PREP_TIME_REPORTS_COLLECTION_INDEXES = exports.MATERIALIZED_TENANT_PREP_TIME_REPORTS_COLLECTION_NAME = exports.MaterializedTenantPrepTimeReportSchema = exports.MATERIALIZED_TENANT_PREP_TIME_REPORTS_SCHEMA_VERSION = void 0;
4
+ const mongoose_1 = require("mongoose");
5
+ const ENUMS_1 = require("../../constants/ENUMS");
6
+ const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
7
+ /**
8
+ * Mongoose schema for `materialized_tenant_prep_time_reports` (M2).
9
+ *
10
+ * Counters ONLY - the itemized rows live in the SIBLING entries collection
11
+ * (`materialized_tenant_prep_time_entries`, owner decision (a2)). See
12
+ * `schemas/types/materialized_tenant_prep_time_reports.ts` and
13
+ * `docs/report-prep-time-concept.md`.
14
+ *
15
+ * The counters are stored TWICE on purpose: a key-addressed MAP
16
+ * (`prep_time_counters`, the store + formatter shape) and the SAME counters as
17
+ * an ARRAY OF ROWS (`prep_time_counter_rows`, the READ shape). Summing the map
18
+ * inside an aggregation needs nested `$getField` calls (a dotted field name
19
+ * silently matches nothing), `$literal` around every computed field name and an
20
+ * `$arrayToObject` rebuild; with rows the read is the canonical `$unwind` ->
21
+ * `$group` -> direct `$sum` pattern. Both are written from one accumulator pass,
22
+ * so they cannot disagree.
23
+ */
24
+ /**
25
+ * Version of the prep time report COUNTER rules. Bump when counter semantics
26
+ * change (new buckets, a different anchor rule) - historical documents must then
27
+ * be re-materialized. PRE-RELEASE: folds into version `1`.
28
+ */
29
+ exports.MATERIALIZED_TENANT_PREP_TIME_REPORTS_SCHEMA_VERSION = 1;
30
+ exports.MaterializedTenantPrepTimeReportSchema = new mongoose_1.Schema({
31
+ tenant_id: { type: String, required: true },
32
+ brand_id: { type: String, required: true },
33
+ scope_context: {
34
+ type: String,
35
+ required: true,
36
+ enum: MATERIALIZED_REPORTS_1.MATERIALIZED_PREP_TIME_REPORT_SCOPES,
37
+ },
38
+ scope_field: { type: String, required: true },
39
+ day_index: {
40
+ type: String,
41
+ default: null,
42
+ enum: [...ENUMS_1.ALL_DAY_INDEX, null],
43
+ },
44
+ sale_type_key_filters: {
45
+ type: [String],
46
+ required: true,
47
+ default: () => [...MATERIALIZED_REPORTS_1.PREP_TIME_KEY_FILTERS],
48
+ validate: {
49
+ validator: (value) => value.length > 0 &&
50
+ value.every((entry) => MATERIALIZED_REPORTS_1.ALL_MATERIALIZED_REPORT_KEY_FILTERS.includes(entry)),
51
+ message: 'sale_type_key_filters must be a non-empty subset of the known key filters',
52
+ },
53
+ },
54
+ // { [sale_type_key]: counters } - pruned per key; never an empty map.
55
+ prep_time_counters: {
56
+ type: mongoose_1.Schema.Types.Mixed,
57
+ required: true,
58
+ default: null,
59
+ },
60
+ // The SAME counters as [{ key, counters }] - the read-path shape.
61
+ prep_time_counter_rows: {
62
+ type: mongoose_1.Schema.Types.Mixed,
63
+ required: true,
64
+ default: null,
65
+ },
66
+ iteration: { type: Number, required: true, min: 1, default: 1 },
67
+ schema_version: {
68
+ type: Number,
69
+ required: true,
70
+ immutable: true,
71
+ default: exports.MATERIALIZED_TENANT_PREP_TIME_REPORTS_SCHEMA_VERSION,
72
+ },
73
+ source_watermark: { type: mongoose_1.Schema.Types.Date, required: true },
74
+ computed_at: { type: mongoose_1.Schema.Types.Date, required: true },
75
+ createdAt: {
76
+ type: mongoose_1.Schema.Types.Date,
77
+ required: true,
78
+ default: () => new Date(),
79
+ immutable: true,
80
+ },
81
+ updatedAt: {
82
+ type: mongoose_1.Schema.Types.Date,
83
+ required: true,
84
+ default: () => new Date(),
85
+ },
86
+ }, { timestamps: true, versionKey: false, minimize: false });
87
+ exports.MATERIALIZED_TENANT_PREP_TIME_REPORTS_COLLECTION_NAME = 'materialized_tenant_prep_time_reports';
88
+ /**
89
+ * Indexes for `materialized_tenant_prep_time_reports` - the same single UNIQUE
90
+ * compound identity index as every materialized report collection. It serves the
91
+ * close-day identity upserts AND the read: the read pipeline's TOP-LEVEL `$match`
92
+ * gates on exactly this prefix, with equality or `$in` on the scope values.
93
+ *
94
+ * No `brand_id` index: a brand's tenants are resolved before the read, so
95
+ * `tenant_id` is always the leading key.
96
+ */
97
+ exports.MATERIALIZED_TENANT_PREP_TIME_REPORTS_COLLECTION_INDEXES = {
98
+ _id: { _id: 1 },
99
+ tenant_id__scope_context__scope_field__day_index: {
100
+ tenant_id: 1,
101
+ scope_context: 1,
102
+ scope_field: 1,
103
+ day_index: 1,
104
+ },
105
+ };
106
+ exports.MATERIALIZED_TENANT_PREP_TIME_REPORTS_INDEX_OPTIONS = [
107
+ {
108
+ key: { tenant_id: 1, scope_context: 1, scope_field: 1, day_index: 1 },
109
+ name: 'tenant_id__scope_context__scope_field__day_index',
110
+ unique: true,
111
+ },
112
+ ];
@@ -0,0 +1,139 @@
1
+ import { Schema } from 'mongoose';
2
+ import { MATERIALIZED_TENANT_SALES_COMPARISON_ENTRIES_SCHEMA_VERSION } from '../../constants/MATERIALIZED_REPORTS';
3
+ /**
4
+ * Mongoose schema for `materialized_tenant_sales_comparison_entries` — the
5
+ * ITEMIZED order rows behind the Sales Comparison drill-down.
6
+ *
7
+ * ORDER ROWS ONLY. Sales Comparison and Payments Comparison are different
8
+ * reports: a payment row here would double-count a split payment. Each row is
9
+ * one order, identified by `order_id` — a period document is a fold of its
10
+ * days, so de-duplicating by `order_id` is exact.
11
+ *
12
+ * Rows are slim (ids + money facts); the order document stays the source of
13
+ * truth. Amounts are CENTS; reads pin `schema_version`.
14
+ */
15
+ /** Version of the entry rules of this collection (bump + re-materialize on change). */
16
+ export { MATERIALIZED_TENANT_SALES_COMPARISON_ENTRIES_SCHEMA_VERSION };
17
+ declare const SalesComparisonEntrySchema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
18
+ _id: false;
19
+ }, {
20
+ order_id: string;
21
+ platform: string;
22
+ discount_amount: number;
23
+ order_number: number;
24
+ order_status: string;
25
+ net_amount: number;
26
+ item_count: number;
27
+ time: string;
28
+ }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
29
+ order_id: string;
30
+ platform: string;
31
+ discount_amount: number;
32
+ order_number: number;
33
+ order_status: string;
34
+ net_amount: number;
35
+ item_count: number;
36
+ time: string;
37
+ }>> & import("mongoose").FlatRecord<{
38
+ order_id: string;
39
+ platform: string;
40
+ discount_amount: number;
41
+ order_number: number;
42
+ order_status: string;
43
+ net_amount: number;
44
+ item_count: number;
45
+ time: string;
46
+ }> & {
47
+ _id: import("mongoose").Types.ObjectId;
48
+ } & {
49
+ __v: number;
50
+ }>;
51
+ export declare const MaterializedTenantSalesComparisonEntriesSchema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
52
+ timestamps: true;
53
+ versionKey: false;
54
+ minimize: false;
55
+ }, {
56
+ createdAt: NativeDate;
57
+ updatedAt: NativeDate;
58
+ } & {
59
+ _id: import("mongoose").Types.ObjectId;
60
+ tenant_id: string;
61
+ createdAt: NativeDate;
62
+ updatedAt: NativeDate;
63
+ brand_id: string;
64
+ day_index: import("../../constants/ENUMS").DAY_INDEX_ENUM | null;
65
+ iteration: number;
66
+ scope_context: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_REPORT_SCOPE_ENUM;
67
+ scope_field: string;
68
+ sale_type_key_filters: string[];
69
+ schema_version: number;
70
+ source_watermark: NativeDate;
71
+ computed_at: NativeDate;
72
+ sales_entries: any;
73
+ }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
74
+ createdAt: NativeDate;
75
+ updatedAt: NativeDate;
76
+ } & {
77
+ _id: import("mongoose").Types.ObjectId;
78
+ tenant_id: string;
79
+ createdAt: NativeDate;
80
+ updatedAt: NativeDate;
81
+ brand_id: string;
82
+ day_index: import("../../constants/ENUMS").DAY_INDEX_ENUM | null;
83
+ iteration: number;
84
+ scope_context: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_REPORT_SCOPE_ENUM;
85
+ scope_field: string;
86
+ sale_type_key_filters: string[];
87
+ schema_version: number;
88
+ source_watermark: NativeDate;
89
+ computed_at: NativeDate;
90
+ sales_entries: any;
91
+ }>> & import("mongoose").FlatRecord<{
92
+ createdAt: NativeDate;
93
+ updatedAt: NativeDate;
94
+ } & {
95
+ _id: import("mongoose").Types.ObjectId;
96
+ tenant_id: string;
97
+ createdAt: NativeDate;
98
+ updatedAt: NativeDate;
99
+ brand_id: string;
100
+ day_index: import("../../constants/ENUMS").DAY_INDEX_ENUM | null;
101
+ iteration: number;
102
+ scope_context: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_REPORT_SCOPE_ENUM;
103
+ scope_field: string;
104
+ sale_type_key_filters: string[];
105
+ schema_version: number;
106
+ source_watermark: NativeDate;
107
+ computed_at: NativeDate;
108
+ sales_entries: any;
109
+ }> & Required<{
110
+ _id: import("mongoose").Types.ObjectId;
111
+ }> & {
112
+ __v: number;
113
+ }>;
114
+ export { SalesComparisonEntrySchema };
115
+ /**
116
+ * Indexes for `materialized_tenant_sales_comparison_entries` — the same ONE
117
+ * unique compound identity/read index as every other materialized report.
118
+ */
119
+ export declare const MATERIALIZED_TENANT_SALES_COMPARISON_ENTRIES_COLLECTION_INDEXES: {
120
+ _id: {
121
+ _id: number;
122
+ };
123
+ tenant_id__scope_context__scope_field__day_index: {
124
+ tenant_id: number;
125
+ scope_context: number;
126
+ scope_field: number;
127
+ day_index: number;
128
+ };
129
+ };
130
+ export declare const MATERIALIZED_TENANT_SALES_COMPARISON_ENTRIES_INDEX_OPTIONS: {
131
+ key: {
132
+ tenant_id: number;
133
+ scope_context: number;
134
+ scope_field: number;
135
+ day_index: number;
136
+ };
137
+ name: string;
138
+ unique: boolean;
139
+ }[];