@managesome/eposmatic-toolkit 0.3.7 → 0.3.9

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 (439) 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/utils/order-engine.js +6 -1
  437. package/lib/tests/soldout-option-default-guard.test.d.ts +1 -0
  438. package/lib/tests/soldout-option-default-guard.test.js +126 -0
  439. package/package.json +6 -3
@@ -0,0 +1,43 @@
1
+ // =========================>>><<<=========================
2
+ import { DEFAULT_ORDER_STATUS_BY_ORDER_TYPE, ORDER_STATUS_ENUM, ORDER_TYPE_ENUM, } from '../../constants';
3
+ const SORTED_ORDER_STATUS_BY_ORDER_TYPE = Object.values(ORDER_TYPE_ENUM).reduce((acc, orderType) => {
4
+ return {
5
+ ...acc,
6
+ [orderType]: [...DEFAULT_ORDER_STATUS_BY_ORDER_TYPE[orderType]].sort((a, b) => a.priority - b.priority),
7
+ };
8
+ }, {});
9
+ export function getOrderStatusInfo(platform, currentStatus) {
10
+ const info = {
11
+ orderProgress: 0,
12
+ nextOrderStatus: null,
13
+ currentOrderStatus: null,
14
+ };
15
+ const order_type = platform.split('_')[1];
16
+ const currentOrderTypeStatuses = SORTED_ORDER_STATUS_BY_ORDER_TYPE[order_type];
17
+ if (!currentOrderTypeStatuses) {
18
+ return info;
19
+ }
20
+ let currentStatusIndex;
21
+ for (let i = 0; i < currentOrderTypeStatuses.length; i++) {
22
+ const obj = currentOrderTypeStatuses[i];
23
+ if (obj.status === currentStatus) {
24
+ info.currentOrderStatus = obj;
25
+ currentStatusIndex = i;
26
+ if (info.currentOrderStatus.status !== ORDER_STATUS_ENUM.CANCELLED) {
27
+ // Total is -2 because we don't want to count unconfrimed and cancelled
28
+ const total = currentOrderTypeStatuses.length - 2;
29
+ info.orderProgress = Math.round((obj.priority / total) * 100);
30
+ }
31
+ break;
32
+ }
33
+ }
34
+ if (currentStatusIndex == null) {
35
+ return info;
36
+ }
37
+ const nextObj = currentOrderTypeStatuses[currentStatusIndex + 1];
38
+ if (!nextObj || nextObj.status === ORDER_STATUS_ENUM.CANCELLED) {
39
+ return info;
40
+ }
41
+ info.nextOrderStatus = nextObj;
42
+ return info;
43
+ }
@@ -0,0 +1,13 @@
1
+ function deg2rad(deg) {
2
+ return deg * (Math.PI / 180);
3
+ }
4
+ export function getDistanceFromLatLonInMeters(lat1, lon1, lat2, lon2) {
5
+ const earthRadius = 6371; // in km
6
+ const dLat = deg2rad(lat2 - lat1);
7
+ const dLon = deg2rad(lon2 - lon1);
8
+ const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
9
+ Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) * Math.sin(dLon / 2) * Math.sin(dLon / 2);
10
+ const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
11
+ const distance = earthRadius * c * 1000; // in meters
12
+ return distance;
13
+ }
@@ -0,0 +1,44 @@
1
+ import { findApplicableSchedule } from './platform-catalog';
2
+ export function getSelectedMenuCatalogs(menus, selectedMenuId, mappedCatalog) {
3
+ if (!selectedMenuId)
4
+ return [];
5
+ const menu = menus.find((menu) => menu._id === selectedMenuId);
6
+ if (!menu)
7
+ return [];
8
+ const catalogs = [];
9
+ for (let i = 0; i < menu.included_categories.length; i++) {
10
+ const menuCategory = menu.included_categories[i];
11
+ const catalog = mappedCatalog[menuCategory.category_id];
12
+ if (!catalog)
13
+ continue;
14
+ let items = [];
15
+ if (menuCategory.excluded_items.length === 0) {
16
+ items = catalog.items;
17
+ }
18
+ else {
19
+ items = catalog.items.filter((item) => !menuCategory.excluded_items.includes(item._id));
20
+ }
21
+ catalogs.push({
22
+ ...catalog,
23
+ items,
24
+ });
25
+ }
26
+ catalogs.sort((a, b) => a.sort_id - b.sort_id);
27
+ return catalogs;
28
+ }
29
+ export function getFilteredMenus(menus, platform) {
30
+ if (!platform)
31
+ return [];
32
+ const newMenus = [];
33
+ for (let i = 0; i < menus.length; i++) {
34
+ const menu = menus[i];
35
+ if (!menu.active || !menu.included_platforms.includes(platform))
36
+ continue;
37
+ const applicableSchedule = findApplicableSchedule(menu.menu_special_hours, platform);
38
+ // if there is no applicable schedule, we skip the menu
39
+ if (applicableSchedule === false)
40
+ continue;
41
+ newMenus.push(menu);
42
+ }
43
+ return newMenus;
44
+ }
@@ -0,0 +1,428 @@
1
+ import { CATEGORY_DISPLAY_TYPE_ENUM } from '../../constants';
2
+ // ========================================================>>>Convert Minified Catalog to Original Catalog<<<========================================================
3
+ export function convertMinifiedPlatformNumToOriginalPlatformNum(priceObj) {
4
+ // step 1: we check if priceObj is either undefined, null or 0
5
+ if (!priceObj)
6
+ return null;
7
+ // step 2: we check if priceObj is a number
8
+ // if so then we return an object with all platforms set to that number
9
+ if (typeof priceObj === 'number') {
10
+ return {
11
+ BASE_PRICE: priceObj,
12
+ };
13
+ }
14
+ return priceObj;
15
+ }
16
+ export function convertMinifiedSpecialHoursToOriginalSpecialHours(specialHours) {
17
+ if (!specialHours || specialHours.length === 0)
18
+ return null;
19
+ const originalSpecialHour = specialHours.map((specialHour) => {
20
+ const {
21
+ // Optional properties
22
+ disabled_outside_date_range = false, start_date = null, end_date = null, excluded_platforms = [], is_discount_percentage = false,
23
+ // Changed properties
24
+ // price,
25
+ // discount_amount,
26
+ // required properties
27
+ days_index, start_time, end_time, } = specialHour;
28
+ const price = convertMinifiedPlatformNumToOriginalPlatformNum(specialHour.price);
29
+ const discount_amount = convertMinifiedPlatformNumToOriginalPlatformNum(specialHour.discount_amount);
30
+ return {
31
+ days_index,
32
+ disabled_outside_date_range,
33
+ start_time,
34
+ end_time,
35
+ start_date,
36
+ end_date,
37
+ price,
38
+ discount_amount,
39
+ is_discount_percentage,
40
+ excluded_platforms,
41
+ };
42
+ });
43
+ return originalSpecialHour;
44
+ }
45
+ export function convertMinifiedModifierOptionsToOriginalModifierOptions(options, tenantId) {
46
+ if (!options || options.length === 0)
47
+ return [];
48
+ const originalOptions = options.map((option) => {
49
+ const {
50
+ // optional properties
51
+ // default,
52
+ ingredients, excluded_platforms = [],
53
+ // changed properties
54
+ // sold_out,
55
+ // price,
56
+ // item_modifier_option_special_hours,
57
+ // modifiers,
58
+ // required properties
59
+ _id, ref, name, active, sort_id, } = option;
60
+ const price = convertMinifiedPlatformNumToOriginalPlatformNum(option.price);
61
+ const item_modifier_option_special_hours = convertMinifiedSpecialHoursToOriginalSpecialHours(option.item_modifier_option_special_hours);
62
+ const modifiers = convertMinifiedModifersToOriginalModifiers(option.modifiers, tenantId);
63
+ const sold_out = option.sold_out === true ? [tenantId] : [];
64
+ return {
65
+ // optional properties
66
+ sold_out,
67
+ excluded_platforms,
68
+ // missing properties
69
+ default: option.default,
70
+ price,
71
+ modifiers,
72
+ ingredients,
73
+ item_modifier_option_special_hours,
74
+ ref_type: option.ref_type,
75
+ choose_expensive_segment_price: option.choose_expensive_segment_price,
76
+ // required properties
77
+ _id,
78
+ ref,
79
+ name,
80
+ active,
81
+ sort_id,
82
+ };
83
+ });
84
+ return originalOptions;
85
+ }
86
+ export function convertMinifiedModifersToOriginalModifiers(modifiers, tenantId) {
87
+ if (!modifiers || modifiers.length === 0)
88
+ return null;
89
+ const originalModifiers = modifiers.map((modifier) => {
90
+ const {
91
+ // Optional properties
92
+ min_num_options, max_num_options, min_option_choice_quantity, max_option_choice_quantity, min_aggregate_options_quantity, max_aggregate_options_quantity, num_free_options, exempt_discount, minimized,
93
+ // changed properties
94
+ // sold_out,
95
+ // options,
96
+ // Required properties
97
+ _id, ref, name, description, active, sort_id, } = modifier;
98
+ const options = convertMinifiedModifierOptionsToOriginalModifierOptions(modifier.options, tenantId);
99
+ const sold_out = modifier.sold_out === true ? [tenantId] : [];
100
+ return {
101
+ _id,
102
+ ref,
103
+ name,
104
+ description,
105
+ active,
106
+ sold_out,
107
+ sort_id,
108
+ min_num_options,
109
+ max_num_options,
110
+ min_option_choice_quantity,
111
+ max_option_choice_quantity,
112
+ min_aggregate_options_quantity,
113
+ max_aggregate_options_quantity,
114
+ num_free_options,
115
+ exempt_discount,
116
+ minimized,
117
+ options,
118
+ };
119
+ });
120
+ return originalModifiers;
121
+ }
122
+ export function convertMinifiedCategoryToOriginalCategory(category) {
123
+ const {
124
+ // Optional properties
125
+ brand_id = 'xxx', tenants = [], createdAt = new Date(), updatedAt = new Date(),
126
+ // Required properties
127
+ _id, image_url, name, subtitle, active, sort_id, display_type, } = category;
128
+ return {
129
+ // Optional properties
130
+ brand_id,
131
+ tenants,
132
+ createdAt,
133
+ updatedAt,
134
+ // // Required properties
135
+ _id,
136
+ image_url,
137
+ name,
138
+ subtitle,
139
+ active,
140
+ sort_id,
141
+ display_type,
142
+ };
143
+ }
144
+ export function convertMinifiedItemToOriginalItem(item, tenantId) {
145
+ const {
146
+ // Optional properties
147
+ brand_id = 'xxx', tenants = [], ingredients = null, createdAt = new Date(), updatedAt = new Date(), hide_name = false, caveats = [], dietary_preferences = [], is_featured = false, featured_sort_id = 0, display_price = null, show_starting_from = false, keywords = [], is_discount_percentage = false,
148
+ // Changed properties
149
+ // sold_out,
150
+ // price,
151
+ // discount_amount,
152
+ // tax_rate,
153
+ // item_special_hours,
154
+ // modifiers,
155
+ // Required properties
156
+ _id, category_id, name, included_platforms, description, active, sort_id, image_url, } = item;
157
+ const price = convertMinifiedPlatformNumToOriginalPlatformNum(item.price);
158
+ const discount_amount = convertMinifiedPlatformNumToOriginalPlatformNum(item.discount_amount);
159
+ const tax_rate = convertMinifiedPlatformNumToOriginalPlatformNum(item.tax_rate);
160
+ const item_special_hours = convertMinifiedSpecialHoursToOriginalSpecialHours(item.item_special_hours);
161
+ const modifiers = convertMinifiedModifersToOriginalModifiers(item.modifiers, tenantId);
162
+ const sold_out = item.sold_out === true ? [tenantId] : [];
163
+ return {
164
+ // Optional properties
165
+ hide_name,
166
+ sold_out,
167
+ caveats,
168
+ dietary_preferences,
169
+ keywords,
170
+ is_featured,
171
+ featured_sort_id,
172
+ display_price,
173
+ show_starting_from,
174
+ is_discount_percentage,
175
+ // changed properties
176
+ price,
177
+ discount_amount,
178
+ tax_rate,
179
+ item_special_hours,
180
+ modifiers,
181
+ // Required properties
182
+ _id,
183
+ brand_id,
184
+ tenants,
185
+ category_id,
186
+ included_platforms,
187
+ name,
188
+ description,
189
+ active,
190
+ sort_id,
191
+ image_url,
192
+ ingredients,
193
+ createdAt,
194
+ updatedAt,
195
+ };
196
+ }
197
+ // ========================================================>>>Convert Original Catalog to Minified Catalog<<<========================================================
198
+ export function convertOriginalPlatformNumToMinifiedPlatformNum(priceObj) {
199
+ // step 1: if num is null, return undefined
200
+ if (!priceObj)
201
+ return undefined;
202
+ // step 2: check if all the platform values are the same
203
+ // if they are, return the value as a number
204
+ if (Object.values(priceObj).every((value) => value === priceObj.BASE_PRICE)) {
205
+ // if the num is 0, return undefined
206
+ return priceObj.BASE_PRICE || undefined;
207
+ }
208
+ const newPriceObj = {};
209
+ for (const key in priceObj) {
210
+ const typedKey = key;
211
+ if (typedKey !== 'BASE_PRICE' && priceObj[typedKey] === priceObj.BASE_PRICE) {
212
+ continue;
213
+ }
214
+ newPriceObj[typedKey] = priceObj[typedKey];
215
+ }
216
+ // step 7: if we reach this point, we send back the original priceObj
217
+ return priceObj;
218
+ }
219
+ export function convertOriginalSpecialHoursToMinifiedSpecialHours(specialHours) {
220
+ if (!specialHours || specialHours.length === 0)
221
+ return undefined;
222
+ const minifiedSpecialHours = [];
223
+ const specialHoursLength = specialHours.length;
224
+ for (let i = 0; i < specialHoursLength; i++) {
225
+ const specialHour = specialHours[i];
226
+ const price = convertOriginalPlatformNumToMinifiedPlatformNum(specialHour.price);
227
+ const discount_amount = convertOriginalPlatformNumToMinifiedPlatformNum(specialHour.discount_amount);
228
+ minifiedSpecialHours.push({
229
+ // optional properties
230
+ disabled_outside_date_range: specialHour.disabled_outside_date_range || undefined,
231
+ start_date: specialHour.start_date || undefined,
232
+ end_date: specialHour.end_date || undefined,
233
+ is_discount_percentage: specialHour.is_discount_percentage || undefined,
234
+ excluded_platforms: specialHour.excluded_platforms.length > 0 ? specialHour.excluded_platforms : undefined,
235
+ // changed properties
236
+ price,
237
+ discount_amount,
238
+ // required properties
239
+ days_index: specialHour.days_index,
240
+ start_time: specialHour.start_time,
241
+ end_time: specialHour.end_time,
242
+ });
243
+ }
244
+ return minifiedSpecialHours;
245
+ }
246
+ export function convertOriginalModifierOptionsToMinifiedModifierOptions(options, tenantId) {
247
+ if (!options || options.length === 0)
248
+ return [];
249
+ const minifiedOptions = [];
250
+ const optionsLength = options.length;
251
+ for (let i = 0; i < optionsLength; i++) {
252
+ const option = options[i];
253
+ const price = convertOriginalPlatformNumToMinifiedPlatformNum(option.price);
254
+ const item_modifier_option_special_hours = convertOriginalSpecialHoursToMinifiedSpecialHours(option.item_modifier_option_special_hours);
255
+ const modifiers = convertOriginalModifiersToMinifiedModifiers(option.modifiers, tenantId);
256
+ minifiedOptions.push({
257
+ // optional properties
258
+ // ingredients,
259
+ sold_out: option.sold_out.includes(tenantId) || undefined,
260
+ default: option.default || undefined,
261
+ excluded_platforms: option.excluded_platforms.length > 0 ? option.excluded_platforms : undefined,
262
+ // changed properties
263
+ price,
264
+ item_modifier_option_special_hours,
265
+ modifiers,
266
+ ref_type: option.ref_type,
267
+ choose_expensive_segment_price: option.choose_expensive_segment_price,
268
+ // required properties
269
+ _id: option._id,
270
+ ref: option.ref,
271
+ name: option.name,
272
+ active: option.active,
273
+ sort_id: option.sort_id,
274
+ });
275
+ }
276
+ return minifiedOptions;
277
+ }
278
+ export function convertOriginalModifiersToMinifiedModifiers(modifiers, tenantId) {
279
+ if (!modifiers || modifiers.length === 0)
280
+ return undefined;
281
+ const minifiedModifiers = modifiers.map((modifier) => {
282
+ const options = convertOriginalModifierOptionsToMinifiedModifierOptions(modifier.options, tenantId);
283
+ return {
284
+ // optional properties
285
+ sold_out: modifier.sold_out.includes(tenantId) || undefined,
286
+ min_num_options: modifier.min_num_options || undefined,
287
+ max_num_options: modifier.max_num_options || undefined,
288
+ min_option_choice_quantity: modifier.min_option_choice_quantity || undefined,
289
+ max_option_choice_quantity: modifier.max_option_choice_quantity || undefined,
290
+ min_aggregate_options_quantity: modifier.min_aggregate_options_quantity || undefined,
291
+ max_aggregate_options_quantity: modifier.max_aggregate_options_quantity || undefined,
292
+ num_free_options: modifier.num_free_options || undefined,
293
+ exempt_discount: modifier.exempt_discount || undefined,
294
+ minimized: modifier.minimized || undefined,
295
+ // changed properties
296
+ options,
297
+ // required properties
298
+ _id: modifier._id,
299
+ ref: modifier.ref,
300
+ name: modifier.name,
301
+ description: modifier.description,
302
+ active: modifier.active,
303
+ sort_id: modifier.sort_id,
304
+ };
305
+ });
306
+ return minifiedModifiers;
307
+ }
308
+ export function convertOriginalCategoryToMinifiedCategory(category) {
309
+ const newCategory = {
310
+ _id: category._id,
311
+ image_url: category.image_url,
312
+ name: category.name,
313
+ subtitle: category.subtitle,
314
+ active: category.active,
315
+ sort_id: category.sort_id,
316
+ display_type: category.display_type,
317
+ };
318
+ return newCategory;
319
+ }
320
+ export function convertPartialOriginalCategoryToPartialMinifiedCategory(partialCategory) {
321
+ const category = {
322
+ _id: partialCategory._id ?? '',
323
+ brand_id: partialCategory.brand_id ?? 'xxx',
324
+ tenants: partialCategory.tenants ?? [],
325
+ image_url: partialCategory.image_url ?? '',
326
+ name: partialCategory.name ?? '',
327
+ subtitle: partialCategory.subtitle ?? '',
328
+ active: partialCategory.active ?? false,
329
+ sort_id: partialCategory.sort_id ?? 0,
330
+ display_type: partialCategory.display_type ?? CATEGORY_DISPLAY_TYPE_ENUM.REGULAR,
331
+ createdAt: partialCategory.createdAt ?? new Date(),
332
+ updatedAt: partialCategory.updatedAt ?? new Date(),
333
+ };
334
+ const minifiedCategory = convertOriginalCategoryToMinifiedCategory(category);
335
+ const partialMinifiedCategory = {};
336
+ for (const key in minifiedCategory) {
337
+ const typedKey = key;
338
+ if (partialCategory[typedKey] === undefined) {
339
+ continue;
340
+ }
341
+ partialMinifiedCategory[typedKey] = minifiedCategory[typedKey];
342
+ }
343
+ return partialMinifiedCategory;
344
+ }
345
+ export function convertOriginalItemToMinifiedItem(item, tenantId) {
346
+ const price = convertOriginalPlatformNumToMinifiedPlatformNum(item.price);
347
+ const discount_amount = convertOriginalPlatformNumToMinifiedPlatformNum(item.discount_amount);
348
+ const tax_rate = convertOriginalPlatformNumToMinifiedPlatformNum(item.tax_rate);
349
+ const item_special_hours = convertOriginalSpecialHoursToMinifiedSpecialHours(item.item_special_hours);
350
+ const modifiers = convertOriginalModifiersToMinifiedModifiers(item.modifiers, tenantId);
351
+ const newItem = {
352
+ // removed properties
353
+ // brand_id
354
+ // ingredients
355
+ // createdAt
356
+ // updatedAt
357
+ tenants: item.tenants,
358
+ // optional properties
359
+ hide_name: item.hide_name || undefined,
360
+ sold_out: item.sold_out.includes(tenantId) || undefined,
361
+ caveats: item.caveats.length > 0 ? item.caveats : undefined,
362
+ dietary_preferences: item.dietary_preferences.length > 0 ? item.dietary_preferences : undefined,
363
+ is_featured: item.is_featured || undefined,
364
+ featured_sort_id: item.is_featured ? item.featured_sort_id : undefined,
365
+ display_price: item.display_price ?? undefined,
366
+ show_starting_from: item.show_starting_from || undefined,
367
+ keywords: item.keywords.length > 0 ? item.keywords : undefined,
368
+ is_discount_percentage: item.is_discount_percentage || undefined,
369
+ // changed properties
370
+ price,
371
+ discount_amount,
372
+ tax_rate,
373
+ item_special_hours,
374
+ modifiers,
375
+ // required properties
376
+ _id: item._id,
377
+ category_id: item.category_id,
378
+ name: item.name,
379
+ included_platforms: item.included_platforms,
380
+ description: item.description,
381
+ active: item.active,
382
+ sort_id: item.sort_id,
383
+ image_url: item.image_url,
384
+ };
385
+ return newItem;
386
+ }
387
+ export function convertPartialOriginalItemToPartialMinifiedItem(partialItem, tenantId) {
388
+ const item = {
389
+ _id: partialItem._id ?? '',
390
+ brand_id: partialItem.brand_id ?? 'xxx',
391
+ tenants: partialItem.tenants ?? [],
392
+ category_id: partialItem.category_id ?? '',
393
+ name: partialItem.name ?? '',
394
+ included_platforms: partialItem.included_platforms ?? [],
395
+ description: partialItem.description ?? '',
396
+ active: partialItem.active ?? false,
397
+ sort_id: partialItem.sort_id ?? 0,
398
+ image_url: partialItem.image_url ?? '',
399
+ price: partialItem.price ?? null,
400
+ discount_amount: partialItem.discount_amount ?? null,
401
+ tax_rate: partialItem.tax_rate ?? null,
402
+ item_special_hours: partialItem.item_special_hours ?? null,
403
+ modifiers: partialItem.modifiers ?? null,
404
+ sold_out: partialItem.sold_out ?? [],
405
+ hide_name: partialItem.hide_name ?? false,
406
+ caveats: partialItem.caveats ?? [],
407
+ dietary_preferences: partialItem.dietary_preferences ?? [],
408
+ is_featured: partialItem.is_featured ?? false,
409
+ featured_sort_id: partialItem.featured_sort_id ?? 0,
410
+ display_price: partialItem.display_price ?? null,
411
+ show_starting_from: partialItem.show_starting_from ?? false,
412
+ keywords: partialItem.keywords ?? [],
413
+ is_discount_percentage: partialItem.is_discount_percentage ?? false,
414
+ createdAt: partialItem.createdAt ?? new Date(),
415
+ updatedAt: partialItem.updatedAt ?? new Date(),
416
+ ingredients: partialItem.ingredients ?? null,
417
+ };
418
+ const minifiedItem = convertOriginalItemToMinifiedItem(item, tenantId);
419
+ const partialMinifiedItem = {};
420
+ for (const key in minifiedItem) {
421
+ const typedKey = key;
422
+ if (partialItem[typedKey] === undefined) {
423
+ continue;
424
+ }
425
+ partialMinifiedItem[typedKey] = minifiedItem[typedKey];
426
+ }
427
+ return partialMinifiedItem;
428
+ }