@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
@@ -15,9 +15,9 @@ export declare const ExpenseDetailsSchema: Schema<any, import("mongoose").Model<
15
15
  createdAt: NativeDate;
16
16
  updatedAt: NativeDate;
17
17
  description: string;
18
+ amount: number;
18
19
  expense_category_id: import("mongoose").Types.ObjectId;
19
20
  expense_sub_category_id: import("mongoose").Types.ObjectId;
20
- amount: number;
21
21
  payment_method: string;
22
22
  date_incurred: NativeDate;
23
23
  date_incurred_mins: number;
@@ -39,9 +39,9 @@ export declare const ExpenseDetailsSchema: Schema<any, import("mongoose").Model<
39
39
  createdAt: NativeDate;
40
40
  updatedAt: NativeDate;
41
41
  description: string;
42
+ amount: number;
42
43
  expense_category_id: import("mongoose").Types.ObjectId;
43
44
  expense_sub_category_id: import("mongoose").Types.ObjectId;
44
- amount: number;
45
45
  payment_method: string;
46
46
  date_incurred: NativeDate;
47
47
  date_incurred_mins: number;
@@ -63,9 +63,9 @@ export declare const ExpenseDetailsSchema: Schema<any, import("mongoose").Model<
63
63
  createdAt: NativeDate;
64
64
  updatedAt: NativeDate;
65
65
  description: string;
66
+ amount: number;
66
67
  expense_category_id: import("mongoose").Types.ObjectId;
67
68
  expense_sub_category_id: import("mongoose").Types.ObjectId;
68
- amount: number;
69
69
  payment_method: string;
70
70
  date_incurred: NativeDate;
71
71
  date_incurred_mins: number;
@@ -28,7 +28,22 @@ export * from './item_transactions';
28
28
  export * from './items';
29
29
  export * from './marketing_fingerprints';
30
30
  export * from './materialized_credit_bills';
31
+ export * from './materialized_tenant_discount_entries';
32
+ export * from './materialized_tenant_discount_reports';
33
+ export * from './materialized_tenant_cash_entries';
34
+ export * from './materialized_tenant_delivery_entries';
35
+ export * from './materialized_tenant_delivery_reports';
36
+ export * from './materialized_rider_daily_reports';
37
+ export * from './materialized_tenant_cash_reports';
38
+ export * from './materialized_tenant_prep_time_entries';
39
+ export * from './materialized_tenant_prep_time_reports';
31
40
  export * from './materialized_tenant_reports_iterations';
41
+ export * from './materialized_tenant_sales_comparison_entries';
42
+ export * from './materialized_tenant_sales_comparison_reports';
43
+ export * from './materialized_tenant_hourly_comparison_entries';
44
+ export * from './materialized_tenant_hourly_comparison_reports';
45
+ export * from './materialized_tenant_payments_comparison_entries';
46
+ export * from './materialized_tenant_payments_comparison_reports';
32
47
  export * from './materialized_tenant_sales_overview_reports';
33
48
  export * from './menus';
34
49
  export * from './messaging_devices';
@@ -44,7 +44,22 @@ __exportStar(require("./item_transactions"), exports);
44
44
  __exportStar(require("./items"), exports);
45
45
  __exportStar(require("./marketing_fingerprints"), exports);
46
46
  __exportStar(require("./materialized_credit_bills"), exports);
47
+ __exportStar(require("./materialized_tenant_discount_entries"), exports);
48
+ __exportStar(require("./materialized_tenant_discount_reports"), exports);
49
+ __exportStar(require("./materialized_tenant_cash_entries"), exports);
50
+ __exportStar(require("./materialized_tenant_delivery_entries"), exports);
51
+ __exportStar(require("./materialized_tenant_delivery_reports"), exports);
52
+ __exportStar(require("./materialized_rider_daily_reports"), exports);
53
+ __exportStar(require("./materialized_tenant_cash_reports"), exports);
54
+ __exportStar(require("./materialized_tenant_prep_time_entries"), exports);
55
+ __exportStar(require("./materialized_tenant_prep_time_reports"), exports);
47
56
  __exportStar(require("./materialized_tenant_reports_iterations"), exports);
