@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,201 @@
1
+ import { ALL_DAY_INDEX } from '../../constants';
2
+ import { addDaysToLocalDate, formatLocalDateFromMidnight, getFirstShiftStartPosition, getLastShiftEndPosition, getLocalDateMidnightMs, getScheduledShiftsForDay, getShiftEndPosition, getShiftStartPosition, getTenantFramePosition, MS_IN_DAY, } from './shift-window-helpers';
3
+ /**
4
+ * Business-day resolution from shift windows — the "which day is the
5
+ * restaurant on?" logic shared by the backend day-open flow and the POS
6
+ * frontends (day label, staleness gating, week boards). All functions are
7
+ * pure; persistence (day sessions, running-day pointer) stays with callers.
8
+ *
9
+ * TWO complementary notions live here:
10
+ * - `resolveBusinessLocalDate` — the date a DAY STARTING NOW belongs to. Used
11
+ * by the backend `openTenantDay`: inside a running shift window it belongs to
12
+ * that window's start date (a store still inside Sunday's 9:00 AM – 2:00 AM
13
+ * window at Monday 12:30 AM opens SUNDAY); in closed hours the new day
14
+ * starts on the tenant's current calendar date.
15
+ * - `getCurrentBusinessDay` — the day the restaurant is CURRENTLY operating /
16
+ * most recently operated, per the POS label model: today once its first
17
+ * ACTIVE shift has started, otherwise the most recent scheduled day.
18
+ */
19
+ /** The default operational start (06:00, minutes from midnight) for legacy non-shift stores. */
20
+ export const DEFAULT_OPERATIONAL_START_TIME = 6 * 60;
21
+ /**
22
+ * Resolves the BUSINESS DATE a moment belongs to, per the tenant's scheduled
23
+ * shift windows — "the restaurant's day", not the raw calendar date.
24
+ *
25
+ * - The moment falls INSIDE a scheduled shift window (overnight windows rolled
26
+ * past midnight) → the date of the day that window STARTED on. A store still
27
+ * inside Sunday's 9:00 AM – 2:00 AM window at Monday 12:30 AM is trading
28
+ * SUNDAY, so a day opened then must be stamped Sunday.
29
+ * - The moment falls in CLOSED hours (e.g. the 2:00 AM – 9:00 AM gap) → the
30
+ * tenant's current calendar date (a new day opened now starts on that date).
31
+ *
32
+ * Only `today`, `yesterday` and the day before are scanned: a shift range is
33
+ * capped at `end_time <= 2 * MS_IN_DAY` (the admin validator's bound), so a
34
+ * window that started earlier than that can never cover the moment. No active
35
+ * shifts at all → calendar date (legacy behavior).
36
+ */
37
+ export function resolveBusinessLocalDate(shifts, gmtOffset, now = new Date()) {
38
+ const frame = getTenantFramePosition(gmtOffset, now);
39
+ // Most recent first: today, yesterday, then the day before (a maximally long
40
+ // 48h window covers into the day after its start).
41
+ for (let i = 0; i <= 2; i++) {
42
+ const dayMidnightMs = frame.dayMidnightMs - i * MS_IN_DAY;
43
+ const dayIndex = ALL_DAY_INDEX[new Date(dayMidnightMs).getUTCDay()];
44
+ for (const shift of getScheduledShiftsForDay(shifts, dayIndex)) {
45
+ const startPosition = getShiftStartPosition(dayMidnightMs, shift);
46
+ const endPosition = getShiftEndPosition(dayMidnightMs, shift);
47
+ if (frame.nowPos >= startPosition && frame.nowPos <= endPosition) {
48
+ return formatLocalDateFromMidnight(dayMidnightMs);
49
+ }
50
+ }
51
+ }
52
+ // Closed hours — the upcoming day is the tenant's current calendar date.
53
+ return formatLocalDateFromMidnight(frame.dayMidnightMs);
54
+ }
55
+ /**
56
+ * The restaurant's CURRENT business day: today once its first ACTIVE shift has
57
+ * started; otherwise the most recent scheduled day — walking back up to a week
58
+ * and skipping off-days. Before a day's first shift (overnight tail / pre-open
59
+ * gap) the previous business day still applies; on off-days the previous
60
+ * business day applies while its own last shift window runs (an overnight
61
+ * window can cross into a day with no shifts).
62
+ *
63
+ * `null` when the tenant has no active templates (legacy stores).
64
+ */
65
+ export function getCurrentBusinessDay(shifts, gmtOffset, now = new Date()) {
66
+ if (!shifts.some((shift) => shift.active === true))
67
+ return null;
68
+ const frame = getTenantFramePosition(gmtOffset, now);
69
+ // Today first (once its first shift has started), else the most recent
70
+ // scheduled day — search back up to a week.
71
+ for (let i = 0; i <= 7; i++) {
72
+ const dayMidnightMs = frame.dayMidnightMs - i * MS_IN_DAY;
73
+ const dayIndex = ALL_DAY_INDEX[new Date(dayMidnightMs).getUTCDay()];
74
+ const firstShiftStartPosition = getFirstShiftStartPosition(shifts, dayMidnightMs, dayIndex);
75
+ if (firstShiftStartPosition == null)
76
+ continue;
77
+ if (i === 0 && frame.timeMs < firstShiftStartPosition - dayMidnightMs)
78
+ continue;
79
+ const lastShiftEndPosition = getLastShiftEndPosition(shifts, dayMidnightMs, dayIndex);
80
+ if (lastShiftEndPosition == null)
81
+ continue;
82
+ return {
83
+ localDate: formatLocalDateFromMidnight(dayMidnightMs),
84
+ dayMidnightMs,
85
+ firstShiftStartPosition,
86
+ lastShiftEndPosition,
87
+ };
88
+ }
89
+ return null;
90
+ }
91
+ /**
92
+ * Weekday (`DAY_INDEX_ENUM`) of the restaurant's current business day — what
93
+ * week boards should treat as "today" (e.g. 1:16 AM on Monday is still Sunday
94
+ * while the Sunday Mid-Night shift runs). `null` when no schedule exists;
95
+ * callers fall back to the POS-local calendar weekday.
96
+ */
97
+ export function getCurrentBusinessDayIndex(shifts, gmtOffset, now = new Date()) {
98
+ const currentDay = getCurrentBusinessDay(shifts, gmtOffset, now);
99
+ if (currentDay == null)
100
+ return null;
101
+ return ALL_DAY_INDEX[new Date(currentDay.dayMidnightMs).getUTCDay()];
102
+ }
103
+ /**
104
+ * True once the day AFTER `dayLocalDate` has effectively begun — the first
105
+ * ACTIVE shift scheduled for that weekday has started. This is the overnight
106
+ * grace: between midnight and the next business day's first shift the previous
107
+ * business day is still legitimately running.
108
+ *
109
+ * When the next calendar day is NOT a business day (nothing scheduled — e.g. a
110
+ * Friday night shift running into an off Saturday), there is no next-day shift
111
+ * to wait for, so the running day is judged by its OWN last shift window: it
112
+ * counts as finished once that window has ended, never at midnight while the
113
+ * shift still runs. No active templates at all → `true` (nothing to wait for).
114
+ */
115
+ export function hasNextDayFirstShiftStarted(shifts, dayLocalDate, gmtOffset, now = new Date()) {
116
+ if (!shifts.some((shift) => shift.active === true))
117
+ return true;
118
+ const frame = getTenantFramePosition(gmtOffset, now);
119
+ const dayMidnightMs = getLocalDateMidnightMs(dayLocalDate);
120
+ const nextDayMidnightMs = dayMidnightMs + MS_IN_DAY;
121
+ const nextDayIndex = ALL_DAY_INDEX[new Date(nextDayMidnightMs).getUTCDay()];
122
+ const firstNextStartPosition = getFirstShiftStartPosition(shifts, nextDayMidnightMs, nextDayIndex);
123
+ if (firstNextStartPosition == null) {
124
+ const dayIndex = ALL_DAY_INDEX[new Date(dayMidnightMs).getUTCDay()];
125
+ const lastEndPosition = getLastShiftEndPosition(shifts, dayMidnightMs, dayIndex);
126
+ if (lastEndPosition == null)
127
+ return true;
128
+ return frame.nowPos >= lastEndPosition;
129
+ }
130
+ return frame.nowPos >= firstNextStartPosition;
131
+ }
132
+ /**
133
+ * Counts how many successive business-day entries have happened since
134
+ * `dayLocalDate` — a "new day" counts only once it has effectively begun (its
135
+ * first ACTIVE shift has started), never at calendar midnight. Walks day by
136
+ * day through `hasNextDayFirstShiftStarted` and stops at the first boundary
137
+ * that has not been reached, so the count stays 0 while the running day is
138
+ * still legitimate (e.g. through an overnight tail), is 1 once the next
139
+ * business day has entered, 2 once the day after that has too — and so on.
140
+ * `maxDays` bounds the walk.
141
+ */
142
+ export function getBusinessDaysBehind(shifts, dayLocalDate, gmtOffset, maxDays = 31, now = new Date()) {
143
+ let cursor = dayLocalDate;
144
+ let behind = 0;
145
+ for (let i = 0; i < maxDays; i++) {
146
+ if (!hasNextDayFirstShiftStarted(shifts, cursor, gmtOffset, now))
147
+ break;
148
+ behind++;
149
+ cursor = addDaysToLocalDate(cursor, 1);
150
+ }
151
+ return behind;
152
+ }
153
+ /**
154
+ * The restaurant-day label (`YYYY-MM-DD`, POS-local) for a moment — the day
155
+ * the tenant is actually on, never the raw calendar day.
156
+ *
157
+ * Restaurants come in two shapes and each has exactly ONE operational-hours
158
+ * source of truth (gated by `isShiftMode`):
159
+ * - Shift-enabled stores: the shifts ONLY — the day begins at TODAY's first
160
+ * ACTIVE shift start; before it (overnight tail / pre-open gap) the previous
161
+ * business day still applies, and on off-days the previous business day
162
+ * applies while its own last shift window runs.
163
+ * - Legacy stores: the day rolls at `operationalStartTime` (never at calendar
164
+ * midnight).
165
+ */
166
+ export function getRestaurantDayLabel(shifts, options, now = new Date()) {
167
+ const frame = getTenantFramePosition(options.gmtOffset, now);
168
+ const todayMidnightMs = frame.dayMidnightMs;
169
+ const isShiftMode = options.isShiftMode ?? shifts.some((shift) => shift.active === true);
170
+ if (isShiftMode) {
171
+ const todayIndex = ALL_DAY_INDEX[new Date(todayMidnightMs).getUTCDay()];
172
+ const firstTodayStartPosition = getFirstShiftStartPosition(shifts, todayMidnightMs, todayIndex);
173
+ if (firstTodayStartPosition != null) {
174
+ // Before today's first shift we are still on the previous business day
175
+ // (overnight tail / pre-open gap); from its start it is today.
176
+ return frame.nowPos >= firstTodayStartPosition
177
+ ? formatLocalDateFromMidnight(todayMidnightMs)
178
+ : formatLocalDateFromMidnight(todayMidnightMs - MS_IN_DAY);
179
+ }
180
+ // Off-day: still the previous business day while ITS OWN last shift window
181
+ // is running (e.g. a Friday-night window crossing into an off Saturday).
182
+ for (let i = 1; i <= 7; i++) {
183
+ const dayMidnightMs = todayMidnightMs - i * MS_IN_DAY;
184
+ const dayIndex = ALL_DAY_INDEX[new Date(dayMidnightMs).getUTCDay()];
185
+ const lastEndPosition = getLastShiftEndPosition(shifts, dayMidnightMs, dayIndex);
186
+ if (lastEndPosition == null)
187
+ continue;
188
+ return frame.nowPos >= lastEndPosition
189
+ ? formatLocalDateFromMidnight(todayMidnightMs)
190
+ : formatLocalDateFromMidnight(dayMidnightMs);
191
+ }
192
+ // No scheduled shifts in the last week → the day itself.
193
+ return formatLocalDateFromMidnight(todayMidnightMs);
194
+ }
195
+ // Legacy stores: roll at the tenant's configured operational start, never at
196
+ // calendar midnight.
197
+ const startTimeMs = (options.operationalStartTime ?? DEFAULT_OPERATIONAL_START_TIME) * 60 * 1000;
198
+ return frame.timeMs >= startTimeMs
199
+ ? formatLocalDateFromMidnight(todayMidnightMs)
200
+ : formatLocalDateFromMidnight(todayMidnightMs - MS_IN_DAY);
201
+ }
@@ -0,0 +1,156 @@
1
+ import { OFFER_REWARD_TYPE_ENUM, ORDER_TYPE_ENUM, PLATFORMS_BY_ORDER_TYPE, } from '../../constants';
2
+ import { calculateItemModifiersPrice } from '../store';
3
+ import { getPercentageAmount, parseNum } from './common';
4
+ export function calculateTotalAmountWithCharges({ bank_percentage_charges, bank_fixed_charges, provider_percentage_charges, provider_fixed_charges, target_amount_cents, }) {
5
+ const providerPercentage = provider_percentage_charges / 100;
6
+ const bankPercentage = bank_percentage_charges / 100;
7
+ const platform_charges =
8
+ // Add the fixed charges for the provider
9
+ provider_fixed_charges +
10
+ // Add the percentage charges for the provider
11
+ getPercentageAmount(target_amount_cents, providerPercentage);
12
+ const fixedCharges = bank_fixed_charges + platform_charges;
13
+ // =========== Bank Charges ===========
14
+ // EQ: x - (bankPercentage * x) - fixedCharges = targetAmountCents
15
+ // x - (bankPercentage * x) = targetAmountCents + fixedCharges
16
+ // x * (1 - bankPercentage) = targetAmountCents + fixedCharges
17
+ // x = (targetAmountCents + fixedCharges) / (1 - bankPercentage)
18
+ const denominator = 1 - bankPercentage || 1;
19
+ const total = (target_amount_cents + fixedCharges) / denominator;
20
+ const grand_total = Math.ceil(total);
21
+ // NOTE: Card Charges Include Both Bank Charges and Provider Charges
22
+ const card_charges = Math.ceil(grand_total - target_amount_cents);
23
+ const provider_charges = Math.ceil(platform_charges);
24
+ return {
25
+ grand_total,
26
+ card_charges,
27
+ provider_charges,
28
+ };
29
+ }
30
+ export function getDeliveryAmt({ platform, delivery_free_over, delivery_min_cost, contemporary_delivery_cost, payable_price, }) {
31
+ if (!PLATFORMS_BY_ORDER_TYPE[ORDER_TYPE_ENUM.DELIVERY].includes(platform))
32
+ return 0;
33
+ else if (delivery_free_over > 0 && payable_price > delivery_free_over) {
34
+ return 0;
35
+ }
36
+ else if (delivery_min_cost > 0) {
37
+ return delivery_min_cost;
38
+ }
39
+ return contemporary_delivery_cost;
40
+ }
41
+ export function getEditItemProps({ item, orderItemCategoryId, orderItem, offers, isLoyaltyDiscountApplied, isVoucherDiscountApplied, }) {
42
+ if (!item || !orderItemCategoryId || !orderItem?._id)
43
+ return;
44
+ let applyLoyalty;
45
+ let applyVoucher;
46
+ const excludeRefs = undefined;
47
+ let excludedDiscountRefs = undefined;
48
+ const zeroPriceRefs = undefined;
49
+ // Step 1: Check if loyalty discount or voucher discount is applied
50
+ if (isLoyaltyDiscountApplied) {
51
+ const offer = offers.find((o) => o._id === orderItem.item_discount_details?.loyalty_discount_id);
52
+ if (offer == null)
53
+ return;
54
+ // const rewardItems = offer?.reward_items;
55
+ let refs = [];
56
+ let offerExcludedDiscountRefs = [];
57
+ let applicable_quantity = 1;
58
+ if (offer.reward_type === OFFER_REWARD_TYPE_ENUM.ITEMS) {
59
+ if (offer.reward_items == null)
60
+ return;
61
+ refs = offer.reward_items.exclusive_refs.concat(item._id) ?? [];
62
+ offerExcludedDiscountRefs = offer.reward_items.excluded_refs;
63
+ applicable_quantity = offer.reward_items.num_of_items || 1;
64
+ }
65
+ else if (offer.reward_type === OFFER_REWARD_TYPE_ENUM.DISCOUNT_ITEMS) {
66
+ if (offer.reward_discount_items == null)
67
+ return;
68
+ refs = offer.reward_discount_items.exclusive_refs.concat(item._id) ?? [];
69
+ offerExcludedDiscountRefs = offer.reward_discount_items.excluded_refs;
70
+ applicable_quantity = offer.reward_discount_items.num_of_items || 1;
71
+ }
72
+ let discount_details = null;
73
+ if (offer.reward_type === OFFER_REWARD_TYPE_ENUM.DISCOUNT_ITEMS && offer.reward_discount_items != null) {
74
+ const discount_value = offer.reward_discount_items.discount_value;
75
+ const is_discount_percentage = offer.reward_discount_items.is_discount_percentage;
76
+ discount_details = {
77
+ discount_value,
78
+ is_discount_percentage,
79
+ };
80
+ }
81
+ applyLoyalty = {
82
+ loyalty_id: offer._id,
83
+ name: offer.name,
84
+ refs,
85
+ discount_details,
86
+ applicable_quantity,
87
+ };
88
+ excludedDiscountRefs = offerExcludedDiscountRefs;
89
+ }
90
+ if (isVoucherDiscountApplied) {
91
+ const offer = offers.find((o) => o._id === orderItem.item_discount_details?.voucher_discount_id);
92
+ if (offer == null)
93
+ return;
94
+ // const rewardItems = offer?.reward_items;
95
+ let refs = [];
96
+ let offerExcludedDiscountRefs = [];
97
+ let applicable_quantity = 1;
98
+ if (offer.reward_type === OFFER_REWARD_TYPE_ENUM.ITEMS) {
99
+ if (offer.reward_items == null)
100
+ return;
101
+ refs = offer.reward_items.exclusive_refs.concat(item._id) ?? [];
102
+ offerExcludedDiscountRefs = offer.reward_items.excluded_refs;
103
+ applicable_quantity = offer.reward_items.num_of_items || 1;
104
+ }
105
+ else if (offer.reward_type === OFFER_REWARD_TYPE_ENUM.DISCOUNT_ITEMS) {
106
+ if (offer.reward_discount_items == null)
107
+ return;
108
+ refs = offer.reward_discount_items.exclusive_refs.concat(item._id) ?? [];
109
+ offerExcludedDiscountRefs = offer.reward_discount_items.excluded_refs;
110
+ applicable_quantity = offer.reward_discount_items.num_of_items || 1;
111
+ }
112
+ let discount_details = null;
113
+ if (offer.reward_type === OFFER_REWARD_TYPE_ENUM.DISCOUNT_ITEMS && offer.reward_discount_items != null) {
114
+ const discount_value = offer.reward_discount_items.discount_value;
115
+ const is_discount_percentage = offer.reward_discount_items.is_discount_percentage;
116
+ discount_details = {
117
+ discount_value,
118
+ is_discount_percentage,
119
+ };
120
+ }
121
+ applyVoucher = {
122
+ voucher_id: offer._id,
123
+ name: offer.name,
124
+ refs,
125
+ discount_details,
126
+ applicable_quantity,
127
+ };
128
+ excludedDiscountRefs = offerExcludedDiscountRefs;
129
+ }
130
+ // TODO: We need to add use case for HalfHalf and Specials
131
+ const isRewardItem = isLoyaltyDiscountApplied || isVoucherDiscountApplied;
132
+ const props = {
133
+ catalogItem: item,
134
+ orderItemId: orderItem._id,
135
+ orderItemType: orderItem.item_type,
136
+ applyLoyalty,
137
+ applyVoucher,
138
+ excludeRefs,
139
+ excludedDiscountRefs,
140
+ zeroPriceRefs,
141
+ isRewardItem,
142
+ ...(isRewardItem && { maxQuantity: orderItem.quantity }),
143
+ };
144
+ return props;
145
+ }
146
+ // ==================================================== //
147
+ export function getOrderItemOriginalPrice(item) {
148
+ return parseNum(item.price + calculateItemModifiersPrice(item));
149
+ }
150
+ export function getOrderItemOriginalQuantityPrice(item) {
151
+ return parseNum((item.price + calculateItemModifiersPrice(item)) * item.quantity);
152
+ }
153
+ export function optionallyGetOrderItemOriginalQuantityPrice(item) {
154
+ const itemPrice = item.item_discount_details != null || item.tax_rate > 0 ? getOrderItemOriginalQuantityPrice(item) : null;
155
+ return itemPrice;
156
+ }
@@ -0,0 +1,129 @@
1
+ import { getIngredientsWithDecimal, getIngredientsWithInt } from './ingredients';
2
+ import { convertModifiersPriceToCents, convertPriceObjFromCents, convertPriceObjToCents, convertSpecialHoursFromCents, convertSpecialHoursToCents, } from './platform-num';
3
+ import { convertPriceFromCents, convertPriceToCents } from './price-conversion';
4
+ export function getModifierOptionMultiplier(multiplier, toCents) {
5
+ if (multiplier == null)
6
+ return undefined;
7
+ const converted = toCents ? convertPriceToCents(multiplier) : convertPriceFromCents(multiplier);
8
+ if (!converted || converted === 1)
9
+ return undefined;
10
+ return converted;
11
+ }
12
+ export function convertModifiersPriceFromCentsAndSort(modifiers, removeNonActive = false) {
13
+ if (!modifiers)
14
+ return null;
15
+ const filteredModifiers = removeNonActive ? modifiers.filter((modifier) => modifier.active) : modifiers;
16
+ const newModifiers = filteredModifiers
17
+ .map((modifier) => {
18
+ const modifierOptions = removeNonActive ? modifier.options.filter((option) => option.active) : modifier.options;
19
+ const options = modifierOptions
20
+ .map((option) => ({
21
+ ...option,
22
+ price: convertPriceObjFromCents(option.price),
23
+ multiplier: getModifierOptionMultiplier(option.multiplier),
24
+ modifiers: convertModifiersPriceFromCentsAndSort(option.modifiers, removeNonActive),
25
+ ingredients: getIngredientsWithDecimal(option.ingredients),
26
+ item_modifier_option_special_hours: convertSpecialHoursFromCents(option.item_modifier_option_special_hours),
27
+ }))
28
+ .sort((a, b) => a.sort_id - b.sort_id);
29
+ return {
30
+ ...modifier,
31
+ options,
32
+ };
33
+ })
34
+ .sort((a, b) => a.sort_id - b.sort_id);
35
+ return newModifiers;
36
+ }
37
+ export function convertModifierExtrasPriceToCents(modifierExtra) {
38
+ return {
39
+ ...modifierExtra,
40
+ ...(Array.isArray(modifierExtra.options)
41
+ ? {
42
+ options: modifierExtra.options.map((option) => ({
43
+ ...option,
44
+ price: convertPriceObjToCents(option.price),
45
+ multiplier: getModifierOptionMultiplier(option.multiplier, true),
46
+ })),
47
+ }
48
+ : {}),
49
+ };
50
+ }
51
+ export function convertModifierExtrasPriceFromCents(modifier) {
52
+ return {
53
+ ...modifier,
54
+ options: modifier.options.map((option) => ({
55
+ ...option,
56
+ price: convertPriceObjFromCents(option.price),
57
+ multiplier: getModifierOptionMultiplier(option.multiplier),
58
+ })),
59
+ };
60
+ }
61
+ // =========================>>>><<<<============================
62
+ export function getPartialItemWithCents(item, removeItemBasedOptionFields) {
63
+ return {
64
+ ...item,
65
+ ...(item.display_price != undefined ? { display_price: convertPriceToCents(item.display_price) } : {}),
66
+ ...(item.price !== undefined ? { price: convertPriceObjToCents(item.price) } : {}),
67
+ ...(item.discount_amount !== undefined ? { discount_amount: convertPriceObjToCents(item.discount_amount) } : {}),
68
+ ...(item.tax_rate !== undefined ? { tax_rate: convertPriceObjToCents(item.tax_rate) } : {}),
69
+ ...(item.modifiers !== undefined
70
+ ? { modifiers: convertModifiersPriceToCents(item.modifiers, removeItemBasedOptionFields) }
71
+ : {}),
72
+ ...(item.item_special_hours !== undefined
73
+ ? { item_special_hours: convertSpecialHoursToCents(item.item_special_hours) }
74
+ : {}),
75
+ ...(item.ingredients !== undefined ? { ingredients: getIngredientsWithInt(item.ingredients) } : {}),
76
+ };
77
+ }
78
+ export function getItemWithCents(item) {
79
+ return {
80
+ ...item,
81
+ display_price: item.display_price != null ? convertPriceToCents(item.display_price) : item.display_price,
82
+ price: convertPriceObjToCents(item.price),
83
+ discount_amount: convertPriceObjToCents(item.discount_amount),
84
+ tax_rate: convertPriceObjToCents(item.tax_rate),
85
+ modifiers: convertModifiersPriceToCents(item.modifiers),
86
+ item_special_hours: convertSpecialHoursToCents(item.item_special_hours),
87
+ ingredients: getIngredientsWithInt(item.ingredients),
88
+ };
89
+ }
90
+ export function getSortedPartialItemWithPrice(item) {
91
+ return {
92
+ ...item,
93
+ ...(item.display_price != undefined ? { display_price: convertPriceFromCents(item.display_price) } : {}),
94
+ ...(item.price !== undefined ? { price: convertPriceObjFromCents(item.price) } : {}),
95
+ ...(item.discount_amount !== undefined ? { discount_amount: convertPriceObjFromCents(item.discount_amount) } : {}),
96
+ ...(item.tax_rate !== undefined ? { tax_rate: convertPriceObjFromCents(item.tax_rate) } : {}),
97
+ ...(item.modifiers !== undefined ? { modifiers: convertModifiersPriceFromCentsAndSort(item.modifiers) } : {}),
98
+ ...(item.item_special_hours !== undefined
99
+ ? { item_special_hours: convertSpecialHoursFromCents(item.item_special_hours) }
100
+ : {}),
101
+ ...(item.ingredients !== undefined ? { ingredients: getIngredientsWithDecimal(item.ingredients) } : {}),
102
+ };
103
+ }
104
+ export function getSortedItemWithPrice(item) {
105
+ return {
106
+ ...item,
107
+ display_price: item.display_price != null ? convertPriceFromCents(item.display_price) : item.display_price,
108
+ price: convertPriceObjFromCents(item.price),
109
+ discount_amount: convertPriceObjFromCents(item.discount_amount),
110
+ tax_rate: convertPriceObjFromCents(item.tax_rate),
111
+ modifiers: convertModifiersPriceFromCentsAndSort(item.modifiers),
112
+ item_special_hours: convertSpecialHoursFromCents(item.item_special_hours),
113
+ ingredients: getIngredientsWithDecimal(item.ingredients),
114
+ };
115
+ }
116
+ export function getOfferRewardItem(item) {
117
+ return {
118
+ ...item,
119
+ ...(item.item_special_hours != null
120
+ ? {
121
+ item_special_hours: item.item_special_hours.map((specialHour) => ({
122
+ ...specialHour,
123
+ discount_amount: null,
124
+ })),
125
+ }
126
+ : {}),
127
+ discount_amount: null,
128
+ };
129
+ }