@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,851 @@
1
+ import moment from 'moment';
2
+ import { COMPARISON_REPORT_TYPE_ENUM, CURRENCY_SYMBOL_ENUM } from '../../constants';
3
+ import { localeAmount } from './common';
4
+ export const HOURLY_MONEY_FIELDS = new Set([
5
+ 'grand_total',
6
+ 'cancelled_orders_amount',
7
+ 'amount_collected',
8
+ 'service_fee_amount',
9
+ 'total_discount_amount',
10
+ 'order_discount_amount',
11
+ 'tip_amount',
12
+ 'tax_amount',
13
+ 'price',
14
+ 'amount_earned',
15
+ 'delivery_cost',
16
+ 'surcharge_amount',
17
+ 'gst_amount',
18
+ ]);
19
+ const ALL_ID = 'ALL_ID';
20
+ const COMPARATIVE_ID = 'COMPARATIVE_ID';
21
+ const getColumnHeaderUtil = (isComparative, reportType) => {
22
+ if (isComparative)
23
+ return 'Date / Tenant';
24
+ switch (reportType) {
25
+ case COMPARISON_REPORT_TYPE_ENUM.DAILY:
26
+ return 'Daily';
27
+ case COMPARISON_REPORT_TYPE_ENUM.WEEKLY:
28
+ return 'Weekly';
29
+ case COMPARISON_REPORT_TYPE_ENUM.MONTHLY:
30
+ return 'Monthly';
31
+ default:
32
+ return 'Daily';
33
+ }
34
+ };
35
+ const formatDateByReportTypeUtil = (dateField, reportType) => {
36
+ if (reportType === COMPARISON_REPORT_TYPE_ENUM.DAILY) {
37
+ return moment(dateField, 'YYYY-MM-DD').format('MMM DD, YYYY');
38
+ }
39
+ else if (reportType === COMPARISON_REPORT_TYPE_ENUM.WEEKLY) {
40
+ const [year, month, week] = dateField.split('-');
41
+ const monthName = moment(`${year}-${month}`, 'YYYY-MM').format('MMMM');
42
+ return `${monthName}, W ${parseInt(week, 10)}`;
43
+ }
44
+ else {
45
+ // MONTHLY
46
+ return moment(dateField, 'YYYY-MM').format('MMMM YYYY');
47
+ }
48
+ };
49
+ // Helper function to format date based on report type
50
+ const formatDateByReportType = (dateField, reportType) => {
51
+ if (!dateField)
52
+ return 'N/A';
53
+ switch (reportType) {
54
+ case COMPARISON_REPORT_TYPE_ENUM.DAILY:
55
+ return moment(dateField, 'YYYY-MM-DD').format('MMMM D, YYYY');
56
+ case COMPARISON_REPORT_TYPE_ENUM.WEEKLY:
57
+ const [year, month, week] = dateField.split('-');
58
+ const monthName = moment(`${year}-${month}`, 'YYYY-MM').format('MMMM');
59
+ return `Week ${parseInt(week, 10)} of ${monthName} ${year}`;
60
+ case COMPARISON_REPORT_TYPE_ENUM.MONTHLY:
61
+ return moment(dateField, 'YYYY-MM').format('MMMM YYYY');
62
+ default:
63
+ return moment(dateField).format('MMMM D, YYYY');
64
+ }
65
+ };
66
+ // Group data by date for comparative mode
67
+ const groupDataByDate = (data) => {
68
+ const grouped = new Map();
69
+ data.forEach((record) => {
70
+ const dateKey = record.date_field;
71
+ if (!grouped.has(dateKey)) {
72
+ grouped.set(dateKey, []);
73
+ }
74
+ grouped.get(dateKey).push(record);
75
+ });
76
+ // Sort dates to ensure consistent ordering
77
+ const sortedEntries = Array.from(grouped.entries()).sort(([a], [b]) => moment(a).valueOf() - moment(b).valueOf());
78
+ return new Map(sortedEntries);
79
+ };
80
+ // Get time ranges for hours
81
+ export const calculateHourlyComparisonReportDynamicWidth = (timeRanges, baseWidth = 200, columnWidth = 140, padding = 40, minWidth) => {
82
+ const calculatedWidth = baseWidth + timeRanges.length * columnWidth + padding;
83
+ return minWidth ? Math.max(minWidth, calculatedWidth) : calculatedWidth;
84
+ };
85
+ export const getHourlyComparisonReportTimeRanges = () => {
86
+ return Array.from({ length: 24 }, (_, index) => {
87
+ const startHour = index % 24;
88
+ const endHour = (index + 1) % 24;
89
+ const formatHour = (hour) => moment({ hour }).format('hA').toLowerCase();
90
+ return {
91
+ key: `${startHour}`,
92
+ label: `${formatHour(startHour)} to ${formatHour(endHour)}`,
93
+ };
94
+ });
95
+ };
96
+ // Generate HTML template for receipt-style hourly comparison report
97
+ export function getHourlyComparisonReceiptHtml(props) {
98
+ const { tenantName, from, to, width = 300, data = [], isComparative = false, reportType = COMPARISON_REPORT_TYPE_ENUM.DAILY, tenantNameMap = {}, currency_symbol = CURRENCY_SYMBOL_ENUM.Rs, selectedField, selectedTenantId, } = props;
99
+ const fromFormatted = from ? moment(from).format('MMM DD, YYYY') : 'N/A';
100
+ const toFormatted = to ? moment(to).format('MMM DD, YYYY') : 'N/A';
101
+ const currentDate = moment().format('MMM DD, YYYY');
102
+ const currentTime = moment().format('hh:mm A');
103
+ const fieldDisplayName = selectedField
104
+ .split('_')
105
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
106
+ .join(' ');
107
+ const reportTitle = isComparative
108
+ ? `Hourly Comparative Report - ${fieldDisplayName}`
109
+ : `Hourly Comparison Report - ${fieldDisplayName}`;
110
+ const timeRanges = getHourlyComparisonReportTimeRanges();
111
+ // Group data by date for comparative mode
112
+ const groupedData = isComparative ? groupDataByDate(data) : null;
113
+ // Format value based on field type
114
+ const formatValue = (value, totalOrders = 0) => {
115
+ if (isNaN(value) || value === 0)
116
+ return '-';
117
+ const formattedValue = HOURLY_MONEY_FIELDS.has(selectedField)
118
+ ? localeAmount(currency_symbol, value)
119
+ : value.toString();
120
+ return totalOrders > 0 ? `${formattedValue} (${totalOrders})` : formattedValue;
121
+ };
122
+ // Generate hourly field rows for a single record
123
+ const generateHourlyFields = (record) => {
124
+ return timeRanges
125
+ .map(({ key, label }) => {
126
+ const cell = record[key];
127
+ const value = typeof cell === 'object' && cell !== null ? cell.value : typeof cell === 'number' ? cell : NaN;
128
+ const totalOrders = typeof cell === 'object' && typeof cell.total_orders === 'number' ? cell.total_orders : 0;
129
+ return `
130
+ <div class="receipt-item-row">
131
+ <span class="receipt-item-name">${label}</span>
132
+ <span class="receipt-item-value">${formatValue(value, totalOrders)}</span>
133
+ </div>
134
+ `;
135
+ })
136
+ .join('');
137
+ };
138
+ // Generate content based on mode
139
+ const generateReceiptContent = () => {
140
+ // Check for empty data first
141
+ if (data.length === 0) {
142
+ return '<div class="receipt-no-data">No hourly data available for the selected period.</div>';
143
+ }
144
+ if (isComparative) {
145
+ if (!groupedData || groupedData.size === 0) {
146
+ return '<div class="receipt-no-data">No comparative data available for the selected period.</div>';
147
+ }
148
+ return Array.from(groupedData.entries())
149
+ .map(([date, records]) => {
150
+ let content = `
151
+ <div class="receipt-date-header">
152
+ ${formatDateByReportType(date, reportType)}
153
+ </div>
154
+ `;
155
+ records.forEach((record) => {
156
+ const tenantDisplayName = tenantNameMap[record.tenant_id || ''] || 'Unknown Tenant';
157
+ content += `
158
+ <div class="receipt-tenant-section">
159
+ <div class="receipt-tenant-name">${tenantDisplayName}</div>
160
+ ${generateHourlyFields(record)}
161
+ </div>
162
+ `;
163
+ });
164
+ return content;
165
+ })
166
+ .join('');
167
+ }
168
+ else {
169
+ // Non-comparative mode - either All or specific tenant
170
+ return data
171
+ .map((record) => {
172
+ const dateDisplay = formatDateByReportType(record.date_field, reportType);
173
+ let content = `
174
+ <div class="receipt-date-header">
175
+ ${dateDisplay}
176
+ </div>
177
+ `;
178
+ // Check if this is a specific tenant view
179
+ const uniqueTenants = [...new Set(data.map((r) => r.tenant_id).filter(Boolean))];
180
+ const isSpecificTenant = selectedTenantId && selectedTenantId !== ALL_ID && selectedTenantId !== COMPARATIVE_ID;
181
+ if (isSpecificTenant || (uniqueTenants.length > 1 && record.tenant_id)) {
182
+ const tenantDisplayName = tenantNameMap[record.tenant_id || ''] || 'Unknown Tenant';
183
+ content += `
184
+ <div class="receipt-tenant-section">
185
+ <div class="receipt-tenant-name">${tenantDisplayName}</div>
186
+ ${generateHourlyFields(record)}
187
+ </div>
188
+ `;
189
+ }
190
+ else {
191
+ content += `
192
+ <div class="receipt-fields-section">
193
+ ${generateHourlyFields(record)}
194
+ </div>
195
+ `;
196
+ }
197
+ return content;
198
+ })
199
+ .join('');
200
+ }
201
+ };
202
+ const styles = `
203
+ <style>
204
+ * {
205
+ margin: 0;
206
+ padding: 0;
207
+ box-sizing: border-box;
208
+ font-family: 'Courier New', monospace;
209
+ }
210
+
211
+ .receipt-container {
212
+ width: ${width}px;
213
+ max-width: ${width}px;
214
+ padding: 10px;
215
+ background: #ffffff;
216
+ color: #000000;
217
+ font-size: 12px;
218
+ line-height: 1.2;
219
+ }
220
+
221
+ .receipt-header {
222
+ text-align: center;
223
+ margin-bottom: 15px;
224
+ border-bottom: 1px solid #000000;
225
+ padding-bottom: 10px;
226
+ }
227
+
228
+ .receipt-company-name {
229
+ font-size: 16px;
230
+ font-weight: bold;
231
+ margin-bottom: 5px;
232
+ }
233
+
234
+ .receipt-title {
235
+ font-size: 14px;
236
+ font-weight: bold;
237
+ margin-bottom: 5px;
238
+ }
239
+
240
+ .receipt-date-range {
241
+ font-size: 14px;
242
+ margin-bottom: 3px;
243
+ }
244
+
245
+ .receipt-content {
246
+ margin-bottom: 15px;
247
+ }
248
+
249
+ .receipt-date-header {
250
+ text-align: center;
251
+ font-weight: bold;
252
+ font-size: 12px;
253
+ margin: 10px 0 8px 0;
254
+ padding: 3px 0;
255
+ border-top: 1px solid #000000;
256
+ border-bottom: 1px solid #000000;
257
+ text-transform: uppercase;
258
+ }
259
+
260
+ .receipt-tenant-section,
261
+ .receipt-fields-section {
262
+ margin-bottom: 8px;
263
+ }
264
+
265
+ .receipt-tenant-name {
266
+ font-weight: bold;
267
+ font-size: 11px;
268
+ margin-bottom: 3px;
269
+ text-decoration: underline;
270
+ }
271
+
272
+ .receipt-item-row {
273
+ display: flex;
274
+ justify-content: space-between;
275
+ align-items: flex-start;
276
+ margin-bottom: 2px;
277
+ padding: 1px 0;
278
+ }
279
+
280
+ .receipt-item-name {
281
+ flex: 1;
282
+ text-align: left;
283
+ font-size: 15px;
284
+ padding-right: 5px;
285
+ word-wrap: break-word;
286
+ line-height: 1.1;
287
+ }
288
+
289
+ .receipt-item-value {
290
+ text-align: right;
291
+ font-weight: bold;
292
+ font-size: 13px;
293
+ white-space: nowrap;
294
+ line-height: 1.1;
295
+ }
296
+
297
+ .receipt-no-data {
298
+ text-align: center;
299
+ font-style: italic;
300
+ padding: 20px;
301
+ color: #666;
302
+ }
303
+
304
+ .receipt-footer {
305
+ margin-top: 15px;
306
+ padding-top: 10px;
307
+ border-top: 1px solid #000000;
308
+ text-align: center;
309
+ font-size: 10px;
310
+ }
311
+
312
+ .receipt-footer-company {
313
+ font-weight: bold;
314
+ margin-bottom: 3px;
315
+ font-size: 16px;
316
+ }
317
+
318
+ .receipt-footer-date {
319
+ font-size: 12px;
320
+ }
321
+
322
+ @media print {
323
+ .receipt-container {
324
+ width: auto !important;
325
+ max-width: none !important;
326
+ }
327
+ }
328
+ </style>
329
+ `;
330
+ return `
331
+ <!DOCTYPE html>
332
+ <html lang="en">
333
+ <head>
334
+ <meta charset="UTF-8">
335
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
336
+ <title>${reportTitle} - Receipt</title>
337
+ ${styles}
338
+ </head>
339
+ <body>
340
+ <div class="receipt-container">
341
+ <div class="receipt-header">
342
+ <div class="receipt-company-name">${tenantName || 'All Tenants'}</div>
343
+ <div class="receipt-title">${reportTitle}</div>
344
+ <div class="receipt-date-range">${fromFormatted} - ${toFormatted}</div>
345
+ </div>
346
+
347
+ <div class="receipt-content">
348
+ ${generateReceiptContent()}
349
+ </div>
350
+
351
+ <div class="receipt-footer">
352
+ <div class="receipt-footer-company">${tenantName || 'All Tenants'}</div>
353
+ <div class="receipt-footer-date">Exported on ${currentDate} ${currentTime}</div>
354
+ </div>
355
+ </div>
356
+ </body>
357
+ </html>
358
+ `;
359
+ }
360
+ const renderHourlyCell = (hour, record, hourlyAverages, currency_symbol, selectedField, getClassForValue) => {
361
+ const cell = record[hour];
362
+ const value = typeof cell === 'object' && cell !== null ? cell.value : typeof cell === 'number' ? cell : NaN;
363
+ if (isNaN(value) || value === 0) {
364
+ return `<td class="css-1frso49fdsdv disabled-text">-</td>`;
365
+ }
366
+ const totalOrders = typeof cell === 'object' && typeof cell.total_orders === 'number' ? cell.total_orders : 0;
367
+ const average = hourlyAverages[hour] || 0;
368
+ let cssClass = 'css-1frso49fdsdv';
369
+ // Apply color coding
370
+ cssClass += ` ${getClassForValue(value, average)}`;
371
+ const formattedText = HOURLY_MONEY_FIELDS.has(selectedField)
372
+ ? `${localeAmount(currency_symbol, value)}${totalOrders !== 0 ? ` (${totalOrders})` : ''}`
373
+ : `${value}`;
374
+ return `<td class="${cssClass}">${formattedText}</td>`;
375
+ };
376
+ // Generate HTML template for hourly comparison report
377
+ export function getHourlyComparisonReportHtml(props) {
378
+ const { data, tenantName, from, to, width = 800, monochrome = false, tenantNameMap = {}, isComparative, currency_symbol = CURRENCY_SYMBOL_ENUM.Rs, reportType = COMPARISON_REPORT_TYPE_ENUM.DAILY, selectedField, } = props;
379
+ const mainStyle = width ? `style="width: ${width}px; max-width: ${width}px"` : '';
380
+ // Shared utilities
381
+ // Helper function to format date based on report type
382
+ const formatDateByReportType = (dateField) => formatDateByReportTypeUtil(dateField, reportType);
383
+ // Get column header based on report type
384
+ const getColumnHeader = () => getColumnHeaderUtil(!!isComparative, reportType);
385
+ const timeRanges = getHourlyComparisonReportTimeRanges();
386
+ const baseWidth = 200; // Width for date column
387
+ const columnWidth = 140; // Width per hour column
388
+ const padding = 40; // Container padding
389
+ const calculatedWidth = calculateHourlyComparisonReportDynamicWidth(timeRanges, baseWidth, columnWidth, padding);
390
+ const dynamicWidth = Math.max(width || 800, calculatedWidth);
391
+ // Calculate hourly averages for color coding
392
+ const hourlyAverages = (() => {
393
+ const averages = {};
394
+ timeRanges.forEach(({ key }) => {
395
+ let sum = 0;
396
+ let count = 0;
397
+ data.forEach((row) => {
398
+ const cell = row[key];
399
+ const value = typeof cell === 'object' && cell !== null ? cell.value : typeof cell === 'number' ? cell : NaN;
400
+ if (!isNaN(value)) {
401
+ sum += value;
402
+ count += 1;
403
+ }
404
+ });
405
+ averages[key] = count > 0 ? sum / count : 0;
406
+ });
407
+ return averages;
408
+ })();
409
+ // Helper function to get CSS class for value comparison
410
+ const getClassForValue = (value, average) => {
411
+ if (value >= average)
412
+ return 'success-text';
413
+ if (value < average)
414
+ return 'error-text';
415
+ return '';
416
+ };
417
+ // Group data by date if comparative mode
418
+ const groupedData = isComparative ? groupDataByDate(data) : null;
419
+ const fromFormatted = from ? moment(from).format('MMM DD, YYYY') : 'N/A';
420
+ const toFormatted = to ? moment(to).format('MMM DD, YYYY') : 'N/A';
421
+ const currentDate = moment().format('MMM DD, YYYY');
422
+ const currentTime = moment().format('hh:mm A');
423
+ const styles = `
424
+ <style>
425
+ * {
426
+ margin: 0;
427
+ padding: 0;
428
+ box-sizing: border-box;
429
+ font-family: 'Arial', sans-serif;
430
+ }
431
+
432
+ .report-container {
433
+ width: ${dynamicWidth}px;
434
+ max-width: 100vw;
435
+ padding: 20px;
436
+ background: #ffffff;
437
+ ${monochrome ? 'color: #000000;' : 'color: #333333;'}
438
+ overflow-x: auto;
439
+ }
440
+
441
+ .table-container {
442
+ width: 100%;
443
+ overflow-x: auto;
444
+ margin-bottom: 20px;
445
+ border: 1px solid ${monochrome ? '#000000' : '#e0e0e0'};
446
+ border-radius: 8px;
447
+ }
448
+
449
+ @media print {
450
+ .report-container {
451
+ overflow-x: visible !important;
452
+ width: auto !important;
453
+ max-width: none !important;
454
+ }
455
+ .table-container {
456
+ overflow-x: visible !important;
457
+ border: none !important;
458
+ }
459
+ .css-u6h4ltdsd {
460
+ width: auto !important;
461
+ }
462
+ }
463
+
464
+ .header {
465
+ text-align: center;
466
+ margin-bottom: 30px;
467
+ border-bottom: 2px solid ${monochrome ? '#000000' : '#e0e0e0'};
468
+ padding-bottom: 20px;
469
+ }
470
+
471
+ .company-name {
472
+ font-size: 24px;
473
+ font-weight: bold;
474
+ margin-bottom: 10px;
475
+ ${monochrome ? 'color: #000000;' : 'color: #2c3e50;'}
476
+ }
477
+
478
+ .report-title {
479
+ font-size: 20px;
480
+ font-weight: 600;
481
+ margin-bottom: 10px;
482
+ ${monochrome ? 'color: #000000;' : 'color: #34495e;'}
483
+ }
484
+
485
+ .date-range {
486
+ font-size: 16px;
487
+ ${monochrome ? 'color: #000000;' : 'color: #95a5a6;'}
488
+ margin-bottom: 10px;
489
+ }
490
+
491
+ .footer {
492
+ margin-top: 40px;
493
+ padding-top: 20px;
494
+ border-top: 1px solid ${monochrome ? '#000000' : '#e0e0e0'};
495
+ text-align: center;
496
+ font-size: 12px;
497
+ ${monochrome ? 'color: #000000;' : 'color: #7f8c8d;'}
498
+ }
499
+
500
+ .tenant-info {
501
+ font-weight: 600;
502
+ margin-bottom: 5px;
503
+ font-size: 14px;
504
+ ${monochrome ? 'color: #000000;' : 'color: #2c3e50;'}
505
+ }
506
+
507
+ .export-info {
508
+ font-size: 12px;
509
+ ${monochrome ? 'color: #000000;' : 'color: #95a5a6;'}
510
+ }
511
+
512
+ .css-l5xv05dsdsd {
513
+ -webkit-font-smoothing: antialiased;
514
+ text-size-adjust: 100%;
515
+ color: rgb(51, 51, 51);
516
+ line-height: 1.3rem;
517
+ font-size: 1rem;
518
+ font-family: Roboto, "Public Sans", sans-serif;
519
+ font-weight: 400;
520
+ box-sizing: inherit;
521
+ position: relative;
522
+ margin: 0px;
523
+ }
524
+ .css-k060yydsds {
525
+ -webkit-font-smoothing: antialiased;
526
+ text-size-adjust: 100%;
527
+ line-height: 1.3rem;
528
+ font-size: 1rem;
529
+ font-family: Roboto, "Public Sans", sans-serif;
530
+ font-weight: 400;
531
+ box-sizing: inherit;
532
+ padding: 15px;
533
+ position: sticky;
534
+ top: 0px;
535
+ background-color: rgb(67, 22, 101);
536
+ color: rgb(255, 255, 255);
537
+ z-index: 1;
538
+ box-shadow: rgba(99, 99, 99, 0.2) 0px 2px 8px 0px;
539
+ }
540
+ .css-1fnliljdsdsd {
541
+ -webkit-font-smoothing: antialiased;
542
+ text-size-adjust: 100%;
543
+ color: rgb(255, 255, 255);
544
+ box-sizing: inherit;
545
+ margin: 0px;
546
+ font-weight: 500;
547
+ line-height: 1.4625rem;
548
+ font-family: Roboto, "Public Sans", sans-serif;
549
+ font-size: 1.5rem;
550
+ }
551
+ .css-1g652zldsfsf {
552
+ -webkit-font-smoothing: antialiased;
553
+ text-size-adjust: 100%;
554
+ color: rgb(255, 255, 255);
555
+ box-sizing: inherit;
556
+ margin: 0px;
557
+ line-height: 0.975rem;
558
+ font-family: Roboto, "Public Sans", sans-serif;
559
+ font-weight: 400;
560
+ font-size: 0.75rem;
561
+ }
562
+ .css-u6h4ltdsd {
563
+ -webkit-font-smoothing: antialiased;
564
+ text-size-adjust: 100%;
565
+ color: rgb(51, 51, 51);
566
+ line-height: 1.3rem;
567
+ font-size: 1rem;
568
+ font-family: Roboto, "Public Sans", sans-serif;
569
+ font-weight: 400;
570
+ box-sizing: inherit;
571
+ display: table;
572
+ width: max-content;
573
+ min-width: 100%;
574
+ border-collapse: collapse;
575
+ border-spacing: 0px;
576
+ }
577
+ .css-s4zxv0dsds {
578
+ -webkit-font-smoothing: antialiased;
579
+ text-size-adjust: 100%;
580
+ color: rgb(51, 51, 51);
581
+ line-height: 1.3rem;
582
+ font-size: 1rem;
583
+ font-family: Roboto, "Public Sans", sans-serif;
584
+ font-weight: 400;
585
+ box-sizing: inherit;
586
+ display: table-header-group;
587
+ }
588
+ .css-1frso49fdsdv {
589
+ -webkit-font-smoothing: antialiased;
590
+ text-size-adjust: 100%;
591
+ color: rgb(51, 51, 51);
592
+ line-height: 1.3rem;
593
+ font-size: 1rem;
594
+ font-family: Roboto, "Public Sans", sans-serif;
595
+ font-weight: 400;
596
+ box-sizing: inherit;
597
+ display: table-cell;
598
+ padding: 16px;
599
+ text-align: left;
600
+ border-bottom: 1px solid rgb(224, 224, 224);
601
+ letter-spacing: 0.01071em;
602
+ vertical-align: inherit;
603
+ }
604
+ .css-1frso49fdsdv.success-text {
605
+ color: ${monochrome ? '#000000' : '#2e7d32'};
606
+ }
607
+ .css-1frso49fdsdv.error-text {
608
+ color: ${monochrome ? '#000000' : '#c62828'};
609
+ }
610
+ .css-1frso49fdsdv.disabled-text {
611
+ color: ${monochrome ? '#666666' : '#9e9e9e'};
612
+ text-align: center;
613
+ }
614
+ .css-1frso49fdsdv.unpaid-text {
615
+ color: ${monochrome ? '#000000' : '#c62828'};
616
+ font-weight: 600;
617
+ }
618
+ .success-text {
619
+ color: ${monochrome ? '#000000' : '#2e7d32'};
620
+ }
621
+ .error-text {
622
+ color: ${monochrome ? '#000000' : '#c62828'};
623
+ }
624
+ .disabled-text {
625
+ color: ${monochrome ? '#666666' : '#9e9e9e'};
626
+ text-align: center;
627
+ }
628
+ .css-1frso49fdsdvheader {
629
+ -webkit-font-smoothing: antialiased;
630
+ text-size-adjust: 100%;
631
+ line-height: 1.3rem;
632
+ font-size: 1rem;
633
+ font-family: Roboto, "Public Sans", sans-serif;
634
+ font-weight: 500;
635
+ box-sizing: inherit;
636
+ display: table-cell;
637
+ padding: 16px;
638
+ color: rgba(0, 0, 0, 0.87);
639
+ text-align: left;
640
+ border-bottom: 1px solid rgb(224, 224, 224);
641
+ letter-spacing: 0.01071em;
642
+ vertical-align: inherit;
643
+ background-color: rgb(250, 250, 250);
644
+ }
645
+ .css-1frso49fdsdvrow {
646
+ -webkit-font-smoothing: antialiased;
647
+ text-size-adjust: 100%;
648
+ color: rgb(51, 51, 51);
649
+ line-height: 1.3rem;
650
+ font-size: 1rem;
651
+ font-family: Roboto, "Public Sans", sans-serif;
652
+ font-weight: 400;
653
+ box-sizing: inherit;
654
+ color: inherit;
655
+ display: table-row;
656
+ vertical-align: middle;
657
+ outline: 0px;
658
+ }
659
+ .css-1frso49fdsdvrow:hover {
660
+ background-color: rgba(0, 0, 0, 0.04);
661
+ }
662
+ .css-1frso49fdsdvgrouprow {
663
+ -webkit-font-smoothing: antialiased;
664
+ text-size-adjust: 100%;
665
+ color: rgb(51, 51, 51);
666
+ line-height: 1.3rem;
667
+ font-size: 1rem;
668
+ font-family: Roboto, "Public Sans", sans-serif;
669
+ font-weight: 500;
670
+ box-sizing: inherit;
671
+ color: inherit;
672
+ display: table-row;
673
+ vertical-align: middle;
674
+ outline: 0px;
675
+ background-color: rgb(245, 245, 245);
676
+ }
677
+ .css-1frso49fdsdvgrouprow .css-1frso49fdsdv {
678
+ font-weight: 600;
679
+ color: rgb(51, 51, 51);
680
+ }
681
+
682
+ ${monochrome
683
+ ? `
684
+ /* Receipt Printer Optimized Styles - Monochrome */
685
+ * {
686
+ font-family: "Roboto Condensed", Roboto, sans-serif !important;
687
+ }
688
+
689
+ .report-container {
690
+ padding: 4px !important;
691
+ }
692
+
693
+ .header {
694
+ margin-bottom: 8px !important;
695
+ padding-bottom: 4px !important;
696
+ }
697
+
698
+ .company-name {
699
+ font-size: 20px !important;
700
+ margin-bottom: 2px !important;
701
+ }
702
+
703
+ .report-title {
704
+ font-size: 18px !important;
705
+ margin-bottom: 2px !important;
706
+ }
707
+
708
+ .date-range {
709
+ font-size: 16px !important;
710
+ margin-bottom: 2px !important;
711
+ }
712
+
713
+ .footer {
714
+ margin-top: 8px !important;
715
+ padding-top: 4px !important;
716
+ font-size: 15px !important;
717
+ }
718
+
719
+ .tenant-info {
720
+ font-size: 17px !important;
721
+ margin-bottom: 2px !important;
722
+ }
723
+
724
+ .export-info {
725
+ font-size: 15px !important;
726
+ }
727
+
728
+ .css-l5xv05dsdsd,
729
+ .css-u6h4ltdsd,
730
+ .css-s4zxv0dsds,
731
+ .css-1frso49fdsdvrow,
732
+ .css-1frso49fdsdvgrouprow {
733
+ font-size: 16px !important;
734
+ line-height: 18px !important;
735
+ }
736
+
737
+ .css-k060yydsds {
738
+ padding: 4px !important;
739
+ }
740
+
741
+ .css-1fnliljdsdsd {
742
+ font-size: 18px !important;
743
+ line-height: 20px !important;
744
+ }
745
+
746
+ .css-1g652zldsfsf {
747
+ font-size: 15px !important;
748
+ line-height: 17px !important;
749
+ }
750
+
751
+ .css-1frso49fdsdv,
752
+ .css-1frso49fdsdvheader {
753
+ padding: 3px 4px !important;
754
+ font-size: 15px !important;
755
+ line-height: 18px !important;
756
+ }
757
+ `
758
+ : ''}
759
+ </style>
760
+ `;
761
+ // Generate table headers
762
+ const tableHeaders = `
763
+ <tr class="css-1frso49fdsdvrow">
764
+ <th class="css-1frso49fdsdvheader">${getColumnHeader()}</th>
765
+ ${timeRanges
766
+ .map(({ label }) => `<th class="css-1frso49fdsdvheader" style="text-align: center; min-width: 140px;">${label}</th>`)
767
+ .join('')}
768
+ </tr>
769
+ `;
770
+ // Generate table rows
771
+ let tableRows = '';
772
+ if (isComparative && groupedData) {
773
+ // Comparative mode - group by date
774
+ for (const [dateKey, records] of groupedData) {
775
+ const formattedDate = formatDateByReportType(dateKey);
776
+ // Group header row
777
+ tableRows += `
778
+ <tr class="css-1frso49fdsdvgrouprow">
779
+ <td class="css-1frso49fdsdv" colspan="${timeRanges.length + 1}">${formattedDate}</td>
780
+ </tr>
781
+ `;
782
+ // Individual tenant rows
783
+ records.forEach((record) => {
784
+ const tenantName = tenantNameMap[record.tenant_id || ''] || 'Unknown Tenant';
785
+ tableRows += `
786
+ <tr class="css-1frso49fdsdvrow">
787
+ <td class="css-1frso49fdsdv" style="padding-left: 32px;">${tenantName}</td>
788
+ ${timeRanges
789
+ .map(({ key }) => renderHourlyCell(key, record, hourlyAverages, currency_symbol, selectedField, getClassForValue))
790
+ .join('')}
791
+ </tr>
792
+ `;
793
+ });
794
+ }
795
+ }
796
+ else {
797
+ // Non-comparative mode
798
+ data.forEach((record) => {
799
+ const formattedDate = formatDateByReportType(record.date_field);
800
+ tableRows += `
801
+ <tr class="css-1frso49fdsdvrow">
802
+ <td class="css-1frso49fdsdv">${formattedDate}</td>
803
+ ${timeRanges
804
+ .map(({ key }) => renderHourlyCell(key, record, hourlyAverages, currency_symbol, selectedField, getClassForValue))
805
+ .join('')}
806
+ </tr>
807
+ `;
808
+ });
809
+ }
810
+ const fieldDisplayName = selectedField
811
+ .split('_')
812
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
813
+ .join(' ');
814
+ const content = `
815
+ <!DOCTYPE html>
816
+ <html lang="en">
817
+ <head>
818
+ <meta charset="UTF-8">
819
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
820
+ <title>Hourly Comparison Report</title>
821
+ ${styles}
822
+ </head>
823
+ <body>
824
+ <div class="report-container" ${mainStyle}>
825
+ <div class="header">
826
+ <div class="company-name">${tenantName || 'All Tenants'}</div>
827
+ <div class="report-title">Hourly Comparison Report - ${fieldDisplayName}</div>
828
+ <div class="date-range">From: ${fromFormatted} | To: ${toFormatted}</div>
829
+ </div>
830
+
831
+ <div class="table-container">
832
+ <table class="css-u6h4ltdsd">
833
+ <thead class="css-s4zxv0dsds">
834
+ ${tableHeaders}
835
+ </thead>
836
+ <tbody>
837
+ ${tableRows}
838
+ </tbody>
839
+ </table>
840
+ </div>
841
+
842
+ <div class="footer">
843
+ <div class="tenant-info">Report generated for: ${tenantName || 'All Tenants'}</div>
844
+ <div class="export-info">Exported on ${currentDate} at ${currentTime}</div>
845
+ </div>
846
+ </div>
847
+ </body>
848
+ </html>
849
+ `;
850
+ return content;
851
+ }