57
+ __exportStar(require("./materialized_tenant_sales_comparison_entries"), exports);
58
+ __exportStar(require("./materialized_tenant_sales_comparison_reports"), exports);
59
+ __exportStar(require("./materialized_tenant_hourly_comparison_entries"), exports);
60
+ __exportStar(require("./materialized_tenant_hourly_comparison_reports"), exports);
61
+ __exportStar(require("./materialized_tenant_payments_comparison_entries"), exports);
62
+ __exportStar(require("./materialized_tenant_payments_comparison_reports"), exports);
48
63
  __exportStar(require("./materialized_tenant_sales_overview_reports"), exports);
49
64
  __exportStar(require("./menus"), exports);
50
65
  __exportStar(require("./messaging_devices"), exports);
@@ -0,0 +1,27 @@
1
+ import { Schema } from 'mongoose';
2
+ import { IMaterializedRiderDailyReport } from '../types/materialized_rider_daily_reports';
3
+ /**
4
+ * Mongoose schema for `materialized_rider_daily_reports`.
5
+ *
6
+ * The tenant breakdown is Mixed because its keys are tenant ids (data). The
7
+ * rider/day pair is the only unique identity.
8
+ */
9
+ export declare const MATERIALIZED_RIDER_DAILY_REPORTS_SCHEMA_VERSION = 1;
10
+ export declare const MATERIALIZED_RIDER_DAILY_REPORTS_COLLECTION_NAME = "materialized_rider_daily_reports";
11
+ export declare const MaterializedRiderDailyReportSchema: Schema<IMaterializedRiderDailyReport, import("mongoose").Model<IMaterializedRiderDailyReport, any, any, any, import("mongoose").Document<unknown, any, IMaterializedRiderDailyReport> & IMaterializedRiderDailyReport & Required<{
12
+ _id: string;
13
+ }> & {
14
+ __v: number;
15
+ }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, IMaterializedRiderDailyReport, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<IMaterializedRiderDailyReport>> & import("mongoose").FlatRecord<IMaterializedRiderDailyReport> & Required<{
16
+ _id: string;
17
+ }> & {
18
+ __v: number;
19
+ }>;
20
+ export declare const MATERIALIZED_RIDER_DAILY_REPORTS_INDEX_OPTIONS: {
21
+ key: {
22
+ rider_id: number;
23
+ local_date: number;
24
+ };
25
+ name: string;
26
+ unique: boolean;
27
+ }[];
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MATERIALIZED_RIDER_DAILY_REPORTS_INDEX_OPTIONS = exports.MaterializedRiderDailyReportSchema = exports.MATERIALIZED_RIDER_DAILY_REPORTS_COLLECTION_NAME = exports.MATERIALIZED_RIDER_DAILY_REPORTS_SCHEMA_VERSION = void 0;
4
+ const mongoose_1 = require("mongoose");
5
+ /**
6
+ * Mongoose schema for `materialized_rider_daily_reports`.
7
+ *
8
+ * The tenant breakdown is Mixed because its keys are tenant ids (data). The
9
+ * rider/day pair is the only unique identity.
10
+ */
11
+ exports.MATERIALIZED_RIDER_DAILY_REPORTS_SCHEMA_VERSION = 1;
12
+ exports.MATERIALIZED_RIDER_DAILY_REPORTS_COLLECTION_NAME = 'materialized_rider_daily_reports';
13
+ exports.MaterializedRiderDailyReportSchema = new mongoose_1.Schema({
14
+ rider_id: { type: String, required: true },
15
+ local_date: { type: String, required: true },
16
+ deliveries: { type: Number, required: true, min: 0, default: 0 },
17
+ completed: { type: Number, required: true, min: 0, default: 0 },
18
+ cancelled: { type: Number, required: true, min: 0, default: 0 },
19
+ earnings: { type: Number, required: true, min: 0, default: 0 },
20
+ distance_meters: { type: Number, required: true, min: 0, default: 0 },
21
+ on_time: { type: Number, required: true, min: 0, default: 0 },
22
+ late: { type: Number, required: true, min: 0, default: 0 },
23
+ tenants: { type: mongoose_1.Schema.Types.Mixed, required: true, default: {} },
24
+ first_delivery_at: { type: mongoose_1.Schema.Types.Date, default: null },
25
+ last_delivery_at: { type: mongoose_1.Schema.Types.Date, default: null },
26
+ schema_version: {
27
+ type: Number,
28
+ required: true,
29
+ immutable: true,
30
+ default: exports.MATERIALIZED_RIDER_DAILY_REPORTS_SCHEMA_VERSION,
31
+ },
32
+ source_watermark: { type: mongoose_1.Schema.Types.Date, required: true },
33
+ computed_at: { type: mongoose_1.Schema.Types.Date, required: true },
34
+ }, { timestamps: true, versionKey: false, minimize: false });
35
+ exports.MaterializedRiderDailyReportSchema.index({ rider_id: 1, local_date: 1 }, { unique: true, name: 'rider_id__local_date' });
36
+ exports.MATERIALIZED_RIDER_DAILY_REPORTS_INDEX_OPTIONS = [
37
+ {
38
+ key: { rider_id: 1, local_date: 1 },
39
+ name: 'rider_id__local_date',
40
+ unique: true,
41
+ },
42
+ ];
@@ -0,0 +1,181 @@
1
+ import { Schema } from 'mongoose';
2
+ /**
3
+ * Mongoose schema for `materialized_tenant_cash_in_out_entries` - the STATEMENT
4
+ * rows behind the cash report's drill-down (owner decision (e3): SPLIT).
5
+ *
6
+ * Scopes are capped at `LOCAL_MONTH`. Each row mirrors what the POS ledger already
7
+ * renders (Detail / Before / signed Amount / After), and carries the four
8
+ * lifecycle FLAGS computed at compile time so the read never re-derives them.
9
+ */
10
+ /**
11
+ * Version of the cash ENTRY rules. Bump when row semantics change - historical
12
+ * documents must then be re-materialized. PRE-RELEASE: folds into version `1`.
13
+ */
14
+ export declare const MATERIALIZED_TENANT_CASH_ENTRIES_SCHEMA_VERSION = 1;
15
+ declare const CashEntrySchema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
16
+ _id: false;
17
+ }, {
18
+ type: import("../../constants/ENUMS").CASH_IN_OUT_TYPE_ENUM;
19
+ staff_id: string;
20
+ staff_name: string;
21
+ note: string;
22
+ ref_type: import("../../constants/ENUMS").CASH_IN_OUT_REF_ENUM;
23
+ ref_id: string;
24
+ amount: number;
25
+ day_id: string;
26
+ drawer_id: string;
27
+ drawer_name: string;
28
+ shift_id: string;
29
+ shift_number: number;
30
+ drawer_balance_before: number;
31
+ drawer_balance_after: number;
32
+ entry_key: string;
33
+ created_at: NativeDate;
34
+ local_hour: string;
35
+ cash_in_out_id: string;
36
+ signed_amount: number;
37
+ is_reopen: boolean;
38
+ is_opening_float: boolean;
39
+ is_count_out: boolean;
40
+ is_system_adjustment: boolean;
41
+ }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
42
+ type: import("../../constants/ENUMS").CASH_IN_OUT_TYPE_ENUM;
43
+ staff_id: string;
44
+ staff_name: string;
45
+ note: string;
46
+ ref_type: import("../../constants/ENUMS").CASH_IN_OUT_REF_ENUM;
47
+ ref_id: string;
48
+ amount: number;
49
+ day_id: string;
50
+ drawer_id: string;
51
+ drawer_name: string;
52
+ shift_id: string;
53
+ shift_number: number;
54
+ drawer_balance_before: number;
55
+ drawer_balance_after: number;
56
+ entry_key: string;
57
+ created_at: NativeDate;
58
+ local_hour: string;
59
+ cash_in_out_id: string;
60
+ signed_amount: number;
61
+ is_reopen: boolean;
62
+ is_opening_float: boolean;
63
+ is_count_out: boolean;
64
+ is_system_adjustment: boolean;
65
+ }>> & import("mongoose").FlatRecord<{
66
+ type: import("../../constants/ENUMS").CASH_IN_OUT_TYPE_ENUM;
67
+ staff_id: string;
68
+ staff_name: string;
69
+ note: string;
70
+ ref_type: import("../../constants/ENUMS").CASH_IN_OUT_REF_ENUM;
71
+ ref_id: string;
72
+ amount: number;
73
+ day_id: string;
74
+ drawer_id: string;
75
+ drawer_name: string;
76
+ shift_id: string;
77
+ shift_number: number;
78
+ drawer_balance_before: number;
79
+ drawer_balance_after: number;
80
+ entry_key: string;
81
+ created_at: NativeDate;
82
+ local_hour: string;
83
+ cash_in_out_id: string;
84
+ signed_amount: number;
85
+ is_reopen: boolean;
86
+ is_opening_float: boolean;
87
+ is_count_out: boolean;
88
+ is_system_adjustment: boolean;
89
+ }> & {
90
+ _id: import("mongoose").Types.ObjectId;
91
+ } & {
92
+ __v: number;
93
+ }>;
94
+ export { CashEntrySchema };
95
+ export declare const MaterializedTenantCashEntriesSchema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
96
+ timestamps: true;
97
+ versionKey: false;
98
+ minimize: false;
99
+ }, {
100
+ createdAt: NativeDate;
101
+ updatedAt: NativeDate;
102
+ } & {
103
+ tenant_id: string;
104
+ createdAt: NativeDate;
105
+ updatedAt: NativeDate;
106
+ brand_id: string;
107
+ day_index: import("../../constants/ENUMS").DAY_INDEX_ENUM | null;
108
+ iteration: number;
109
+ scope_context: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_REPORT_SCOPE_ENUM;
110
+ scope_field: string;
111
+ sale_type_key_filters: string[];
112
+ schema_version: number;
113
+ source_watermark: NativeDate;
114
+ computed_at: NativeDate;
115
+ cash_entries: any;
116
+ }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
117
+ createdAt: NativeDate;
118
+ updatedAt: NativeDate;
119
+ } & {
120
+ tenant_id: string;
121
+ createdAt: NativeDate;
122
+ updatedAt: NativeDate;
123
+ brand_id: string;
124
+ day_index: import("../../constants/ENUMS").DAY_INDEX_ENUM | null;
125
+ iteration: number;
126
+ scope_context: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_REPORT_SCOPE_ENUM;
127
+ scope_field: string;
128
+ sale_type_key_filters: string[];
129
+ schema_version: number;
130
+ source_watermark: NativeDate;
131
+ computed_at: NativeDate;
132
+ cash_entries: any;
133
+ }>> & import("mongoose").FlatRecord<{
134
+ createdAt: NativeDate;
135
+ updatedAt: NativeDate;
136
+ } & {
137
+ tenant_id: string;
138
+ createdAt: NativeDate;
139
+ updatedAt: NativeDate;
140
+ brand_id: string;
141
+ day_index: import("../../constants/ENUMS").DAY_INDEX_ENUM | null;
142
+ iteration: number;
143
+ scope_context: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_REPORT_SCOPE_ENUM;
144
+ scope_field: string;
145
+ sale_type_key_filters: string[];
146
+ schema_version: number;
147
+ source_watermark: NativeDate;
148
+ computed_at: NativeDate;
149
+ cash_entries: any;
150
+ }> & {
151
+ _id: import("mongoose").Types.ObjectId;
152
+ } & {
153
+ __v: number;
154
+ }>;
155
+ export declare const MATERIALIZED_TENANT_CASH_ENTRIES_COLLECTION_NAME = "materialized_tenant_cash_in_out_entries";
156
+ /**
157
+ * The single UNIQUE compound identity index, like every materialized collection.
158
+ * The `{ tenant_id, scope_context, scope_field }` prefix also serves the
159
+ * drill-down's month-document resolution.
160
+ */
161
+ export declare const MATERIALIZED_TENANT_CASH_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_CASH_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,98 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MATERIALIZED_TENANT_CASH_ENTRIES_INDEX_OPTIONS = exports.MATERIALIZED_TENANT_CASH_ENTRIES_COLLECTION_INDEXES = exports.MATERIALIZED_TENANT_CASH_ENTRIES_COLLECTION_NAME = exports.MaterializedTenantCashEntriesSchema = exports.CashEntrySchema = exports.MATERIALIZED_TENANT_CASH_ENTRIES_SCHEMA_VERSION = void 0;
4
+ const mongoose_1 = require("mongoose");
5
+ const ENUMS_1 = require("../../constants/ENUMS");
6
+ const cash_1 = require("../../constants/enums/cash");
7
+ const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
8
+ /**
9
+ * Mongoose schema for `materialized_tenant_cash_in_out_entries` - the STATEMENT
10
+ * rows behind the cash report's drill-down (owner decision (e3): SPLIT).
11
+ *
12
+ * Scopes are capped at `LOCAL_MONTH`. Each row mirrors what the POS ledger already
13
+ * renders (Detail / Before / signed Amount / After), and carries the four
14
+ * lifecycle FLAGS computed at compile time so the read never re-derives them.
15
+ */
16
+ /**
17
+ * Version of the cash ENTRY rules. Bump when row semantics change - historical
18
+ * documents must then be re-materialized. PRE-RELEASE: folds into version `1`.
19
+ */
20
+ exports.MATERIALIZED_TENANT_CASH_ENTRIES_SCHEMA_VERSION = 1;
21
+ const CashEntrySchema = new mongoose_1.Schema({
22
+ cash_in_out_id: { type: String, required: true },
23
+ entry_key: { type: String, required: true },
24
+ drawer_id: { type: String, required: true },
25
+ drawer_name: { type: String, default: null },
26
+ day_id: { type: String, required: true },
27
+ shift_id: { type: String, default: null },
28
+ shift_number: { type: Number, default: null },
29
+ type: { type: String, required: true, enum: cash_1.ALL_CASH_IN_OUT_TYPES },
30
+ ref_type: { type: String, required: true, enum: cash_1.ALL_CASH_IN_OUT_REFS },
31
+ ref_id: { type: String, default: null },
32
+ amount: { type: Number, required: true, default: 0 },
33
+ signed_amount: { type: Number, required: true, default: 0 },
34
+ drawer_balance_before: { type: Number, required: true, default: 0 },
35
+ drawer_balance_after: { type: Number, required: true, default: 0 },
36
+ staff_id: { type: String, default: null },
37
+ staff_name: { type: String, default: null },
38
+ note: { type: String, default: null },
39
+ // Computed ONCE at compile time (decision (i3)) - never re-derived on read.
40
+ is_reopen: { type: Boolean, required: true, default: false },
41
+ is_opening_float: { type: Boolean, required: true, default: false },
42
+ is_count_out: { type: Boolean, required: true, default: false },
43
+ is_system_adjustment: { type: Boolean, required: true, default: false },
44
+ created_at: { type: mongoose_1.Schema.Types.Date, required: true },
45
+ local_hour: { type: String, default: null },
46
+ }, { _id: false });
47
+ exports.CashEntrySchema = CashEntrySchema;
48
+ exports.MaterializedTenantCashEntriesSchema = new mongoose_1.Schema({
49
+ tenant_id: { type: String, required: true },
50
+ brand_id: { type: String, required: true },
51
+ scope_context: { type: String, required: true, enum: MATERIALIZED_REPORTS_1.MATERIALIZED_CASH_REPORT_SCOPES },
52
+ scope_field: { type: String, required: true },
53
+ day_index: { type: String, default: null, enum: [...ENUMS_1.ALL_DAY_INDEX, null] },
54
+ sale_type_key_filters: {
55
+ type: [String],
56
+ required: true,
57
+ default: () => [...MATERIALIZED_REPORTS_1.CASH_KEY_FILTERS],
58
+ validate: {
59
+ validator: (value) => value.length > 0 &&
60
+ value.every((entry) => MATERIALIZED_REPORTS_1.ALL_MATERIALIZED_REPORT_KEY_FILTERS.includes(entry)),
61
+ message: 'sale_type_key_filters must be a non-empty subset of the known key filters',
62
+ },
63
+ },
64
+ cash_entries: { type: mongoose_1.Schema.Types.Mixed, required: true, default: null },
65
+ iteration: { type: Number, required: true, min: 1, default: 1 },
66
+ schema_version: {
67
+ type: Number,
68
+ required: true,
69
+ immutable: true,
70
+ default: exports.MATERIALIZED_TENANT_CASH_ENTRIES_SCHEMA_VERSION,
71
+ },
72
+ source_watermark: { type: mongoose_1.Schema.Types.Date, required: true },
73
+ computed_at: { type: mongoose_1.Schema.Types.Date, required: true },
74
+ createdAt: { type: mongoose_1.Schema.Types.Date, required: true, default: () => new Date(), immutable: true },
75
+ updatedAt: { type: mongoose_1.Schema.Types.Date, required: true, default: () => new Date() },
76
+ }, { timestamps: true, versionKey: false, minimize: false });
77
+ exports.MATERIALIZED_TENANT_CASH_ENTRIES_COLLECTION_NAME = 'materialized_tenant_cash_in_out_entries';
78
+ /**
79
+ * The single UNIQUE compound identity index, like every materialized collection.
80
+ * The `{ tenant_id, scope_context, scope_field }` prefix also serves the
81
+ * drill-down's month-document resolution.
82
+ */
83
+ exports.MATERIALIZED_TENANT_CASH_ENTRIES_COLLECTION_INDEXES = {
84
+ _id: { _id: 1 },
85
+ tenant_id__scope_context__scope_field__day_index: {
86
+ tenant_id: 1,
87
+ scope_context: 1,
88
+ scope_field: 1,
89
+ day_index: 1,
90
+ },
91
+ };
92
+ exports.MATERIALIZED_TENANT_CASH_ENTRIES_INDEX_OPTIONS = [
93
+ {
94
+ key: { tenant_id: 1, scope_context: 1, scope_field: 1, day_index: 1 },
95
+ name: 'tenant_id__scope_context__scope_field__day_index',
96
+ unique: true,
97
+ },
98
+ ];
@@ -0,0 +1,111 @@
1
+ import { Schema } from 'mongoose';
2
+ /**
3
+ * Mongoose schema for `materialized_tenant_cash_in_out_reports` (M3).
4
+ *
5
+ * Counters ONLY - the statement rows live in the SIBLING entries collection
6
+ * (`materialized_tenant_cash_in_out_entries`, decision (e3)).
7
+ *
8
+ * The counters are stored TWICE on purpose: a key-addressed MAP (`cash_counters`, the
9
+ * store + formatter shape) and the SAME counters as an ARRAY OF ROWS
10
+ * (`cash_counter_rows`, the READ shape), so the read aggregation is the canonical
11
+ * unwind/group/direct-sum pattern instead of dynamic-key navigation.
12
+ *
13
+ * Key grammar is `<DRAWER_ID>:<REF_TYPE>` (decision (b3)) - cash has neither an
14
+ * order status nor a platform.
15
+ */
16
+ /**
17
+ * Version of the cash COUNTER rules. Bump when counter semantics change -
18
+ * historical documents must then be re-materialized. PRE-RELEASE: folds into
19
+ * version `1`.
20
+ */
21
+ export declare const MATERIALIZED_TENANT_CASH_REPORTS_SCHEMA_VERSION = 1;
22
+ export declare const MaterializedTenantCashReportSchema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
23
+ timestamps: true;
24
+ versionKey: false;
25
+ minimize: false;
26
+ }, {
27
+ createdAt: NativeDate;
28
+ updatedAt: NativeDate;
29
+ } & {
30
+ tenant_id: string;
31
+ createdAt: NativeDate;
32
+ updatedAt: NativeDate;
33
+ brand_id: string;
34
+ day_index: import("../../constants/ENUMS").DAY_INDEX_ENUM | null;
35
+ iteration: number;
36
+ scope_context: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_REPORT_SCOPE_ENUM;
37
+ scope_field: string;
38
+ sale_type_key_filters: string[];
39
+ schema_version: number;
40
+ source_watermark: NativeDate;
41
+ computed_at: NativeDate;
42
+ cash_counters: any;
43
+ cash_counter_rows: any;
44
+ }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
45
+ createdAt: NativeDate;
46
+ updatedAt: NativeDate;
47
+ } & {
48
+ tenant_id: string;
49
+ createdAt: NativeDate;
50
+ updatedAt: NativeDate;
51
+ brand_id: string;
52
+ day_index: import("../../constants/ENUMS").DAY_INDEX_ENUM | null;
53
+ iteration: number;
54
+ scope_context: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_REPORT_SCOPE_ENUM;
55
+ scope_field: string;
56
+ sale_type_key_filters: string[];
57
+ schema_version: number;
58
+ source_watermark: NativeDate;
59
+ computed_at: NativeDate;
60
+ cash_counters: any;
61
+ cash_counter_rows: any;
62
+ }>> & import("mongoose").FlatRecord<{
63
+ createdAt: NativeDate;
64
+ updatedAt: NativeDate;
65
+ } & {
66
+ tenant_id: string;
67
+ createdAt: NativeDate;
68
+ updatedAt: NativeDate;
69
+ brand_id: string;
70
+ day_index: import("../../constants/ENUMS").DAY_INDEX_ENUM | null;
71
+ iteration: number;
72
+ scope_context: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_REPORT_SCOPE_ENUM;
73
+ scope_field: string;
74
+ sale_type_key_filters: string[];
75
+ schema_version: number;
76
+ source_watermark: NativeDate;
77
+ computed_at: NativeDate;
78
+ cash_counters: any;
79
+ cash_counter_rows: any;
80
+ }> & {
81
+ _id: import("mongoose").Types.ObjectId;
82
+ } & {
83
+ __v: number;
84
+ }>;
85
+ export declare const MATERIALIZED_TENANT_CASH_REPORTS_COLLECTION_NAME = "materialized_tenant_cash_in_out_reports";
86
+ /**
87
+ * The single UNIQUE compound identity index. It serves the close-day identity
88
+ * upserts AND the read: the pipeline's TOP-LEVEL `$match` gates on exactly this
89
+ * prefix. No `brand_id` index - a brand's drawers are resolved before the read.
90
+ */
91
+ export declare const MATERIALIZED_TENANT_CASH_REPORTS_COLLECTION_INDEXES: {
92
+ _id: {
93
+ _id: number;
94
+ };
95
+ tenant_id__scope_context__scope_field__day_index: {
96
+ tenant_id: number;
97
+ scope_context: number;
98
+ scope_field: number;
99
+ day_index: number;
100
+ };
101
+ };
102
+ export declare const MATERIALIZED_TENANT_CASH_REPORTS_INDEX_OPTIONS: {
103
+ key: {
104
+ tenant_id: number;
105
+ scope_context: number;
106
+ scope_field: number;
107
+ day_index: number;
108
+ };
109
+ name: string;
110
+ unique: boolean;
111
+ }[];
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MATERIALIZED_TENANT_CASH_REPORTS_INDEX_OPTIONS = exports.MATERIALIZED_TENANT_CASH_REPORTS_COLLECTION_INDEXES = exports.MATERIALIZED_TENANT_CASH_REPORTS_COLLECTION_NAME = exports.MaterializedTenantCashReportSchema = exports.MATERIALIZED_TENANT_CASH_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_cash_in_out_reports` (M3).
9
+ *
10
+ * Counters ONLY - the statement rows live in the SIBLING entries collection
11
+ * (`materialized_tenant_cash_in_out_entries`, decision (e3)).
12
+ *
13
+ * The counters are stored TWICE on purpose: a key-addressed MAP (`cash_counters`, the
14
+ * store + formatter shape) and the SAME counters as an ARRAY OF ROWS
15
+ * (`cash_counter_rows`, the READ shape), so the read aggregation is the canonical
16
+ * unwind/group/direct-sum pattern instead of dynamic-key navigation.
17
+ *
18
+ * Key grammar is `<DRAWER_ID>:<REF_TYPE>` (decision (b3)) - cash has neither an
19
+ * order status nor a platform.
20
+ */
21
+ /**
22
+ * Version of the cash COUNTER rules. Bump when counter semantics change -
23
+ * historical documents must then be re-materialized. PRE-RELEASE: folds into
24
+ * version `1`.
25
+ */
26
+ exports.MATERIALIZED_TENANT_CASH_REPORTS_SCHEMA_VERSION = 1;
27
+ exports.MaterializedTenantCashReportSchema = new mongoose_1.Schema({
28
+ tenant_id: { type: String, required: true },
29
+ brand_id: { type: String, required: true },
30
+ scope_context: { type: String, required: true, enum: MATERIALIZED_REPORTS_1.MATERIALIZED_CASH_REPORT_SCOPES },
31
+ scope_field: { type: String, required: true },
32
+ day_index: { type: String, default: null, enum: [...ENUMS_1.ALL_DAY_INDEX, null] },
33
+ sale_type_key_filters: {
34
+ type: [String],
35
+ required: true,
36
+ default: () => [...MATERIALIZED_REPORTS_1.CASH_KEY_FILTERS],
37
+ validate: {
38
+ validator: (value) => value.length > 0 &&
39
+ value.every((entry) => MATERIALIZED_REPORTS_1.ALL_MATERIALIZED_REPORT_KEY_FILTERS.includes(entry)),
40
+ message: 'sale_type_key_filters must be a non-empty subset of the known key filters',
41
+ },
42
+ },
43
+ // { [key]: counters } - pruned per key; never an empty map.
44
+ cash_counters: { type: mongoose_1.Schema.Types.Mixed, required: true, default: null },
45
+ // The SAME counters as [{ key, counters }] - the read-path shape.
46
+ cash_counter_rows: { type: mongoose_1.Schema.Types.Mixed, required: true, default: null },
47
+ iteration: { type: Number, required: true, min: 1, default: 1 },
48
+ schema_version: {
49
+ type: Number,
50
+ required: true,
51
+ immutable: true,
52
+ default: exports.MATERIALIZED_TENANT_CASH_REPORTS_SCHEMA_VERSION,
53
+ },
54
+ source_watermark: { type: mongoose_1.Schema.Types.Date, required: true },
55
+ computed_at: { type: mongoose_1.Schema.Types.Date, required: true },
56
+ createdAt: { type: mongoose_1.Schema.Types.Date, required: true, default: () => new Date(), immutable: true },
57
+ updatedAt: { type: mongoose_1.Schema.Types.Date, required: true, default: () => new Date() },
58
+ }, { timestamps: true, versionKey: false, minimize: false });
59
+ exports.MATERIALIZED_TENANT_CASH_REPORTS_COLLECTION_NAME = 'materialized_tenant_cash_in_out_reports';
60
+ /**
61
+ * The single UNIQUE compound identity index. It serves the close-day identity
62
+ * upserts AND the read: the pipeline's TOP-LEVEL `$match` gates on exactly this
63
+ * prefix. No `brand_id` index - a brand's drawers are resolved before the read.
64
+ */
65
+ exports.MATERIALIZED_TENANT_CASH_REPORTS_COLLECTION_INDEXES = {
66
+ _id: { _id: 1 },
67
+ tenant_id__scope_context__scope_field__day_index: {
68
+ tenant_id: 1,
69
+ scope_context: 1,
70
+ scope_field: 1,
71
+ day_index: 1,
72
+ },
73
+ };
74
+ exports.MATERIALIZED_TENANT_CASH_REPORTS_INDEX_OPTIONS = [
75
+ {
76
+ key: { tenant_id: 1, scope_context: 1, scope_field: 1, day_index: 1 },
77
+ name: 'tenant_id__scope_context__scope_field__day_index',
78
+ unique: true,
79
+ },
80
+ ];