@managesome/eposmatic-toolkit 0.3.8 → 0.3.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 (437) hide show
  1. package/esm/constants/ANALYTICS.js +146 -0
  2. package/esm/constants/API_ERRORS.js +6 -0
  3. package/esm/constants/COMMON.js +369 -0
  4. package/esm/constants/DELIVERY.js +45 -0
  5. package/esm/constants/DIALER_ENUMS.js +11 -0
  6. package/esm/constants/ENUMS.js +1988 -0
  7. package/esm/constants/FBR_ENUMS.js +18 -0
  8. package/esm/constants/HUBRISE_ENUMS.js +179 -0
  9. package/esm/constants/INTERNAL_ENUMS.js +49 -0
  10. package/esm/constants/NOTIFICATIONS.js +6 -0
  11. package/esm/constants/ORDER.js +251 -0
  12. package/esm/constants/PRA_ENUMS.js +18 -0
  13. package/esm/constants/REPORT_WEBVIEW.js +28 -0
  14. package/esm/constants/RFQ_GO.js +83 -0
  15. package/esm/constants/SMARTPAY_ENUMS.js +55 -0
  16. package/esm/constants/SOCKET.js +149 -0
  17. package/esm/constants/SRB_ENUMS.js +13 -0
  18. package/esm/constants/SWITCHPAY.js +28 -0
  19. package/esm/constants/TENANT_ENUMS.js +90 -0
  20. package/esm/constants/TENANT_PURCHASE_ORDER.js +91 -0
  21. package/esm/constants/WALLET.js +51 -0
  22. package/esm/constants/WAREHOUSE_ANALYTICS.js +28 -0
  23. package/esm/constants/WAREHOUSE_ENUMS.js +420 -0
  24. package/esm/constants/WAREHOUSE_PURCHASE_ORDER.js +97 -0
  25. package/esm/constants/WEBVIEW.js +43 -0
  26. package/esm/constants/WORKER_ENDPOINTS.js +79 -0
  27. package/esm/constants/index.js +27 -0
  28. package/esm/constants/types.js +2 -0
  29. package/esm/helpers/fbr/generate-invoice.js +94 -0
  30. package/esm/helpers/fbr/index.js +1 -0
  31. package/esm/helpers/hubrise/hubrise-catalog.js +304 -0
  32. package/esm/helpers/hubrise/index.js +1 -0
  33. package/esm/helpers/index.js +9 -0
  34. package/esm/helpers/kpra/generate-invoice.js +26 -0
  35. package/esm/helpers/kpra/index.js +1 -0
  36. package/esm/helpers/order/generate-order.js +508 -0
  37. package/esm/helpers/order/generate-warehouse-internal-movement.js +71 -0
  38. package/esm/helpers/order/generate-warehouse-purchase-order-rfq.js +176 -0
  39. package/esm/helpers/order/generate-warehouse-purchase-order.js +187 -0
  40. package/esm/helpers/order/generate-warehouse-sale-order-rfq.js +176 -0
  41. package/esm/helpers/order/generate-warehouse-sale-order.js +149 -0
  42. package/esm/helpers/order/index.js +6 -0
  43. package/esm/helpers/pra/generate-invoice.js +94 -0
  44. package/esm/helpers/pra/index.js +1 -0
  45. package/esm/helpers/srb/generate-invoice.js +68 -0
  46. package/esm/helpers/srb/index.js +1 -0
  47. package/esm/helpers/store/all-orders-actions.js +17 -0
  48. package/esm/helpers/store/all-tenant-purchase-orders-actions.js +45 -0
  49. package/esm/helpers/store/all-warehouse-purchase-order-rfqs-actions.js +66 -0
  50. package/esm/helpers/store/all-warehouse-purchase-order-vendor-return-actions.js +50 -0
  51. package/esm/helpers/store/all-warehouse-purchase-orders-actions.js +49 -0
  52. package/esm/helpers/store/all-warehouse-sale-order-invoices-actions.js +132 -0
  53. package/esm/helpers/store/all-warehouse-sale-order-rfqs-actions.js +66 -0
  54. package/esm/helpers/store/all-warehouse-sale-orders-actions.js +72 -0
  55. package/esm/helpers/store/cart-actions.js +3563 -0
  56. package/esm/helpers/store/catalog-actions.js +379 -0
  57. package/esm/helpers/store/common-order-actions.js +937 -0
  58. package/esm/helpers/store/common-tenant-purchase-order-actions.js +440 -0
  59. package/esm/helpers/store/common-warehouse-internal-movement-actions.js +95 -0
  60. package/esm/helpers/store/common-warehouse-purchase-order-actions.js +530 -0
  61. package/esm/helpers/store/common-warehouse-purchase-order-receipt-actions.js +33 -0
  62. package/esm/helpers/store/common-warehouse-purchase-order-rfq-actions.js +523 -0
  63. package/esm/helpers/store/common-warehouse-purchase-order-vendor-return-actions.js +25 -0
  64. package/esm/helpers/store/common-warehouse-sale-order-actions.js +483 -0
  65. package/esm/helpers/store/common-warehouse-sale-order-invoice-actions.js +54 -0
  66. package/esm/helpers/store/common-warehouse-sale-order-rfq-actions.js +523 -0
  67. package/esm/helpers/store/index.js +26 -0
  68. package/esm/helpers/store/offline-ordering.js +251 -0
  69. package/esm/helpers/store/tenant-purchase-orders-cart-actions.js +379 -0
  70. package/esm/helpers/store/warehouse-purchase-order-rfq-cart-actions.js +360 -0
  71. package/esm/helpers/store/warehouse-purchase-orders-cart-actions.js +470 -0
  72. package/esm/helpers/store/warehouse-sale-order-rfq-cart-actions.js +359 -0
  73. package/esm/helpers/store/warehouse-sale-orders-cart-actions.js +456 -0
  74. package/esm/helpers/types/api-types.js +1 -0
  75. package/esm/helpers/types/cart-actions.js +1 -0
  76. package/esm/helpers/types/cart-helpers.js +1 -0
  77. package/esm/helpers/types/catalog.js +1 -0
  78. package/esm/helpers/types/common.js +1 -0
  79. package/esm/helpers/types/deliverect_menu.js +1 -0
  80. package/esm/helpers/types/email-templates.js +1 -0
  81. package/esm/helpers/types/fbr-generate-invoice.js +1 -0
  82. package/esm/helpers/types/halfhalf.js +1 -0
  83. package/esm/helpers/types/hubrise_catalog.js +1 -0
  84. package/esm/helpers/types/hubrise_customers.js +1 -0
  85. package/esm/helpers/types/hubrise_deliveries.js +1 -0
  86. package/esm/helpers/types/hubrise_location.js +1 -0
  87. package/esm/helpers/types/hubrise_orders.js +1 -0
  88. package/esm/helpers/types/index.js +33 -0
  89. package/esm/helpers/types/internal-leads.js +1 -0
  90. package/esm/helpers/types/inventory-catalog.js +1 -0
  91. package/esm/helpers/types/kpra-generate-invoice.js +1 -0
  92. package/esm/helpers/types/marketing.js +1 -0
  93. package/esm/helpers/types/order-engine.js +1 -0
  94. package/esm/helpers/types/pra-generate-invoice.js +1 -0
  95. package/esm/helpers/types/report-webview.js +1 -0
  96. package/esm/helpers/types/reports.js +1 -0
  97. package/esm/helpers/types/smartpay-apis.js +2 -0
  98. package/esm/helpers/types/specials.js +1 -0
  99. package/esm/helpers/types/split_bill.js +1 -0
  100. package/esm/helpers/types/srb-generate-invoice.js +1 -0
  101. package/esm/helpers/types/switchpay.js +1 -0
  102. package/esm/helpers/types/tenant-purchase-order-cart-actions.js +1 -0
  103. package/esm/helpers/types/warehouse-catalog.js +1 -0
  104. package/esm/helpers/types/warehouse-purchase-order-cart-actions.js +1 -0
  105. package/esm/helpers/types/warehouse-purchase-order-rfq-cart-actions.js +1 -0
  106. package/esm/helpers/types/warehouse-sale-order-cart-actions.js +1 -0
  107. package/esm/helpers/types/warehouse-sale-order-rfq-cart-actions.js +1 -0
  108. package/esm/helpers/types/workers.js +1 -0
  109. package/esm/helpers/utils/asaanbill-identifier-helpers.js +31 -0
  110. package/esm/helpers/utils/business-day-helpers.js +201 -0
  111. package/esm/helpers/utils/cart-helpers.js +156 -0
  112. package/esm/helpers/utils/catalog-conversion.js +129 -0
  113. package/esm/helpers/utils/code-redemption-helpers.js +452 -0
  114. package/esm/helpers/utils/color-helpers.js +31 -0
  115. package/esm/helpers/utils/common.js +368 -0
  116. package/esm/helpers/utils/crypt.js +40 -0
  117. package/esm/helpers/utils/customers-helpers.js +15 -0
  118. package/esm/helpers/utils/delivery-area-helpers.js +42 -0
  119. package/esm/helpers/utils/delivery-helpers.js +87 -0
  120. package/esm/helpers/utils/denominations-helpers.js +53 -0
  121. package/esm/helpers/utils/dinein.js +39 -0
  122. package/esm/helpers/utils/discount-helpers.js +55 -0
  123. package/esm/helpers/utils/email-helpers.js +111 -0
  124. package/esm/helpers/utils/error-helpers.js +14 -0
  125. package/esm/helpers/utils/expense.js +26 -0
  126. package/esm/helpers/utils/getFormFieldsDiff.js +15 -0
  127. package/esm/helpers/utils/gift-card-helpers.js +258 -0
  128. package/esm/helpers/utils/halfhalf-setup-helpers.js +779 -0
  129. package/esm/helpers/utils/hourly-comparison-report-helpers.js +851 -0
  130. package/esm/helpers/utils/hr-helpers.js +62 -0
  131. package/esm/helpers/utils/hubrise-utils.js +32 -0
  132. package/esm/helpers/utils/image-helpers.js +95 -0
  133. package/esm/helpers/utils/image-url-helpers.js +96 -0
  134. package/esm/helpers/utils/index.js +96 -0
  135. package/esm/helpers/utils/ingredients.js +26 -0
  136. package/esm/helpers/utils/internal-amount-helpers.js +49 -0
  137. package/esm/helpers/utils/inventory.js +123 -0
  138. package/esm/helpers/utils/inventory_entries.js +91 -0
  139. package/esm/helpers/utils/inventory_transactions.js +91 -0
  140. package/esm/helpers/utils/item-report-helpers.js +2603 -0
  141. package/esm/helpers/utils/items-comparison-report-helpers.js +1057 -0
  142. package/esm/helpers/utils/kds-helpers.js +43 -0
  143. package/esm/helpers/utils/location-helpers.js +13 -0
  144. package/esm/helpers/utils/menu-helpers.js +44 -0
  145. package/esm/helpers/utils/minified-catalog.js +428 -0
  146. package/esm/helpers/utils/offer-apply-helpers.js +613 -0
  147. package/esm/helpers/utils/offers-helpers.js +3351 -0
  148. package/esm/helpers/utils/operational-roles-helpers.js +33 -0
  149. package/esm/helpers/utils/order-engine.js +1409 -0
  150. package/esm/helpers/utils/order-history.js +208 -0
  151. package/esm/helpers/utils/payment-comparison-report-helpers.js +873 -0
  152. package/esm/helpers/utils/payment-helpers.js +302 -0
  153. package/esm/helpers/utils/pdf-generator.js +110 -0
  154. package/esm/helpers/utils/platform-catalog.js +306 -0
  155. package/esm/helpers/utils/platform-num.js +188 -0
  156. package/esm/helpers/utils/platform-specific-tenant-shifts.js +19 -0
  157. package/esm/helpers/utils/price-conversion.js +24 -0
  158. package/esm/helpers/utils/printer-helpers.js +319 -0
  159. package/esm/helpers/utils/public-holidays-helpers.js +8 -0
  160. package/esm/helpers/utils/ratings-comparison-report-helpers.js +1187 -0
  161. package/esm/helpers/utils/receipt-engine.js +1050 -0
  162. package/esm/helpers/utils/review-helpers.js +391 -0
  163. package/esm/helpers/utils/rider-tracking.js +12 -0
  164. package/esm/helpers/utils/riders-report-helpers.js +1590 -0
  165. package/esm/helpers/utils/sales-comparison-report-helpers.js +1259 -0
  166. package/esm/helpers/utils/sales-comparitive-report-helpers.js +939 -0
  167. package/esm/helpers/utils/sales-overview-report-helpers.js +1046 -0
  168. package/esm/helpers/utils/sales-summary-report-helpers.js +877 -0
  169. package/esm/helpers/utils/scan-code-helpers.js +31 -0
  170. package/esm/helpers/utils/selection-model.js +68 -0
  171. package/esm/helpers/utils/shift-window-helpers.js +148 -0
  172. package/esm/helpers/utils/simplified-catalog.js +107 -0
  173. package/esm/helpers/utils/simplified-halfhalf.js +101 -0
  174. package/esm/helpers/utils/simplified-specials.js +107 -0
  175. package/esm/helpers/utils/simplified-tenant.js +411 -0
  176. package/esm/helpers/utils/specials-helpers.js +727 -0
  177. package/esm/helpers/utils/tenant-calendar-helpers.js +67 -0
  178. package/esm/helpers/utils/tenant-cash-drawer-sessions-helpers.js +248 -0
  179. package/esm/helpers/utils/tenant-cash-drawers-helpers.js +31 -0
  180. package/esm/helpers/utils/tenant-cash-in-out-helpers.js +47 -0
  181. package/esm/helpers/utils/tenant-day-sessions-helpers.js +167 -0
  182. package/esm/helpers/utils/tenant-instore-shift-sessions-helpers.js +227 -0
  183. package/esm/helpers/utils/tenant-staff-helpers.js +19 -0
  184. package/esm/helpers/utils/tenant_cash_in_hand_transactions.js +31 -0
  185. package/esm/helpers/utils/time-helpers.js +142 -0
  186. package/esm/helpers/utils/void-items-report-helpers.js +529 -0
  187. package/esm/helpers/utils/void-order-items-helpers.js +32 -0
  188. package/esm/helpers/utils/voidations-summary-report-helpers.js +800 -0
  189. package/esm/helpers/utils/wallet-helpers.js +22 -0
  190. package/esm/helpers/utils/wallet-redemption-helpers.js +46 -0
  191. package/esm/helpers/utils/warehouse-catalog-conversion.js +117 -0
  192. package/esm/helpers/utils/warehouse-inventory.js +59 -0
  193. package/esm/helpers/utils/warehouse-purchase-order-engine.js +27 -0
  194. package/esm/helpers/utils/warehouse-purchase-order-receipt-engine.js +205 -0
  195. package/esm/helpers/utils/warehouse-purchase-order-x-report-helpers.js +1432 -0
  196. package/esm/helpers/utils/warehouse-sale-order-engine.js +27 -0
  197. package/esm/helpers/utils/warehouse-sale-order-receipt-engine.js +207 -0
  198. package/esm/helpers/utils/warehouse-sale-order-x-report-helpers.js +1 -0
  199. package/esm/helpers/utils/warehouse-sale-x-report-helpers.js +1434 -0
  200. package/esm/helpers/utils/warehouse-settings-helpers.js +37 -0
  201. package/esm/helpers/utils/warehouse-void-purchase-order-items-helpers.js +34 -0
  202. package/esm/helpers/utils/warehouse-void-purchase-order-items-report-helpers.js +18 -0
  203. package/esm/helpers/utils/warehouse-void-sale-order-items-helpers.js +34 -0
  204. package/esm/helpers/utils/warehouse-void-sale-order-items-report-helpers.js +18 -0
  205. package/esm/helpers/utils/warehouse_inventory_transactions.js +91 -0
  206. package/esm/helpers/utils/x-report-helpers.js +1850 -0
  207. package/esm/index.js +3 -0
  208. package/esm/schemas/index.js +2 -0
  209. package/esm/schemas/models/app_configs.js +36 -0
  210. package/esm/schemas/models/applied_order_discounts.js +103 -0
  211. package/esm/schemas/models/brands.js +56 -0
  212. package/esm/schemas/models/categories.js +74 -0
  213. package/esm/schemas/models/close_dates.js +63 -0
  214. package/esm/schemas/models/common-models.js +449 -0
  215. package/esm/schemas/models/courses.js +62 -0
  216. package/esm/schemas/models/customer_redemptions.js +82 -0
  217. package/esm/schemas/models/customers.js +269 -0
  218. package/esm/schemas/models/deliveries.js +137 -0
  219. package/esm/schemas/models/delivery_areas.js +97 -0
  220. package/esm/schemas/models/dinein_floors.js +55 -0
  221. package/esm/schemas/models/dinein_tables.js +97 -0
  222. package/esm/schemas/models/dinein_tables_fingerprints.js +96 -0
  223. package/esm/schemas/models/discounts.js +87 -0
  224. package/esm/schemas/models/expense_categories.js +61 -0
  225. package/esm/schemas/models/expense_details.js +130 -0
  226. package/esm/schemas/models/gift_cards.js +342 -0
  227. package/esm/schemas/models/halfhalf_setup.js +142 -0
  228. package/esm/schemas/models/index.js +111 -0
  229. package/esm/schemas/models/internal_customers.js +139 -0
  230. package/esm/schemas/models/internal_invoices.js +119 -0
  231. package/esm/schemas/models/internal_leads.js +78 -0
  232. package/esm/schemas/models/internal_operational_roles.js +85 -0
  233. package/esm/schemas/models/internal_staffs.js +65 -0
  234. package/esm/schemas/models/inventories.js +103 -0
  235. package/esm/schemas/models/inventory_categories.js +52 -0
  236. package/esm/schemas/models/inventory_transactions.js +143 -0
  237. package/esm/schemas/models/item_transactions.js +117 -0
  238. package/esm/schemas/models/items.js +341 -0
  239. package/esm/schemas/models/marketing_fingerprints.js +92 -0
  240. package/esm/schemas/models/menus.js +66 -0
  241. package/esm/schemas/models/messaging_devices.js +99 -0
  242. package/esm/schemas/models/modifier_extras.js +120 -0
  243. package/esm/schemas/models/offers.js +470 -0
  244. package/esm/schemas/models/offers_fingerprints.js +61 -0
  245. package/esm/schemas/models/operational_roles.js +155 -0
  246. package/esm/schemas/models/orders.js +1051 -0
  247. package/esm/schemas/models/printer_settings.js +245 -0
  248. package/esm/schemas/models/public_holidays.js +58 -0
  249. package/esm/schemas/models/reservations.js +127 -0
  250. package/esm/schemas/models/reviews.js +145 -0
  251. package/esm/schemas/models/rewards_usage.js +61 -0
  252. package/esm/schemas/models/riders.js +75 -0
  253. package/esm/schemas/models/specials.js +169 -0
  254. package/esm/schemas/models/staff_shifts.js +66 -0
  255. package/esm/schemas/models/tenant-activity-logs.js +126 -0
  256. package/esm/schemas/models/tenant_active_jobs.js +77 -0
  257. package/esm/schemas/models/tenant_calendar.js +89 -0
  258. package/esm/schemas/models/tenant_cash_drawer_sessions.js +208 -0
  259. package/esm/schemas/models/tenant_cash_drawers.js +60 -0
  260. package/esm/schemas/models/tenant_cash_in_hand_transactions.js +69 -0
  261. package/esm/schemas/models/tenant_cash_in_out.js +104 -0
  262. package/esm/schemas/models/tenant_clients.js +66 -0
  263. package/esm/schemas/models/tenant_day_sessions.js +166 -0
  264. package/esm/schemas/models/tenant_hr_attendance_records.js +87 -0
  265. package/esm/schemas/models/tenant_hr_biometric_enrollments.js +69 -0
  266. package/esm/schemas/models/tenant_hr_departments.js +42 -0
  267. package/esm/schemas/models/tenant_hr_documents.js +71 -0
  268. package/esm/schemas/models/tenant_hr_employees.js +172 -0
  269. package/esm/schemas/models/tenant_hr_leave_requests.js +80 -0
  270. package/esm/schemas/models/tenant_hr_payrolls.js +131 -0
  271. package/esm/schemas/models/tenant_hr_performance_reviews.js +58 -0
  272. package/esm/schemas/models/tenant_hr_policies.js +57 -0
  273. package/esm/schemas/models/tenant_hr_positions.js +48 -0
  274. package/esm/schemas/models/tenant_hr_shift_schedules.js +84 -0
  275. package/esm/schemas/models/tenant_hr_shifts.js +64 -0
  276. package/esm/schemas/models/tenant_instore_shift_sessions.js +204 -0
  277. package/esm/schemas/models/tenant_instore_shifts.js +63 -0
  278. package/esm/schemas/models/tenant_inventory_department_transactions.js +116 -0
  279. package/esm/schemas/models/tenant_inventory_department_utilities.js +85 -0
  280. package/esm/schemas/models/tenant_inventory_departments.js +55 -0
  281. package/esm/schemas/models/tenant_inventory_entries.js +131 -0
  282. package/esm/schemas/models/tenant_metadata.js +88 -0
  283. package/esm/schemas/models/tenant_order_item_instructions.js +66 -0
  284. package/esm/schemas/models/tenant_purchase_order_vendor_returns.js +80 -0
  285. package/esm/schemas/models/tenant_purchase_orders.js +158 -0
  286. package/esm/schemas/models/tenant_shifts.js +57 -0
  287. package/esm/schemas/models/tenant_staffs.js +129 -0
  288. package/esm/schemas/models/tenant_vendors.js +99 -0
  289. package/esm/schemas/models/tenants.js +811 -0
  290. package/esm/schemas/models/terminal_devices.js +63 -0
  291. package/esm/schemas/models/tokens.js +73 -0
  292. package/esm/schemas/models/track_order_numbers.js +42 -0
  293. package/esm/schemas/models/void_order_items.js +210 -0
  294. package/esm/schemas/models/vouchers.js +101 -0
  295. package/esm/schemas/models/wallet_transactions.js +128 -0
  296. package/esm/schemas/models/wallets.js +44 -0
  297. package/esm/schemas/models/warehouse-activity-logs.js +144 -0
  298. package/esm/schemas/models/warehouse_categories.js +83 -0
  299. package/esm/schemas/models/warehouse_clients.js +81 -0
  300. package/esm/schemas/models/warehouse_communications.js +226 -0
  301. package/esm/schemas/models/warehouse_internal_movements.js +463 -0
  302. package/esm/schemas/models/warehouse_inventory_entries.js +125 -0
  303. package/esm/schemas/models/warehouse_inventory_lot_serial_numbers.js +188 -0
  304. package/esm/schemas/models/warehouse_inventory_transactions.js +133 -0
  305. package/esm/schemas/models/warehouse_item_transactions.js +97 -0
  306. package/esm/schemas/models/warehouse_items.js +173 -0
  307. package/esm/schemas/models/warehouse_operational_roles.js +87 -0
  308. package/esm/schemas/models/warehouse_purchase_order_receipts.js +163 -0
  309. package/esm/schemas/models/warehouse_purchase_order_rfqs.js +339 -0
  310. package/esm/schemas/models/warehouse_purchase_order_vendor_returns.js +199 -0
  311. package/esm/schemas/models/warehouse_purchase_orders.js +334 -0
  312. package/esm/schemas/models/warehouse_sale_deliveries.js +155 -0
  313. package/esm/schemas/models/warehouse_sale_invoices.js +229 -0
  314. package/esm/schemas/models/warehouse_sale_order_rfqs.js +340 -0
  315. package/esm/schemas/models/warehouse_sale_orders.js +322 -0
  316. package/esm/schemas/models/warehouse_staffs.js +104 -0
  317. package/esm/schemas/models/warehouse_track_order_numbers.js +73 -0
  318. package/esm/schemas/models/warehouse_vendors.js +99 -0
  319. package/esm/schemas/models/warehouse_void_purchase_order_items.js +174 -0
  320. package/esm/schemas/models/warehouse_void_sale_order_items.js +174 -0
  321. package/esm/schemas/models/warehouses.js +253 -0
  322. package/esm/schemas/types/app_configs.js +1 -0
  323. package/esm/schemas/types/applied_order_discounts.js +1 -0
  324. package/esm/schemas/types/brands.js +1 -0
  325. package/esm/schemas/types/categories.js +1 -0
  326. package/esm/schemas/types/close_dates.js +1 -0
  327. package/esm/schemas/types/common.js +1 -0
  328. package/esm/schemas/types/courses.js +1 -0
  329. package/esm/schemas/types/customer_redemptions.js +1 -0
  330. package/esm/schemas/types/customers.js +1 -0
  331. package/esm/schemas/types/deliveries.js +1 -0
  332. package/esm/schemas/types/delivery_areas.js +1 -0
  333. package/esm/schemas/types/dinein_floors.js +1 -0
  334. package/esm/schemas/types/dinein_tables.js +1 -0
  335. package/esm/schemas/types/dinein_tables_fingerprints.js +1 -0
  336. package/esm/schemas/types/discounts.js +1 -0
  337. package/esm/schemas/types/expense_categories.js +1 -0
  338. package/esm/schemas/types/expense_details.js +1 -0
  339. package/esm/schemas/types/gift_cards.js +1 -0
  340. package/esm/schemas/types/halfhalf_setup.js +1 -0
  341. package/esm/schemas/types/index.js +113 -0
  342. package/esm/schemas/types/internal_customers.js +1 -0
  343. package/esm/schemas/types/internal_invoices.js +1 -0
  344. package/esm/schemas/types/internal_leads.js +1 -0
  345. package/esm/schemas/types/internal_operational_roles.js +16 -0
  346. package/esm/schemas/types/internal_staffs.js +1 -0
  347. package/esm/schemas/types/inventories.js +1 -0
  348. package/esm/schemas/types/inventory_categories.js +1 -0
  349. package/esm/schemas/types/inventory_department_transactions.js +1 -0
  350. package/esm/schemas/types/inventory_department_utilities.js +1 -0
  351. package/esm/schemas/types/inventory_departments.js +1 -0
  352. package/esm/schemas/types/inventory_transactions.js +1 -0
  353. package/esm/schemas/types/item_transactions.js +1 -0
  354. package/esm/schemas/types/items.js +1 -0
  355. package/esm/schemas/types/marketing_fingerprints.js +1 -0
  356. package/esm/schemas/types/menus.js +1 -0
  357. package/esm/schemas/types/messaging_devices.js +1 -0
  358. package/esm/schemas/types/modifier_extras.js +1 -0
  359. package/esm/schemas/types/multi_tenants.js +1 -0
  360. package/esm/schemas/types/offers.js +1 -0
  361. package/esm/schemas/types/offers_fingerprints.js +1 -0
  362. package/esm/schemas/types/operational_roles.js +15 -0
  363. package/esm/schemas/types/orders.js +1 -0
  364. package/esm/schemas/types/printer_settings.js +1 -0
  365. package/esm/schemas/types/public_holidays.js +1 -0
  366. package/esm/schemas/types/reservations.js +1 -0
  367. package/esm/schemas/types/reviews.js +1 -0
  368. package/esm/schemas/types/rewards_usage.js +1 -0
  369. package/esm/schemas/types/riders.js +1 -0
  370. package/esm/schemas/types/specials.js +1 -0
  371. package/esm/schemas/types/staff_shifts.js +1 -0
  372. package/esm/schemas/types/tenant-activity-logs.js +1 -0
  373. package/esm/schemas/types/tenant_active_jobs.js +1 -0
  374. package/esm/schemas/types/tenant_calendar.js +1 -0
  375. package/esm/schemas/types/tenant_cash_drawer_sessions.js +1 -0
  376. package/esm/schemas/types/tenant_cash_drawers.js +1 -0
  377. package/esm/schemas/types/tenant_cash_in_hand_transactions.js +1 -0
  378. package/esm/schemas/types/tenant_cash_in_out.js +1 -0
  379. package/esm/schemas/types/tenant_clients.js +1 -0
  380. package/esm/schemas/types/tenant_day_sessions.js +1 -0
  381. package/esm/schemas/types/tenant_hr_attendance_records.js +1 -0
  382. package/esm/schemas/types/tenant_hr_biometric_enrollments.js +1 -0
  383. package/esm/schemas/types/tenant_hr_departments.js +1 -0
  384. package/esm/schemas/types/tenant_hr_documents.js +1 -0
  385. package/esm/schemas/types/tenant_hr_employees.js +1 -0
  386. package/esm/schemas/types/tenant_hr_leave_requests.js +1 -0
  387. package/esm/schemas/types/tenant_hr_payrolls.js +1 -0
  388. package/esm/schemas/types/tenant_hr_performance_reviews.js +1 -0
  389. package/esm/schemas/types/tenant_hr_policies.js +1 -0
  390. package/esm/schemas/types/tenant_hr_positions.js +1 -0
  391. package/esm/schemas/types/tenant_hr_shift_schedules.js +1 -0
  392. package/esm/schemas/types/tenant_hr_shifts.js +1 -0
  393. package/esm/schemas/types/tenant_instore_shift_sessions.js +1 -0
  394. package/esm/schemas/types/tenant_instore_shifts.js +1 -0
  395. package/esm/schemas/types/tenant_inventory_entries.js +1 -0
  396. package/esm/schemas/types/tenant_metadata.js +1 -0
  397. package/esm/schemas/types/tenant_order_item_instructions.js +1 -0
  398. package/esm/schemas/types/tenant_purchase_order_vendor_returns.js +1 -0
  399. package/esm/schemas/types/tenant_purchase_orders.js +1 -0
  400. package/esm/schemas/types/tenant_shifts.js +1 -0
  401. package/esm/schemas/types/tenant_staffs.js +1 -0
  402. package/esm/schemas/types/tenant_vendors.js +1 -0
  403. package/esm/schemas/types/tenants.js +1 -0
  404. package/esm/schemas/types/terminal_devices.js +1 -0
  405. package/esm/schemas/types/tokens.js +1 -0
  406. package/esm/schemas/types/track_order_numbers.js +1 -0
  407. package/esm/schemas/types/void_order_items.js +1 -0
  408. package/esm/schemas/types/vouchers.js +1 -0
  409. package/esm/schemas/types/wallet_transactions.js +1 -0
  410. package/esm/schemas/types/wallets.js +1 -0
  411. package/esm/schemas/types/warehouse-activity-logs.js +1 -0
  412. package/esm/schemas/types/warehouse_categories.js +1 -0
  413. package/esm/schemas/types/warehouse_clients.js +1 -0
  414. package/esm/schemas/types/warehouse_communications.js +1 -0
  415. package/esm/schemas/types/warehouse_internal_movements.js +1 -0
  416. package/esm/schemas/types/warehouse_inventory_entries.js +1 -0
  417. package/esm/schemas/types/warehouse_inventory_lot_serial_numbers.js +1 -0
  418. package/esm/schemas/types/warehouse_inventory_transactions.js +1 -0
  419. package/esm/schemas/types/warehouse_item_transactions.js +1 -0
  420. package/esm/schemas/types/warehouse_items.js +1 -0
  421. package/esm/schemas/types/warehouse_operational_roles.js +15 -0
  422. package/esm/schemas/types/warehouse_purchase_order_receipts.js +18 -0
  423. package/esm/schemas/types/warehouse_purchase_order_rfqs.js +1 -0
  424. package/esm/schemas/types/warehouse_purchase_order_vendor_returns.js +1 -0
  425. package/esm/schemas/types/warehouse_purchase_orders.js +1 -0
  426. package/esm/schemas/types/warehouse_sale_deliveries.js +1 -0
  427. package/esm/schemas/types/warehouse_sale_invoices.js +1 -0
  428. package/esm/schemas/types/warehouse_sale_order_rfqs.js +1 -0
  429. package/esm/schemas/types/warehouse_sale_orders.js +1 -0
  430. package/esm/schemas/types/warehouse_staffs.js +1 -0
  431. package/esm/schemas/types/warehouse_track_order_numbers.js +1 -0
  432. package/esm/schemas/types/warehouse_vendors.js +1 -0
  433. package/esm/schemas/types/warehouse_void_purchase_order_items.js +1 -0
  434. package/esm/schemas/types/warehouse_void_sale_order_items.js +1 -0
  435. package/esm/schemas/types/warehouses.js +1 -0
  436. package/lib/helpers/types/api-types.d.ts +37 -0
  437. package/package.json +6 -3
@@ -0,0 +1,31 @@
1
+ import { ALL_SCAN_CODE_TYPES, SCAN_CODE_IDENTIFIER_SEPARATOR } from '../../constants';
2
+ // =======================>>><<<=======================
3
+ /**
4
+ * Builds a scannable barcode/QR identifier: `<type>:<entity id>`
5
+ * (e.g. `POS_ITEM:<item._id>`, `INVENTORY_CODE:<inventory entry _id>`).
6
+ */
7
+ export function buildScanCode(type, id) {
8
+ return `${type}${SCAN_CODE_IDENTIFIER_SEPARATOR}${id}`;
9
+ }
10
+ /**
11
+ * Parses a scanned barcode/QR payload back into its parts, or null when the
12
+ * payload does not follow the `<type>:<entity id>` format. Callers ignore
13
+ * null — only supported enum types are ever returned.
14
+ *
15
+ * Only the FIRST separator is structural: the type must be one of
16
+ * `ALL_SCAN_CODE_TYPES` and the remaining string is the code untouched.
17
+ */
18
+ export function parseScanCode(raw) {
19
+ if (!raw)
20
+ return null;
21
+ const separatorIndex = raw.indexOf(SCAN_CODE_IDENTIFIER_SEPARATOR);
22
+ if (separatorIndex <= 0)
23
+ return null; // no separator, or empty type
24
+ const type = raw.slice(0, separatorIndex);
25
+ if (!ALL_SCAN_CODE_TYPES.includes(type))
26
+ return null;
27
+ const code = raw.slice(separatorIndex + 1);
28
+ if (!code)
29
+ return null; // missing entity id
30
+ return { type, code };
31
+ }
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Builds IOrderModifier[] from selection groups (save direction).
3
+ * Occurrence `_id`s are the real deterministic entity ids: groups use
4
+ * `group.ref` (modifierSpecial/segment `_id`), options use `option.ref`
5
+ * (catalog item `_id`) — same as `ref`, like catalog IItem ids. Stored
6
+ * `_id`s are kept when present (legacy lines).
7
+ */
8
+ export function buildStoredFromSelection(groups) {
9
+ const modifiers = [];
10
+ for (let i = 0; i < groups.length; i++) {
11
+ const group = groups[i];
12
+ if (group.options.length === 0)
13
+ continue;
14
+ const options = group.options.map((option) => ({
15
+ _id: option._id.length > 0 ? option._id : option.ref,
16
+ ref: option.ref,
17
+ name: option.name,
18
+ price: option.price,
19
+ quantity: option.quantity,
20
+ is_free: option.is_free,
21
+ ...(option.ref_type != null ? { ref_type: option.ref_type } : {}),
22
+ modifiers: option.modifiers ?? null,
23
+ }));
24
+ modifiers.push({
25
+ _id: group._id.length > 0 ? group._id : group.ref,
26
+ ref: group.ref,
27
+ name: group.name,
28
+ options,
29
+ });
30
+ }
31
+ return modifiers;
32
+ }
33
+ /**
34
+ * Builds FIFO queues of stored order modifiers/options keyed by their
35
+ * deterministic `ref`, preserving stored order. Empty refs are skipped so
36
+ * they can never alias.
37
+ */
38
+ export function buildSelectionRefQueues(items) {
39
+ const queues = new Map();
40
+ for (let i = 0; i < items.length; i++) {
41
+ const item = items[i];
42
+ if (item.ref.length === 0)
43
+ continue;
44
+ const queue = queues.get(item.ref);
45
+ if (queue == null) {
46
+ queues.set(item.ref, [item]);
47
+ }
48
+ else {
49
+ queue.push(item);
50
+ }
51
+ }
52
+ return queues;
53
+ }
54
+ /**
55
+ * Consumes one stored occurrence for a catalog entity (duplicate-safe):
56
+ * prefers an exact `_id` hit (same converted instance, e.g. legacy data where
57
+ * `_id` equals the source ref), otherwise takes the oldest stored occurrence
58
+ * with the ref (FIFO, deterministic). Returns undefined when nothing is left.
59
+ */
60
+ export function consumeSelectionMatch(queues, ref, exactId) {
61
+ if (queues == null || ref.length === 0)
62
+ return undefined;
63
+ const queue = queues.get(ref);
64
+ if (queue == null || queue.length === 0)
65
+ return undefined;
66
+ const exactIndex = exactId.length > 0 ? queue.findIndex((item) => item._id === exactId) : -1;
67
+ return exactIndex !== -1 ? queue.splice(exactIndex, 1)[0] : queue.shift();
68
+ }
@@ -0,0 +1,148 @@
1
+ import { ALL_DAY_INDEX } from '../../constants';
2
+ import { getTenantTime } from './time-helpers';
3
+ /**
4
+ * Shared shift-window math for the business-day lifecycle — the single source
5
+ * of truth used by the backend (items-service day/shift/drawer sessions and
6
+ * guards), the POS frontend (day window, staleness gating) and the admin panel
7
+ * (shift-template validation).
8
+ *
9
+ * Time convention (the "POS frame"): every position produced here is an
10
+ * epoch-ms value in a frame where the tenant's local wall clock reads as UTC —
11
+ * `Date.UTC(...)` of the tenant's local date/time components. The frame is
12
+ * built from the tenant's `operational_time_zone_offset_gmt` (via
13
+ * `getTenantTime`), never from the runtime/server timezone, so the same
14
+ * instant yields the same positions in every process (backend, worker,
15
+ * browser).
16
+ *
17
+ * Shift templates (`ITenantInstoreShift`) store `start_time` / `end_time` as
18
+ * milliseconds from their START day's midnight. Overnight windows are normally
19
+ * stored with an `end_time` beyond 24h (e.g. 27:00:59.999 = 3:00:59.999 AM the
20
+ * next day); legacy/wrapped rows may instead carry `end_time <= start_time`,
21
+ * meaning the window crosses midnight — an equal start/end wraps a full +24h
22
+ * (the same `end <= start` convention the admin overlap validator documents).
23
+ */
24
+ /** Milliseconds in a day. */
25
+ export const MS_IN_DAY = 24 * 60 * 60 * 1000;
26
+ /**
27
+ * Resolves an instant into the tenant's POS frame: `dayMidnightMs` is the
28
+ * tenant-local calendar day's midnight, `nowPos` the instant itself and
29
+ * `timeMs` the time since local midnight.
30
+ *
31
+ * Server-timezone independent — the wall-clock components are read off the
32
+ * `getTenantTime`-shifted date with local getters (the same convention as
33
+ * `getLocalDocumentFields`).
34
+ */
35
+ export function getTenantFramePosition(gmtOffset, now = new Date()) {
36
+ const tenantTime = getTenantTime(gmtOffset, now);
37
+ const dayMidnightMs = Date.UTC(tenantTime.getFullYear(), tenantTime.getMonth(), tenantTime.getDate());
38
+ const timeMs = ((tenantTime.getHours() * 60 + tenantTime.getMinutes()) * 60 + tenantTime.getSeconds()) * 1000 +
39
+ tenantTime.getMilliseconds();
40
+ return { tenantTime, nowPos: dayMidnightMs + timeMs, dayMidnightMs, timeMs };
41
+ }
42
+ /** `YYYY-MM-DD` of a POS-frame midnight (UTC getters — deterministic). */
43
+ export function formatLocalDateFromMidnight(dayMidnightMs) {
44
+ const date = new Date(dayMidnightMs);
45
+ return `${date.getUTCFullYear()}-${String(date.getUTCMonth() + 1).padStart(2, '0')}-${String(date.getUTCDate()).padStart(2, '0')}`;
46
+ }
47
+ /**
48
+ * The tenant's current local calendar date (`YYYY-MM-DD`) — the raw clock date
49
+ * in the tenant's timezone, NOT the business date. Use
50
+ * `resolveBusinessLocalDate` / `getCurrentBusinessDay` when the restaurant-day
51
+ * is meant.
52
+ */
53
+ export function getTenantLocalDate(gmtOffset, now = new Date()) {
54
+ return formatLocalDateFromMidnight(getTenantFramePosition(gmtOffset, now).dayMidnightMs);
55
+ }
56
+ /** POS-frame midnight (ms) of a `YYYY-MM-DD` local date. */
57
+ export function getLocalDateMidnightMs(localDate) {
58
+ const [localYear, localMonth, localDay] = localDate.split('-').map(Number);
59
+ return Date.UTC(localYear, localMonth - 1, localDay);
60
+ }
61
+ /** `2026-09-13` + 1 → `2026-09-14` — plain calendar date-string math. */
62
+ export function addDaysToLocalDate(localDate, days) {
63
+ return formatLocalDateFromMidnight(getLocalDateMidnightMs(localDate) + days * MS_IN_DAY);
64
+ }
65
+ /**
66
+ * End position of a shift window (absolute POS-frame ms): `dayMidnightMs +
67
+ * end_time`, rolled a full day for wrapped shifts (`end_time <= start_time`).
68
+ * A stored `end_time` beyond 24h rolls naturally past midnight.
69
+ */
70
+ export function getShiftEndPosition(dayMidnightMs, shift) {
71
+ return dayMidnightMs + (shift.end_time <= shift.start_time ? MS_IN_DAY : 0) + shift.end_time;
72
+ }
73
+ /** Start position of a shift window (absolute POS-frame ms). */
74
+ export function getShiftStartPosition(dayMidnightMs, shift) {
75
+ return dayMidnightMs + shift.start_time;
76
+ }
77
+ /** ACTIVE shifts scheduled for a weekday (`day_indexes` includes it). */
78
+ export function getScheduledShiftsForDay(shifts, dayIndex) {
79
+ return shifts.filter((shift) => shift.active === true && shift.day_indexes.includes(dayIndex));
80
+ }
81
+ /** Last end position among a day's scheduled shifts (absolute), or null when none. */
82
+ export function getLastShiftEndPosition(shifts, dayMidnightMs, dayIndex) {
83
+ const dayShifts = getScheduledShiftsForDay(shifts, dayIndex);
84
+ if (!dayShifts.length)
85
+ return null;
86
+ return dayShifts.reduce((latest, shift) => Math.max(latest, getShiftEndPosition(dayMidnightMs, shift)), 0);
87
+ }
88
+ /** Earliest start position among a day's scheduled shifts (absolute), or null when none. */
89
+ export function getFirstShiftStartPosition(shifts, dayMidnightMs, dayIndex) {
90
+ const dayShifts = getScheduledShiftsForDay(shifts, dayIndex);
91
+ if (!dayShifts.length)
92
+ return null;
93
+ return dayShifts.reduce((earliest, shift) => Math.min(earliest, getShiftStartPosition(dayMidnightMs, shift)), Infinity);
94
+ }
95
+ /**
96
+ * Whether a new business day may be started for a CLOSED day (mirrors the POS
97
+ * `dayWindow` / the backend day guard): the closed day's `localDate` must be
98
+ * BEHIND the tenant's current local date AND the previous day must have fully
99
+ * elapsed — `now` is past the LAST end position of the shifts scheduled on the
100
+ * closed day's weekday.
101
+ *
102
+ * Returns `null` when there is no anchor to decide with (no shift scheduled on
103
+ * the closed day's weekday or on the next day's weekday) — callers apply their
104
+ * legacy fallback (e.g. "a new day may start only when none is running").
105
+ */
106
+ export function canStartNewBusinessDay(shifts, dayLocalDate, gmtOffset, now = new Date()) {
107
+ const frame = getTenantFramePosition(gmtOffset, now);
108
+ const dayMidnightMs = getLocalDateMidnightMs(dayLocalDate);
109
+ const nextDayMidnightMs = dayMidnightMs + MS_IN_DAY;
110
+ const dayIndex = ALL_DAY_INDEX[new Date(dayMidnightMs).getUTCDay()];
111
+ const nextDayIndex = ALL_DAY_INDEX[new Date(nextDayMidnightMs).getUTCDay()];
112
+ const lastEndPosition = getLastShiftEndPosition(shifts, dayMidnightMs, dayIndex);
113
+ const firstNextStartPosition = getFirstShiftStartPosition(shifts, nextDayMidnightMs, nextDayIndex);
114
+ // No shift anchor → the caller applies its legacy fallback.
115
+ if (lastEndPosition == null || firstNextStartPosition == null)
116
+ return null;
117
+ const dayBehind = dayLocalDate < formatLocalDateFromMidnight(frame.dayMidnightMs);
118
+ const pastLastShiftEnd = frame.nowPos > lastEndPosition;
119
+ return dayBehind && pastLastShiftEnd;
120
+ }
121
+ /**
122
+ * Normalizes a shift time-range into coverage intervals on the
123
+ * `[0, 2 * MS_IN_DAY)` timeline so overnight windows (`end_time <= start_time`)
124
+ * are handled directly — `22:00–02:00` covers `[22:00, 24:00]` + `[00:00,
125
+ * 02:00]`. Same wrap convention as `getShiftEndPosition` (equal start/end
126
+ * wraps a full day).
127
+ */
128
+ export function getShiftCoverageIntervals(startTime, endTime) {
129
+ const normalizedEnd = endTime <= startTime ? endTime + MS_IN_DAY : endTime;
130
+ if (normalizedEnd <= MS_IN_DAY) {
131
+ return [[startTime, normalizedEnd]];
132
+ }
133
+ return [
134
+ [startTime, MS_IN_DAY],
135
+ [0, normalizedEnd - MS_IN_DAY],
136
+ ];
137
+ }
138
+ /**
139
+ * Whether two shift time-ranges overlap. Half-open intervals — back-to-back
140
+ * shifts (one ends exactly when the other starts) do NOT conflict. Day
141
+ * (`day_indexes`) and tenant matching stay with the caller (e.g. the admin
142
+ * panel's shift-template conflict finder).
143
+ */
144
+ export function doShiftWindowsOverlap(a, b) {
145
+ const aCoverage = getShiftCoverageIntervals(a.start_time, a.end_time);
146
+ const bCoverage = getShiftCoverageIntervals(b.start_time, b.end_time);
147
+ return aCoverage.some(([aStart, aEnd]) => bCoverage.some(([bStart, bEnd]) => aStart < bEnd && bStart < aEnd));
148
+ }
@@ -0,0 +1,107 @@
1
+ import { convertOriginalPlatformNumToMinifiedPlatformNum, convertOriginalSpecialHoursToMinifiedSpecialHours, } from './minified-catalog';
2
+ // =========================>>><<<=========================
3
+ export function convertPartialCatalogItemToPartialSimplifiedItem(item, tenantId) {
4
+ return {
5
+ ...(item.hide_name !== undefined ? { hide_name: item.hide_name } : {}),
6
+ ...(item.sold_out !== undefined ? { sold_out: item.sold_out.includes(tenantId) } : {}),
7
+ ...(item.caveats !== undefined ? { caveats: item.caveats } : {}),
8
+ ...(item.dietary_preferences !== undefined ? { dietary_preferences: item.dietary_preferences } : {}),
9
+ ...(item.is_featured ? { is_featured: item.is_featured, featured_sort_id: item.featured_sort_id } : {}),
10
+ ...(item.display_price != undefined ? { display_price: item.display_price } : {}),
11
+ ...(item.show_starting_from !== undefined ? { show_starting_from: item.show_starting_from } : {}),
12
+ ...(item.sort_id !== undefined ? { sort_id: item.sort_id } : {}),
13
+ ...(item.keywords !== undefined ? { keywords: item.keywords } : {}),
14
+ ...(item.is_discount_percentage !== undefined ? { is_discount_percentage: item.is_discount_percentage } : {}),
15
+ ...(item._id !== undefined ? { _id: item._id } : {}),
16
+ ...(item.category_id !== undefined ? { category_id: item.category_id } : {}),
17
+ ...(item.name !== undefined ? { name: item.name } : {}),
18
+ ...(item.description !== undefined ? { description: item.description } : {}),
19
+ ...(item.active !== undefined ? { active: item.active } : {}),
20
+ ...(item.sort_id !== undefined ? { sort_id: item.sort_id } : {}),
21
+ ...(item.image_url !== undefined ? { image_url: item.image_url } : {}),
22
+ ...(item.price !== undefined ? { price: convertOriginalPlatformNumToMinifiedPlatformNum(item.price) } : {}),
23
+ ...(item.discount_amount !== undefined
24
+ ? { discount_amount: convertOriginalPlatformNumToMinifiedPlatformNum(item.discount_amount) }
25
+ : {}),
26
+ ...(item.tax_rate !== undefined
27
+ ? { tax_rate: convertOriginalPlatformNumToMinifiedPlatformNum(item.tax_rate) }
28
+ : {}),
29
+ ...(item.item_special_hours !== undefined
30
+ ? { item_special_hours: convertOriginalSpecialHoursToMinifiedSpecialHours(item.item_special_hours) }
31
+ : {}),
32
+ ...(item.included_platforms !== undefined ? { included_platforms: item.included_platforms } : {}),
33
+ ...(item.modifiers !== undefined
34
+ ? { modifiers: item.modifiers === null || item.modifiers?.length === 0 ? null : undefined }
35
+ : {}),
36
+ };
37
+ }
38
+ export function convertCatalogItemToSimplifiedItem(item, tenantId) {
39
+ return {
40
+ hide_name: item.hide_name || undefined,
41
+ sold_out: item.sold_out.includes(tenantId) || undefined,
42
+ caveats: item.caveats.length > 0 ? item.caveats : undefined,
43
+ dietary_preferences: item.dietary_preferences.length > 0 ? item.dietary_preferences : undefined,
44
+ is_featured: item.is_featured || undefined,
45
+ featured_sort_id: item.is_featured ? item.featured_sort_id : undefined,
46
+ display_price: item.display_price ?? undefined,
47
+ show_starting_from: item.show_starting_from || undefined,
48
+ keywords: item.keywords.length > 0 ? item.keywords : undefined,
49
+ is_discount_percentage: item.is_discount_percentage || undefined,
50
+ _id: item._id,
51
+ category_id: item.category_id,
52
+ name: item.name,
53
+ description: item.description,
54
+ active: item.active,
55
+ sort_id: item.sort_id,
56
+ image_url: item.image_url,
57
+ price: convertOriginalPlatformNumToMinifiedPlatformNum(item.price),
58
+ discount_amount: convertOriginalPlatformNumToMinifiedPlatformNum(item.discount_amount),
59
+ tax_rate: convertOriginalPlatformNumToMinifiedPlatformNum(item.tax_rate),
60
+ item_special_hours: convertOriginalSpecialHoursToMinifiedSpecialHours(item.item_special_hours),
61
+ included_platforms: item.included_platforms,
62
+ modifiers: item.modifiers === null || item.modifiers?.length === 0 ? null : undefined,
63
+ };
64
+ }
65
+ export function convertCatalogItemsToSimplifiedItems(items, tenantId) {
66
+ const newItems = [];
67
+ for (let j = 0; j < items.length; j++) {
68
+ const item = items[j];
69
+ const simpleItem = convertCatalogItemToSimplifiedItem(item, tenantId);
70
+ newItems.push(simpleItem);
71
+ }
72
+ return newItems;
73
+ }
74
+ // =========================>>><<<=========================
75
+ export function convertPartialCatalogCategoryToPartialSimplifiedCategory(category) {
76
+ return {
77
+ _id: category._id,
78
+ image_url: category.image_url,
79
+ name: category.name,
80
+ subtitle: category.subtitle,
81
+ active: category.active,
82
+ sort_id: category.sort_id,
83
+ display_type: category.display_type,
84
+ };
85
+ }
86
+ export function convertCatalogCategoryToSimpleCategory(category) {
87
+ return {
88
+ _id: category._id,
89
+ image_url: category.image_url,
90
+ banner_url: category.banner_url || undefined,
91
+ name: category.name,
92
+ subtitle: category.subtitle,
93
+ active: category.active,
94
+ sort_id: category.sort_id,
95
+ display_type: category.display_type,
96
+ };
97
+ }
98
+ export function convertCatalogCategoriesToSimplifiedCategories(categories) {
99
+ const newCategories = [];
100
+ for (let i = 0; i < categories.length; i++) {
101
+ const category = categories[i];
102
+ const simpleCategory = convertCatalogCategoryToSimpleCategory(category);
103
+ newCategories.push(simpleCategory);
104
+ }
105
+ return newCategories;
106
+ }
107
+ // =========================>>><<<=========================
@@ -0,0 +1,101 @@
1
+ import { convertMinifiedPlatformNumToOriginalPlatformNum, convertMinifiedSpecialHoursToOriginalSpecialHours, convertOriginalPlatformNumToMinifiedPlatformNum, convertOriginalSpecialHoursToMinifiedSpecialHours, } from './minified-catalog';
2
+ import { convertMinifiedPriceFromCents, convertMinifiedPriceToCents, convertMinifiedSpecialHoursFromCents, convertMinifiedSpecialHoursToCents, } from './platform-num';
3
+ export function convertHalfHalfSetupToSimplifiedHalfHalfSetup(halfhalfSetup, tenantId) {
4
+ return {
5
+ sold_out: halfhalfSetup.sold_out.includes(tenantId) || undefined,
6
+ is_discount_percentage: halfhalfSetup.is_discount_percentage || undefined,
7
+ discount_amount: convertOriginalPlatformNumToMinifiedPlatformNum(halfhalfSetup.discount_amount),
8
+ item_special_hours: convertOriginalSpecialHoursToMinifiedSpecialHours(halfhalfSetup.item_special_hours),
9
+ // Only sent when true (keeps the minified payload lean, same as above).
10
+ choose_expensive_segment_price: halfhalfSetup.choose_expensive_segment_price || undefined,
11
+ _id: halfhalfSetup._id,
12
+ category_id: halfhalfSetup.category_id,
13
+ name: halfhalfSetup.name,
14
+ description: halfhalfSetup.description,
15
+ active: halfhalfSetup.active,
16
+ image_url: halfhalfSetup.image_url,
17
+ included_platforms: halfhalfSetup.included_platforms,
18
+ };
19
+ }
20
+ export function convertHalfHalfSetupsToSimplifiedHalfHalfSetups(halfhalfSetups, tenantId) {
21
+ const newHalfHalfSetups = [];
22
+ for (let i = 0; i < halfhalfSetups.length; i++) {
23
+ const halfhalfSetup = halfhalfSetups[i];
24
+ newHalfHalfSetups.push(convertHalfHalfSetupToSimplifiedHalfHalfSetup(halfhalfSetup, tenantId));
25
+ }
26
+ return newHalfHalfSetups;
27
+ }
28
+ /**
29
+ * Converts an ISimplifiedHalfHalfSetup into an ISimplifiedCatalogItem so it
30
+ * can flow through the standard catalog → drawer → cart pipeline just like a
31
+ * regular simplified catalog item (the simplified counterpart of
32
+ * `convertHalfHalfToItem`).
33
+ *
34
+ * The simplified half-half payload carries only menu-list data — no segments,
35
+ * no constituent items, no upsell and no ref rules — so this is a pure field
36
+ * mapping of what ISimplifiedCatalogItem can represent:
37
+ * - item `price`/`tax_rate` are null (there is no base price on the payload;
38
+ * the per-segment prices come from the constituent items at selection time),
39
+ * - `discount_amount` and `item_special_hours` are already in the dollar/UI
40
+ * domain (converted at slice ingest via `getSimplifiedHalfHalfSetupWithPrice`),
41
+ * so only the minified shape is normalized — NO currency re-scaling,
42
+ * mirroring `convertHalfHalfToItem` after `getHalfhalfSetupWithPrice`,
43
+ * - no `modifiers` are produced (selection structure isn't part of the
44
+ * simplified setup),
45
+ * - `sort_id` is not part of the payload, so it defaults to 0 (same as
46
+ * `convertHalfHalfToItem`).
47
+ */
48
+ export function convertSimplifiedHalfHalfToSimplifiedItem(halfhalfSetup) {
49
+ // Dollar/UI domain input (set at slice ingest) — normalize the minified
50
+ // shape only, no currency re-scaling (mirrors convertHalfHalfToItem).
51
+ const discount_amount = convertMinifiedPlatformNumToOriginalPlatformNum(halfhalfSetup.discount_amount);
52
+ const item_special_hours = convertMinifiedSpecialHoursToOriginalSpecialHours(halfhalfSetup.item_special_hours);
53
+ return {
54
+ sold_out: halfhalfSetup.sold_out,
55
+ is_discount_percentage: halfhalfSetup.is_discount_percentage,
56
+ discount_amount,
57
+ item_special_hours,
58
+ // No base price / tax on the simplified payload; per-segment prices are
59
+ // resolved from the constituent items at selection time.
60
+ price: null,
61
+ tax_rate: null,
62
+ modifiers: null,
63
+ // sort_id is not part of the simplified payload (mirrors convertHalfHalfToItem).
64
+ sort_id: 0,
65
+ hide_name: false,
66
+ is_featured: false,
67
+ featured_sort_id: 0,
68
+ show_starting_from: false,
69
+ _id: halfhalfSetup._id,
70
+ category_id: halfhalfSetup.category_id,
71
+ name: halfhalfSetup.name,
72
+ included_platforms: halfhalfSetup.included_platforms,
73
+ description: halfhalfSetup.description,
74
+ active: halfhalfSetup.active,
75
+ image_url: halfhalfSetup.image_url,
76
+ };
77
+ }
78
+ /**
79
+ * Converts an ISimplifiedHalfHalfSetup's minified money fields (and those
80
+ * nested in `item_special_hours`) between the cents (server) domain and the
81
+ * dollar/UI domain while preserving the simplified payload shape. Mirrors
82
+ * `getHalfhalfSetupWithPrice` for the full IHalfHalfSetup:
83
+ * - `discount_amount` (IMinifiedPrice) is scaled (a scalar stays a scalar),
84
+ * - `item_special_hours` prices are scaled in place.
85
+ *
86
+ * Only present fields are rewritten; absent fields stay absent (the payload
87
+ * carries no upsell/items to convert).
88
+ */
89
+ export function getSimplifiedHalfHalfSetupWithPrice(halfhalfSetup, writeable) {
90
+ const convertToPrice = writeable ? convertMinifiedPriceToCents : convertMinifiedPriceFromCents;
91
+ const convertItemSpecialHours = writeable ? convertMinifiedSpecialHoursToCents : convertMinifiedSpecialHoursFromCents;
92
+ return {
93
+ ...halfhalfSetup,
94
+ ...(halfhalfSetup.discount_amount != null
95
+ ? { discount_amount: convertToPrice(halfhalfSetup.discount_amount) }
96
+ : {}),
97
+ ...(halfhalfSetup.item_special_hours != null
98
+ ? { item_special_hours: convertItemSpecialHours(halfhalfSetup.item_special_hours) }
99
+ : {}),
100
+ };
101
+ }
@@ -0,0 +1,107 @@
1
+ import { convertMinifiedPlatformNumToOriginalPlatformNum, convertMinifiedSpecialHoursToOriginalSpecialHours, convertOriginalPlatformNumToMinifiedPlatformNum, convertOriginalSpecialHoursToMinifiedSpecialHours, } from './minified-catalog';
2
+ import { convertMinifiedPriceFromCents, convertMinifiedPriceToCents, convertMinifiedSpecialHoursFromCents, convertMinifiedSpecialHoursToCents, } from './platform-num';
3
+ import { convertPriceFromCents, convertPriceToCents } from './price-conversion';
4
+ export function convertSpecialToSimplifiedSpecial(special, tenantId) {
5
+ return {
6
+ sold_out: special.sold_out.includes(tenantId) || undefined,
7
+ display_price: special.display_price ?? undefined,
8
+ show_starting_from: special.show_starting_from || undefined,
9
+ is_discount_percentage: special.is_discount_percentage || undefined,
10
+ price: convertOriginalPlatformNumToMinifiedPlatformNum(special.price),
11
+ discount_amount: convertOriginalPlatformNumToMinifiedPlatformNum(special.discount_amount),
12
+ item_special_hours: convertOriginalSpecialHoursToMinifiedSpecialHours(special.item_special_hours),
13
+ _id: special._id,
14
+ category_id: special.category_id,
15
+ name: special.name,
16
+ description: special.description,
17
+ active: special.active,
18
+ sort_id: special.sort_id,
19
+ image_url: special.image_url,
20
+ included_platforms: special.included_platforms,
21
+ };
22
+ }
23
+ export function convertSpecialsToSimplifiedSpecials(specials, tenantId) {
24
+ const newSpecials = [];
25
+ for (let i = 0; i < specials.length; i++) {
26
+ const special = specials[i];
27
+ newSpecials.push(convertSpecialToSimplifiedSpecial(special, tenantId));
28
+ }
29
+ return newSpecials;
30
+ }
31
+ /**
32
+ * Converts an ISimplifiedSpecial into an ISimplifiedCatalogItem so it can
33
+ * flow through the standard catalog → drawer → cart pipeline just like a
34
+ * regular simplified catalog item (the simplified counterpart of
35
+ * `convertSpecialToItem`).
36
+ *
37
+ * The simplified special payload carries only menu-list data — the
38
+ * modifier_specials selection structure is dropped — so this is a pure field
39
+ * mapping of what ISimplifiedCatalogItem can represent:
40
+ * - the simplified setup is already in the dollar/UI domain (converted at
41
+ * slice ingest via `getSimplifiedSpecialWithPrice`), so only the minified
42
+ * shape is normalized (scalar → `{ BASE_PRICE }`) — NO currency re-scaling,
43
+ * mirroring `convertSpecialToItem` after `getSpecialWithPrice`,
44
+ * - `tax_rate` is null (not part of the special payload, mirrors
45
+ * `convertSpecialToItem`),
46
+ * - no `modifiers` are produced (selection structure isn't part of the
47
+ * simplified setup).
48
+ */
49
+ export function convertSimplifiedSpecialToSimplifiedItem(special) {
50
+ // Dollar/UI domain input (set at slice ingest) — normalize the minified
51
+ // shape only, no currency re-scaling (mirrors convertSpecialToItem).
52
+ const price = convertMinifiedPlatformNumToOriginalPlatformNum(special.price);
53
+ const discount_amount = convertMinifiedPlatformNumToOriginalPlatformNum(special.discount_amount);
54
+ const item_special_hours = convertMinifiedSpecialHoursToOriginalSpecialHours(special.item_special_hours);
55
+ const display_price = special.display_price ?? undefined;
56
+ return {
57
+ sold_out: special.sold_out,
58
+ is_discount_percentage: special.is_discount_percentage,
59
+ show_starting_from: special.show_starting_from,
60
+ display_price,
61
+ price,
62
+ discount_amount,
63
+ item_special_hours,
64
+ // No tax on the special payload (mirrors convertSpecialToItem); no
65
+ // selection structure on the simplified payload.
66
+ tax_rate: null,
67
+ modifiers: null,
68
+ sort_id: special.sort_id,
69
+ hide_name: false,
70
+ is_featured: false,
71
+ featured_sort_id: 0,
72
+ _id: special._id,
73
+ category_id: special.category_id,
74
+ name: special.name,
75
+ included_platforms: special.included_platforms,
76
+ description: special.description,
77
+ active: special.active,
78
+ image_url: special.image_url,
79
+ };
80
+ }
81
+ /**
82
+ * Converts an ISimplifiedSpecial's minified money fields (and those nested in
83
+ * `item_special_hours`) between the cents (server) domain and the dollar/UI
84
+ * domain while preserving the simplified payload shape. Mirrors
85
+ * `getSpecialWithPrice` for the full ISpecial:
86
+ * - `price` / `discount_amount` (IMinifiedPrice) are scaled (a scalar stays a
87
+ * scalar),
88
+ * - `display_price` (scalar) is scaled,
89
+ * - `item_special_hours` prices are scaled in place.
90
+ *
91
+ * Only present fields are rewritten; absent fields stay absent (the payload
92
+ * carries no modifier_specials to convert).
93
+ */
94
+ export function getSimplifiedSpecialWithPrice(special, writeable) {
95
+ const convertToPrice = writeable ? convertMinifiedPriceToCents : convertMinifiedPriceFromCents;
96
+ const convertItemSpecialHours = writeable ? convertMinifiedSpecialHoursToCents : convertMinifiedSpecialHoursFromCents;
97
+ const convertNumPrice = writeable ? convertPriceToCents : convertPriceFromCents;
98
+ return {
99
+ ...special,
100
+ ...(special.price != null ? { price: convertToPrice(special.price) } : {}),
101
+ ...(special.discount_amount != null ? { discount_amount: convertToPrice(special.discount_amount) } : {}),
102
+ ...(special.display_price != null ? { display_price: convertNumPrice(special.display_price) } : {}),
103
+ ...(special.item_special_hours != null
104
+ ? { item_special_hours: convertItemSpecialHours(special.item_special_hours) }
105
+ : {}),
106
+ };
107
+ }