@managesome/eposmatic-toolkit 0.3.7 → 0.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/constants/ANALYTICS.js +146 -0
- package/esm/constants/API_ERRORS.js +6 -0
- package/esm/constants/COMMON.js +369 -0
- package/esm/constants/DELIVERY.js +45 -0
- package/esm/constants/DIALER_ENUMS.js +11 -0
- package/esm/constants/ENUMS.js +1988 -0
- package/esm/constants/FBR_ENUMS.js +18 -0
- package/esm/constants/HUBRISE_ENUMS.js +179 -0
- package/esm/constants/INTERNAL_ENUMS.js +49 -0
- package/esm/constants/NOTIFICATIONS.js +6 -0
- package/esm/constants/ORDER.js +251 -0
- package/esm/constants/PRA_ENUMS.js +18 -0
- package/esm/constants/REPORT_WEBVIEW.js +28 -0
- package/esm/constants/RFQ_GO.js +83 -0
- package/esm/constants/SMARTPAY_ENUMS.js +55 -0
- package/esm/constants/SOCKET.js +149 -0
- package/esm/constants/SRB_ENUMS.js +13 -0
- package/esm/constants/SWITCHPAY.js +28 -0
- package/esm/constants/TENANT_ENUMS.js +90 -0
- package/esm/constants/TENANT_PURCHASE_ORDER.js +91 -0
- package/esm/constants/WALLET.js +51 -0
- package/esm/constants/WAREHOUSE_ANALYTICS.js +28 -0
- package/esm/constants/WAREHOUSE_ENUMS.js +420 -0
- package/esm/constants/WAREHOUSE_PURCHASE_ORDER.js +97 -0
- package/esm/constants/WEBVIEW.js +43 -0
- package/esm/constants/WORKER_ENDPOINTS.js +79 -0
- package/esm/constants/index.js +27 -0
- package/esm/constants/types.js +2 -0
- package/esm/helpers/fbr/generate-invoice.js +94 -0
- package/esm/helpers/fbr/index.js +1 -0
- package/esm/helpers/hubrise/hubrise-catalog.js +304 -0
- package/esm/helpers/hubrise/index.js +1 -0
- package/esm/helpers/index.js +9 -0
- package/esm/helpers/kpra/generate-invoice.js +26 -0
- package/esm/helpers/kpra/index.js +1 -0
- package/esm/helpers/order/generate-order.js +508 -0
- package/esm/helpers/order/generate-warehouse-internal-movement.js +71 -0
- package/esm/helpers/order/generate-warehouse-purchase-order-rfq.js +176 -0
- package/esm/helpers/order/generate-warehouse-purchase-order.js +187 -0
- package/esm/helpers/order/generate-warehouse-sale-order-rfq.js +176 -0
- package/esm/helpers/order/generate-warehouse-sale-order.js +149 -0
- package/esm/helpers/order/index.js +6 -0
- package/esm/helpers/pra/generate-invoice.js +94 -0
- package/esm/helpers/pra/index.js +1 -0
- package/esm/helpers/srb/generate-invoice.js +68 -0
- package/esm/helpers/srb/index.js +1 -0
- package/esm/helpers/store/all-orders-actions.js +17 -0
- package/esm/helpers/store/all-tenant-purchase-orders-actions.js +45 -0
- package/esm/helpers/store/all-warehouse-purchase-order-rfqs-actions.js +66 -0
- package/esm/helpers/store/all-warehouse-purchase-order-vendor-return-actions.js +50 -0
- package/esm/helpers/store/all-warehouse-purchase-orders-actions.js +49 -0
- package/esm/helpers/store/all-warehouse-sale-order-invoices-actions.js +132 -0
- package/esm/helpers/store/all-warehouse-sale-order-rfqs-actions.js +66 -0
- package/esm/helpers/store/all-warehouse-sale-orders-actions.js +72 -0
- package/esm/helpers/store/cart-actions.js +3563 -0
- package/esm/helpers/store/catalog-actions.js +379 -0
- package/esm/helpers/store/common-order-actions.js +937 -0
- package/esm/helpers/store/common-tenant-purchase-order-actions.js +440 -0
- package/esm/helpers/store/common-warehouse-internal-movement-actions.js +95 -0
- package/esm/helpers/store/common-warehouse-purchase-order-actions.js +530 -0
- package/esm/helpers/store/common-warehouse-purchase-order-receipt-actions.js +33 -0
- package/esm/helpers/store/common-warehouse-purchase-order-rfq-actions.js +523 -0
- package/esm/helpers/store/common-warehouse-purchase-order-vendor-return-actions.js +25 -0
- package/esm/helpers/store/common-warehouse-sale-order-actions.js +483 -0
- package/esm/helpers/store/common-warehouse-sale-order-invoice-actions.js +54 -0
- package/esm/helpers/store/common-warehouse-sale-order-rfq-actions.js +523 -0
- package/esm/helpers/store/index.js +26 -0
- package/esm/helpers/store/offline-ordering.js +251 -0
- package/esm/helpers/store/tenant-purchase-orders-cart-actions.js +379 -0
- package/esm/helpers/store/warehouse-purchase-order-rfq-cart-actions.js +360 -0
- package/esm/helpers/store/warehouse-purchase-orders-cart-actions.js +470 -0
- package/esm/helpers/store/warehouse-sale-order-rfq-cart-actions.js +359 -0
- package/esm/helpers/store/warehouse-sale-orders-cart-actions.js +456 -0
- package/esm/helpers/types/api-types.js +1 -0
- package/esm/helpers/types/cart-actions.js +1 -0
- package/esm/helpers/types/cart-helpers.js +1 -0
- package/esm/helpers/types/catalog.js +1 -0
- package/esm/helpers/types/common.js +1 -0
- package/esm/helpers/types/deliverect_menu.js +1 -0
- package/esm/helpers/types/email-templates.js +1 -0
- package/esm/helpers/types/fbr-generate-invoice.js +1 -0
- package/esm/helpers/types/halfhalf.js +1 -0
- package/esm/helpers/types/hubrise_catalog.js +1 -0
- package/esm/helpers/types/hubrise_customers.js +1 -0
- package/esm/helpers/types/hubrise_deliveries.js +1 -0
- package/esm/helpers/types/hubrise_location.js +1 -0
- package/esm/helpers/types/hubrise_orders.js +1 -0
- package/esm/helpers/types/index.js +33 -0
- package/esm/helpers/types/internal-leads.js +1 -0
- package/esm/helpers/types/inventory-catalog.js +1 -0
- package/esm/helpers/types/kpra-generate-invoice.js +1 -0
- package/esm/helpers/types/marketing.js +1 -0
- package/esm/helpers/types/order-engine.js +1 -0
- package/esm/helpers/types/pra-generate-invoice.js +1 -0
- package/esm/helpers/types/report-webview.js +1 -0
- package/esm/helpers/types/reports.js +1 -0
- package/esm/helpers/types/smartpay-apis.js +2 -0
- package/esm/helpers/types/specials.js +1 -0
- package/esm/helpers/types/split_bill.js +1 -0
- package/esm/helpers/types/srb-generate-invoice.js +1 -0
- package/esm/helpers/types/switchpay.js +1 -0
- package/esm/helpers/types/tenant-purchase-order-cart-actions.js +1 -0
- package/esm/helpers/types/warehouse-catalog.js +1 -0
- package/esm/helpers/types/warehouse-purchase-order-cart-actions.js +1 -0
- package/esm/helpers/types/warehouse-purchase-order-rfq-cart-actions.js +1 -0
- package/esm/helpers/types/warehouse-sale-order-cart-actions.js +1 -0
- package/esm/helpers/types/warehouse-sale-order-rfq-cart-actions.js +1 -0
- package/esm/helpers/types/workers.js +1 -0
- package/esm/helpers/utils/asaanbill-identifier-helpers.js +31 -0
- package/esm/helpers/utils/business-day-helpers.js +201 -0
- package/esm/helpers/utils/cart-helpers.js +156 -0
- package/esm/helpers/utils/catalog-conversion.js +129 -0
- package/esm/helpers/utils/code-redemption-helpers.js +452 -0
- package/esm/helpers/utils/color-helpers.js +31 -0
- package/esm/helpers/utils/common.js +368 -0
- package/esm/helpers/utils/crypt.js +40 -0
- package/esm/helpers/utils/customers-helpers.js +15 -0
- package/esm/helpers/utils/delivery-area-helpers.js +42 -0
- package/esm/helpers/utils/delivery-helpers.js +87 -0
- package/esm/helpers/utils/denominations-helpers.js +53 -0
- package/esm/helpers/utils/dinein.js +39 -0
- package/esm/helpers/utils/discount-helpers.js +55 -0
- package/esm/helpers/utils/email-helpers.js +111 -0
- package/esm/helpers/utils/error-helpers.js +14 -0
- package/esm/helpers/utils/expense.js +26 -0
- package/esm/helpers/utils/getFormFieldsDiff.js +15 -0
- package/esm/helpers/utils/gift-card-helpers.js +258 -0
- package/esm/helpers/utils/halfhalf-setup-helpers.js +779 -0
- package/esm/helpers/utils/hourly-comparison-report-helpers.js +851 -0
- package/esm/helpers/utils/hr-helpers.js +62 -0
- package/esm/helpers/utils/hubrise-utils.js +32 -0
- package/esm/helpers/utils/image-helpers.js +95 -0
- package/esm/helpers/utils/image-url-helpers.js +96 -0
- package/esm/helpers/utils/index.js +96 -0
- package/esm/helpers/utils/ingredients.js +26 -0
- package/esm/helpers/utils/internal-amount-helpers.js +49 -0
- package/esm/helpers/utils/inventory.js +123 -0
- package/esm/helpers/utils/inventory_entries.js +91 -0
- package/esm/helpers/utils/inventory_transactions.js +91 -0
- package/esm/helpers/utils/item-report-helpers.js +2603 -0
- package/esm/helpers/utils/items-comparison-report-helpers.js +1057 -0
- package/esm/helpers/utils/kds-helpers.js +43 -0
- package/esm/helpers/utils/location-helpers.js +13 -0
- package/esm/helpers/utils/menu-helpers.js +44 -0
- package/esm/helpers/utils/minified-catalog.js +428 -0
- package/esm/helpers/utils/offer-apply-helpers.js +613 -0
- package/esm/helpers/utils/offers-helpers.js +3351 -0
- package/esm/helpers/utils/operational-roles-helpers.js +33 -0
- package/esm/helpers/utils/order-engine.js +1409 -0
- package/esm/helpers/utils/order-history.js +208 -0
- package/esm/helpers/utils/payment-comparison-report-helpers.js +873 -0
- package/esm/helpers/utils/payment-helpers.js +302 -0
- package/esm/helpers/utils/pdf-generator.js +110 -0
- package/esm/helpers/utils/platform-catalog.js +306 -0
- package/esm/helpers/utils/platform-num.js +188 -0
- package/esm/helpers/utils/platform-specific-tenant-shifts.js +19 -0
- package/esm/helpers/utils/price-conversion.js +24 -0
- package/esm/helpers/utils/printer-helpers.js +319 -0
- package/esm/helpers/utils/public-holidays-helpers.js +8 -0
- package/esm/helpers/utils/ratings-comparison-report-helpers.js +1187 -0
- package/esm/helpers/utils/receipt-engine.js +1050 -0
- package/esm/helpers/utils/review-helpers.js +391 -0
- package/esm/helpers/utils/rider-tracking.js +12 -0
- package/esm/helpers/utils/riders-report-helpers.js +1590 -0
- package/esm/helpers/utils/sales-comparison-report-helpers.js +1259 -0
- package/esm/helpers/utils/sales-comparitive-report-helpers.js +939 -0
- package/esm/helpers/utils/sales-overview-report-helpers.js +1046 -0
- package/esm/helpers/utils/sales-summary-report-helpers.js +877 -0
- package/esm/helpers/utils/scan-code-helpers.js +31 -0
- package/esm/helpers/utils/selection-model.js +68 -0
- package/esm/helpers/utils/shift-window-helpers.js +148 -0
- package/esm/helpers/utils/simplified-catalog.js +107 -0
- package/esm/helpers/utils/simplified-halfhalf.js +101 -0
- package/esm/helpers/utils/simplified-specials.js +107 -0
- package/esm/helpers/utils/simplified-tenant.js +411 -0
- package/esm/helpers/utils/specials-helpers.js +727 -0
- package/esm/helpers/utils/tenant-calendar-helpers.js +67 -0
- package/esm/helpers/utils/tenant-cash-drawer-sessions-helpers.js +248 -0
- package/esm/helpers/utils/tenant-cash-drawers-helpers.js +31 -0
- package/esm/helpers/utils/tenant-cash-in-out-helpers.js +47 -0
- package/esm/helpers/utils/tenant-day-sessions-helpers.js +167 -0
- package/esm/helpers/utils/tenant-instore-shift-sessions-helpers.js +227 -0
- package/esm/helpers/utils/tenant-staff-helpers.js +19 -0
- package/esm/helpers/utils/tenant_cash_in_hand_transactions.js +31 -0
- package/esm/helpers/utils/time-helpers.js +142 -0
- package/esm/helpers/utils/void-items-report-helpers.js +529 -0
- package/esm/helpers/utils/void-order-items-helpers.js +32 -0
- package/esm/helpers/utils/voidations-summary-report-helpers.js +800 -0
- package/esm/helpers/utils/wallet-helpers.js +22 -0
- package/esm/helpers/utils/wallet-redemption-helpers.js +46 -0
- package/esm/helpers/utils/warehouse-catalog-conversion.js +117 -0
- package/esm/helpers/utils/warehouse-inventory.js +59 -0
- package/esm/helpers/utils/warehouse-purchase-order-engine.js +27 -0
- package/esm/helpers/utils/warehouse-purchase-order-receipt-engine.js +205 -0
- package/esm/helpers/utils/warehouse-purchase-order-x-report-helpers.js +1432 -0
- package/esm/helpers/utils/warehouse-sale-order-engine.js +27 -0
- package/esm/helpers/utils/warehouse-sale-order-receipt-engine.js +207 -0
- package/esm/helpers/utils/warehouse-sale-order-x-report-helpers.js +1 -0
- package/esm/helpers/utils/warehouse-sale-x-report-helpers.js +1434 -0
- package/esm/helpers/utils/warehouse-settings-helpers.js +37 -0
- package/esm/helpers/utils/warehouse-void-purchase-order-items-helpers.js +34 -0
- package/esm/helpers/utils/warehouse-void-purchase-order-items-report-helpers.js +18 -0
- package/esm/helpers/utils/warehouse-void-sale-order-items-helpers.js +34 -0
- package/esm/helpers/utils/warehouse-void-sale-order-items-report-helpers.js +18 -0
- package/esm/helpers/utils/warehouse_inventory_transactions.js +91 -0
- package/esm/helpers/utils/x-report-helpers.js +1850 -0
- package/esm/index.js +3 -0
- package/esm/schemas/index.js +2 -0
- package/esm/schemas/models/app_configs.js +36 -0
- package/esm/schemas/models/applied_order_discounts.js +103 -0
- package/esm/schemas/models/brands.js +56 -0
- package/esm/schemas/models/categories.js +74 -0
- package/esm/schemas/models/close_dates.js +63 -0
- package/esm/schemas/models/common-models.js +449 -0
- package/esm/schemas/models/courses.js +62 -0
- package/esm/schemas/models/customer_redemptions.js +82 -0
- package/esm/schemas/models/customers.js +269 -0
- package/esm/schemas/models/deliveries.js +137 -0
- package/esm/schemas/models/delivery_areas.js +97 -0
- package/esm/schemas/models/dinein_floors.js +55 -0
- package/esm/schemas/models/dinein_tables.js +97 -0
- package/esm/schemas/models/dinein_tables_fingerprints.js +96 -0
- package/esm/schemas/models/discounts.js +87 -0
- package/esm/schemas/models/expense_categories.js +61 -0
- package/esm/schemas/models/expense_details.js +130 -0
- package/esm/schemas/models/gift_cards.js +342 -0
- package/esm/schemas/models/halfhalf_setup.js +142 -0
- package/esm/schemas/models/index.js +111 -0
- package/esm/schemas/models/internal_customers.js +139 -0
- package/esm/schemas/models/internal_invoices.js +119 -0
- package/esm/schemas/models/internal_leads.js +78 -0
- package/esm/schemas/models/internal_operational_roles.js +85 -0
- package/esm/schemas/models/internal_staffs.js +65 -0
- package/esm/schemas/models/inventories.js +103 -0
- package/esm/schemas/models/inventory_categories.js +52 -0
- package/esm/schemas/models/inventory_transactions.js +143 -0
- package/esm/schemas/models/item_transactions.js +117 -0
- package/esm/schemas/models/items.js +341 -0
- package/esm/schemas/models/marketing_fingerprints.js +92 -0
- package/esm/schemas/models/menus.js +66 -0
- package/esm/schemas/models/messaging_devices.js +99 -0
- package/esm/schemas/models/modifier_extras.js +120 -0
- package/esm/schemas/models/offers.js +470 -0
- package/esm/schemas/models/offers_fingerprints.js +61 -0
- package/esm/schemas/models/operational_roles.js +155 -0
- package/esm/schemas/models/orders.js +1051 -0
- package/esm/schemas/models/printer_settings.js +245 -0
- package/esm/schemas/models/public_holidays.js +58 -0
- package/esm/schemas/models/reservations.js +127 -0
- package/esm/schemas/models/reviews.js +145 -0
- package/esm/schemas/models/rewards_usage.js +61 -0
- package/esm/schemas/models/riders.js +75 -0
- package/esm/schemas/models/specials.js +169 -0
- package/esm/schemas/models/staff_shifts.js +66 -0
- package/esm/schemas/models/tenant-activity-logs.js +126 -0
- package/esm/schemas/models/tenant_active_jobs.js +77 -0
- package/esm/schemas/models/tenant_calendar.js +89 -0
- package/esm/schemas/models/tenant_cash_drawer_sessions.js +208 -0
- package/esm/schemas/models/tenant_cash_drawers.js +60 -0
- package/esm/schemas/models/tenant_cash_in_hand_transactions.js +69 -0
- package/esm/schemas/models/tenant_cash_in_out.js +104 -0
- package/esm/schemas/models/tenant_clients.js +66 -0
- package/esm/schemas/models/tenant_day_sessions.js +166 -0
- package/esm/schemas/models/tenant_hr_attendance_records.js +87 -0
- package/esm/schemas/models/tenant_hr_biometric_enrollments.js +69 -0
- package/esm/schemas/models/tenant_hr_departments.js +42 -0
- package/esm/schemas/models/tenant_hr_documents.js +71 -0
- package/esm/schemas/models/tenant_hr_employees.js +172 -0
- package/esm/schemas/models/tenant_hr_leave_requests.js +80 -0
- package/esm/schemas/models/tenant_hr_payrolls.js +131 -0
- package/esm/schemas/models/tenant_hr_performance_reviews.js +58 -0
- package/esm/schemas/models/tenant_hr_policies.js +57 -0
- package/esm/schemas/models/tenant_hr_positions.js +48 -0
- package/esm/schemas/models/tenant_hr_shift_schedules.js +84 -0
- package/esm/schemas/models/tenant_hr_shifts.js +64 -0
- package/esm/schemas/models/tenant_instore_shift_sessions.js +204 -0
- package/esm/schemas/models/tenant_instore_shifts.js +63 -0
- package/esm/schemas/models/tenant_inventory_department_transactions.js +116 -0
- package/esm/schemas/models/tenant_inventory_department_utilities.js +85 -0
- package/esm/schemas/models/tenant_inventory_departments.js +55 -0
- package/esm/schemas/models/tenant_inventory_entries.js +131 -0
- package/esm/schemas/models/tenant_metadata.js +88 -0
- package/esm/schemas/models/tenant_order_item_instructions.js +66 -0
- package/esm/schemas/models/tenant_purchase_order_vendor_returns.js +80 -0
- package/esm/schemas/models/tenant_purchase_orders.js +158 -0
- package/esm/schemas/models/tenant_shifts.js +57 -0
- package/esm/schemas/models/tenant_staffs.js +129 -0
- package/esm/schemas/models/tenant_vendors.js +99 -0
- package/esm/schemas/models/tenants.js +811 -0
- package/esm/schemas/models/terminal_devices.js +63 -0
- package/esm/schemas/models/tokens.js +73 -0
- package/esm/schemas/models/track_order_numbers.js +42 -0
- package/esm/schemas/models/void_order_items.js +210 -0
- package/esm/schemas/models/vouchers.js +101 -0
- package/esm/schemas/models/wallet_transactions.js +128 -0
- package/esm/schemas/models/wallets.js +44 -0
- package/esm/schemas/models/warehouse-activity-logs.js +144 -0
- package/esm/schemas/models/warehouse_categories.js +83 -0
- package/esm/schemas/models/warehouse_clients.js +81 -0
- package/esm/schemas/models/warehouse_communications.js +226 -0
- package/esm/schemas/models/warehouse_internal_movements.js +463 -0
- package/esm/schemas/models/warehouse_inventory_entries.js +125 -0
- package/esm/schemas/models/warehouse_inventory_lot_serial_numbers.js +188 -0
- package/esm/schemas/models/warehouse_inventory_transactions.js +133 -0
- package/esm/schemas/models/warehouse_item_transactions.js +97 -0
- package/esm/schemas/models/warehouse_items.js +173 -0
- package/esm/schemas/models/warehouse_operational_roles.js +87 -0
- package/esm/schemas/models/warehouse_purchase_order_receipts.js +163 -0
- package/esm/schemas/models/warehouse_purchase_order_rfqs.js +339 -0
- package/esm/schemas/models/warehouse_purchase_order_vendor_returns.js +199 -0
- package/esm/schemas/models/warehouse_purchase_orders.js +334 -0
- package/esm/schemas/models/warehouse_sale_deliveries.js +155 -0
- package/esm/schemas/models/warehouse_sale_invoices.js +229 -0
- package/esm/schemas/models/warehouse_sale_order_rfqs.js +340 -0
- package/esm/schemas/models/warehouse_sale_orders.js +322 -0
- package/esm/schemas/models/warehouse_staffs.js +104 -0
- package/esm/schemas/models/warehouse_track_order_numbers.js +73 -0
- package/esm/schemas/models/warehouse_vendors.js +99 -0
- package/esm/schemas/models/warehouse_void_purchase_order_items.js +174 -0
- package/esm/schemas/models/warehouse_void_sale_order_items.js +174 -0
- package/esm/schemas/models/warehouses.js +253 -0
- package/esm/schemas/types/app_configs.js +1 -0
- package/esm/schemas/types/applied_order_discounts.js +1 -0
- package/esm/schemas/types/brands.js +1 -0
- package/esm/schemas/types/categories.js +1 -0
- package/esm/schemas/types/close_dates.js +1 -0
- package/esm/schemas/types/common.js +1 -0
- package/esm/schemas/types/courses.js +1 -0
- package/esm/schemas/types/customer_redemptions.js +1 -0
- package/esm/schemas/types/customers.js +1 -0
- package/esm/schemas/types/deliveries.js +1 -0
- package/esm/schemas/types/delivery_areas.js +1 -0
- package/esm/schemas/types/dinein_floors.js +1 -0
- package/esm/schemas/types/dinein_tables.js +1 -0
- package/esm/schemas/types/dinein_tables_fingerprints.js +1 -0
- package/esm/schemas/types/discounts.js +1 -0
- package/esm/schemas/types/expense_categories.js +1 -0
- package/esm/schemas/types/expense_details.js +1 -0
- package/esm/schemas/types/gift_cards.js +1 -0
- package/esm/schemas/types/halfhalf_setup.js +1 -0
- package/esm/schemas/types/index.js +113 -0
- package/esm/schemas/types/internal_customers.js +1 -0
- package/esm/schemas/types/internal_invoices.js +1 -0
- package/esm/schemas/types/internal_leads.js +1 -0
- package/esm/schemas/types/internal_operational_roles.js +16 -0
- package/esm/schemas/types/internal_staffs.js +1 -0
- package/esm/schemas/types/inventories.js +1 -0
- package/esm/schemas/types/inventory_categories.js +1 -0
- package/esm/schemas/types/inventory_department_transactions.js +1 -0
- package/esm/schemas/types/inventory_department_utilities.js +1 -0
- package/esm/schemas/types/inventory_departments.js +1 -0
- package/esm/schemas/types/inventory_transactions.js +1 -0
- package/esm/schemas/types/item_transactions.js +1 -0
- package/esm/schemas/types/items.js +1 -0
- package/esm/schemas/types/marketing_fingerprints.js +1 -0
- package/esm/schemas/types/menus.js +1 -0
- package/esm/schemas/types/messaging_devices.js +1 -0
- package/esm/schemas/types/modifier_extras.js +1 -0
- package/esm/schemas/types/multi_tenants.js +1 -0
- package/esm/schemas/types/offers.js +1 -0
- package/esm/schemas/types/offers_fingerprints.js +1 -0
- package/esm/schemas/types/operational_roles.js +15 -0
- package/esm/schemas/types/orders.js +1 -0
- package/esm/schemas/types/printer_settings.js +1 -0
- package/esm/schemas/types/public_holidays.js +1 -0
- package/esm/schemas/types/reservations.js +1 -0
- package/esm/schemas/types/reviews.js +1 -0
- package/esm/schemas/types/rewards_usage.js +1 -0
- package/esm/schemas/types/riders.js +1 -0
- package/esm/schemas/types/specials.js +1 -0
- package/esm/schemas/types/staff_shifts.js +1 -0
- package/esm/schemas/types/tenant-activity-logs.js +1 -0
- package/esm/schemas/types/tenant_active_jobs.js +1 -0
- package/esm/schemas/types/tenant_calendar.js +1 -0
- package/esm/schemas/types/tenant_cash_drawer_sessions.js +1 -0
- package/esm/schemas/types/tenant_cash_drawers.js +1 -0
- package/esm/schemas/types/tenant_cash_in_hand_transactions.js +1 -0
- package/esm/schemas/types/tenant_cash_in_out.js +1 -0
- package/esm/schemas/types/tenant_clients.js +1 -0
- package/esm/schemas/types/tenant_day_sessions.js +1 -0
- package/esm/schemas/types/tenant_hr_attendance_records.js +1 -0
- package/esm/schemas/types/tenant_hr_biometric_enrollments.js +1 -0
- package/esm/schemas/types/tenant_hr_departments.js +1 -0
- package/esm/schemas/types/tenant_hr_documents.js +1 -0
- package/esm/schemas/types/tenant_hr_employees.js +1 -0
- package/esm/schemas/types/tenant_hr_leave_requests.js +1 -0
- package/esm/schemas/types/tenant_hr_payrolls.js +1 -0
- package/esm/schemas/types/tenant_hr_performance_reviews.js +1 -0
- package/esm/schemas/types/tenant_hr_policies.js +1 -0
- package/esm/schemas/types/tenant_hr_positions.js +1 -0
- package/esm/schemas/types/tenant_hr_shift_schedules.js +1 -0
- package/esm/schemas/types/tenant_hr_shifts.js +1 -0
- package/esm/schemas/types/tenant_instore_shift_sessions.js +1 -0
- package/esm/schemas/types/tenant_instore_shifts.js +1 -0
- package/esm/schemas/types/tenant_inventory_entries.js +1 -0
- package/esm/schemas/types/tenant_metadata.js +1 -0
- package/esm/schemas/types/tenant_order_item_instructions.js +1 -0
- package/esm/schemas/types/tenant_purchase_order_vendor_returns.js +1 -0
- package/esm/schemas/types/tenant_purchase_orders.js +1 -0
- package/esm/schemas/types/tenant_shifts.js +1 -0
- package/esm/schemas/types/tenant_staffs.js +1 -0
- package/esm/schemas/types/tenant_vendors.js +1 -0
- package/esm/schemas/types/tenants.js +1 -0
- package/esm/schemas/types/terminal_devices.js +1 -0
- package/esm/schemas/types/tokens.js +1 -0
- package/esm/schemas/types/track_order_numbers.js +1 -0
- package/esm/schemas/types/void_order_items.js +1 -0
- package/esm/schemas/types/vouchers.js +1 -0
- package/esm/schemas/types/wallet_transactions.js +1 -0
- package/esm/schemas/types/wallets.js +1 -0
- package/esm/schemas/types/warehouse-activity-logs.js +1 -0
- package/esm/schemas/types/warehouse_categories.js +1 -0
- package/esm/schemas/types/warehouse_clients.js +1 -0
- package/esm/schemas/types/warehouse_communications.js +1 -0
- package/esm/schemas/types/warehouse_internal_movements.js +1 -0
- package/esm/schemas/types/warehouse_inventory_entries.js +1 -0
- package/esm/schemas/types/warehouse_inventory_lot_serial_numbers.js +1 -0
- package/esm/schemas/types/warehouse_inventory_transactions.js +1 -0
- package/esm/schemas/types/warehouse_item_transactions.js +1 -0
- package/esm/schemas/types/warehouse_items.js +1 -0
- package/esm/schemas/types/warehouse_operational_roles.js +15 -0
- package/esm/schemas/types/warehouse_purchase_order_receipts.js +18 -0
- package/esm/schemas/types/warehouse_purchase_order_rfqs.js +1 -0
- package/esm/schemas/types/warehouse_purchase_order_vendor_returns.js +1 -0
- package/esm/schemas/types/warehouse_purchase_orders.js +1 -0
- package/esm/schemas/types/warehouse_sale_deliveries.js +1 -0
- package/esm/schemas/types/warehouse_sale_invoices.js +1 -0
- package/esm/schemas/types/warehouse_sale_order_rfqs.js +1 -0
- package/esm/schemas/types/warehouse_sale_orders.js +1 -0
- package/esm/schemas/types/warehouse_staffs.js +1 -0
- package/esm/schemas/types/warehouse_track_order_numbers.js +1 -0
- package/esm/schemas/types/warehouse_vendors.js +1 -0
- package/esm/schemas/types/warehouse_void_purchase_order_items.js +1 -0
- package/esm/schemas/types/warehouse_void_sale_order_items.js +1 -0
- package/esm/schemas/types/warehouses.js +1 -0
- package/lib/helpers/utils/order-engine.js +6 -1
- package/lib/tests/soldout-option-default-guard.test.d.ts +1 -0
- package/lib/tests/soldout-option-default-guard.test.js +126 -0
- package/package.json +6 -3
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import { PhoneNumberUtil } from 'google-libphonenumber';
|
|
2
|
+
import moment from 'moment';
|
|
3
|
+
import { COUNTRY_ALPHA_2_ENUM, SUBSCRIPTION_STATUS_ENUM, TAX_INVOICE_PROVIDER_ENUM, } from '../../constants';
|
|
4
|
+
import { convertPriceFromCents } from './price-conversion';
|
|
5
|
+
import { getTenantTime } from './time-helpers';
|
|
6
|
+
export const phoneUtil = PhoneNumberUtil.getInstance();
|
|
7
|
+
export function getNationalNumberFromPhone(phoneNumber, region) {
|
|
8
|
+
let phone = null;
|
|
9
|
+
try {
|
|
10
|
+
phone = phoneUtil.parse(phoneNumber, region).getNationalNumber();
|
|
11
|
+
if (phone != null) {
|
|
12
|
+
phone = `0${phone.toString()}`;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
catch (e) {
|
|
16
|
+
phone = null;
|
|
17
|
+
}
|
|
18
|
+
return phone;
|
|
19
|
+
}
|
|
20
|
+
export function getIntNumberFromPhone(phoneNumber, region) {
|
|
21
|
+
let phone = null;
|
|
22
|
+
try {
|
|
23
|
+
const parsedPhone = phoneUtil.parse(phoneNumber, region);
|
|
24
|
+
phone = `${parsedPhone.getCountryCode() ?? ''}${parsedPhone.getNationalNumber() ?? ''}`;
|
|
25
|
+
if (phone) {
|
|
26
|
+
phone = `+${phone}`;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
phone = null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
phone = null;
|
|
34
|
+
}
|
|
35
|
+
return phone;
|
|
36
|
+
}
|
|
37
|
+
export function getCountryCodeFromPhone(phoneNumber) {
|
|
38
|
+
try {
|
|
39
|
+
return phoneUtil.parse(phoneNumber).getCountryCode();
|
|
40
|
+
}
|
|
41
|
+
catch (e) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// ==============================>><<==============================
|
|
46
|
+
export function strToNum(str) {
|
|
47
|
+
const numStr = str.replace(/[^\d.-]/g, '');
|
|
48
|
+
return parseFloat(numStr);
|
|
49
|
+
}
|
|
50
|
+
// ==============================>><<==============================
|
|
51
|
+
export function convertHoursToMilli(hours) {
|
|
52
|
+
return hours * 3600000;
|
|
53
|
+
}
|
|
54
|
+
// ==============================>><<==============================
|
|
55
|
+
export function convertMinutesToMilli(minutes) {
|
|
56
|
+
return Math.floor(minutes * 60000);
|
|
57
|
+
}
|
|
58
|
+
// ==============================>><<==============================
|
|
59
|
+
export function convertMilliToMinutes(milliseconds) {
|
|
60
|
+
return Math.floor(milliseconds / 60000);
|
|
61
|
+
}
|
|
62
|
+
// ==============================>><<==============================
|
|
63
|
+
export function convertMilliToTime(milliseconds) {
|
|
64
|
+
let seconds = Math.floor(milliseconds / 1000);
|
|
65
|
+
let minutes = Math.floor(seconds / 60);
|
|
66
|
+
const hours = Math.floor(minutes / 60);
|
|
67
|
+
seconds = seconds % 60;
|
|
68
|
+
minutes = minutes % 60;
|
|
69
|
+
// 👇️ If you don't want to roll hours over, e.g. 24 to 00
|
|
70
|
+
// 👇️ comment (or remove) the line below
|
|
71
|
+
// commenting next line gets you `24:00:00` instead of `00:00:00`
|
|
72
|
+
// or `36:15:31` instead of `12:15:31`, etc.
|
|
73
|
+
// hours = hours % 24;
|
|
74
|
+
return {
|
|
75
|
+
seconds,
|
|
76
|
+
minutes,
|
|
77
|
+
hours,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
// ==============================>><<==============================
|
|
81
|
+
export function getHMS(milliseconds, showSeconds) {
|
|
82
|
+
const date = new Date(milliseconds);
|
|
83
|
+
let hours = date.getUTCHours();
|
|
84
|
+
let minutes = date.getUTCMinutes();
|
|
85
|
+
let seconds = showSeconds ? date.getUTCSeconds() : 0;
|
|
86
|
+
if (hours < 10) {
|
|
87
|
+
hours = '0' + hours;
|
|
88
|
+
}
|
|
89
|
+
if (minutes < 10) {
|
|
90
|
+
minutes = '0' + minutes;
|
|
91
|
+
}
|
|
92
|
+
if (seconds < 10) {
|
|
93
|
+
seconds = '0' + seconds;
|
|
94
|
+
}
|
|
95
|
+
return hours + ':' + minutes + ':' + seconds;
|
|
96
|
+
}
|
|
97
|
+
// ==============================>><<==============================
|
|
98
|
+
export async function fakeDelay(delay = 1000) {
|
|
99
|
+
const promise = new Promise((resolve) => setTimeout(() => resolve(true), delay));
|
|
100
|
+
await Promise.resolve(promise);
|
|
101
|
+
}
|
|
102
|
+
// ==============================>><<==============================
|
|
103
|
+
export const isValidNumber = new RegExp('^-?[0-9|.]*$');
|
|
104
|
+
// ==============================>><<==============================
|
|
105
|
+
export function pxToRem(value) {
|
|
106
|
+
return `${value / 16}rem`;
|
|
107
|
+
}
|
|
108
|
+
// ==============================>><<==============================
|
|
109
|
+
export function titleCase(str) {
|
|
110
|
+
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
|
|
111
|
+
}
|
|
112
|
+
export function sentenceCase(str) {
|
|
113
|
+
return str
|
|
114
|
+
.split(' ')
|
|
115
|
+
.map((word) => titleCase(word))
|
|
116
|
+
.join(' ');
|
|
117
|
+
}
|
|
118
|
+
// ==============================>><<==============================
|
|
119
|
+
// Only use this function when we need to display a number to the user
|
|
120
|
+
// This function will parse the number to 2 decimal places
|
|
121
|
+
export function parseNum(num, abs) {
|
|
122
|
+
// we need to do this because of floating point errors
|
|
123
|
+
// 0.1 + 0.2 = 0.30000000000000004
|
|
124
|
+
// 0.3 * 100 = 30.000000000000004
|
|
125
|
+
const absNum = Math.abs(num) * 100;
|
|
126
|
+
// 30.000000000000004.toFixed(2) = 30.00
|
|
127
|
+
// parseInt("30.00", 10) = 30
|
|
128
|
+
const parsedInt = parseInt(absNum.toFixed(2), 10);
|
|
129
|
+
// 30 / 100 = 0.3
|
|
130
|
+
const parsed = parsedInt / 100;
|
|
131
|
+
if (num < 0 && !abs) {
|
|
132
|
+
return -parsed;
|
|
133
|
+
}
|
|
134
|
+
return parsed;
|
|
135
|
+
}
|
|
136
|
+
// ==============================>><<==============================
|
|
137
|
+
export function countLeadingSpaces(inputString) {
|
|
138
|
+
// Use a regular expression to match leading spaces and count them
|
|
139
|
+
const leadingSpaces = inputString.match(/^\s*/);
|
|
140
|
+
// Check if leadingSpaces is null (no spaces found) and return 0, otherwise return the length
|
|
141
|
+
return leadingSpaces ? leadingSpaces[0].length : 0;
|
|
142
|
+
}
|
|
143
|
+
// ==============================>><<==============================
|
|
144
|
+
export function formatDateToDateTime(date, gmtOffset) {
|
|
145
|
+
const tenantTime = getTenantTime(gmtOffset, new Date(date || new Date()));
|
|
146
|
+
// Convert date to ISO format
|
|
147
|
+
const isoString = tenantTime.toISOString();
|
|
148
|
+
// Extract date and time components
|
|
149
|
+
const datePart = isoString.slice(0, 10);
|
|
150
|
+
const timePart = isoString.slice(11, 19);
|
|
151
|
+
// Combine date and time in the desired format
|
|
152
|
+
// FORMAT: YYYY-MM-DD HH:MM:SS
|
|
153
|
+
const customFormat = `${datePart} ${timePart}`;
|
|
154
|
+
return customFormat;
|
|
155
|
+
}
|
|
156
|
+
// ==============================>><<==============================
|
|
157
|
+
function addThousandsSeparator(value) {
|
|
158
|
+
return value.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
159
|
+
}
|
|
160
|
+
export function formatMoneyAmount(amount) {
|
|
161
|
+
const rounded = parseNum(amount);
|
|
162
|
+
const fixed = Math.abs(rounded).toFixed(2);
|
|
163
|
+
const [integerPart, decimalPart = ''] = fixed.split('.');
|
|
164
|
+
const groupedInteger = addThousandsSeparator(integerPart);
|
|
165
|
+
const trimmedDecimal = decimalPart.replace(/0+$/, '');
|
|
166
|
+
const sign = rounded < 0 ? '-' : '';
|
|
167
|
+
return `${sign}${groupedInteger}${trimmedDecimal ? `.${trimmedDecimal}` : ''}`;
|
|
168
|
+
}
|
|
169
|
+
export function localeAmount(currency, amount) {
|
|
170
|
+
return `${currency ?? ''}${formatMoneyAmount(amount)}`;
|
|
171
|
+
}
|
|
172
|
+
let lastOfflineOrderNumber;
|
|
173
|
+
export const getOfflineOrderNumber = () => {
|
|
174
|
+
if (lastOfflineOrderNumber == null) {
|
|
175
|
+
const timestamp = Date.now(); // Get the current timestamp in milliseconds
|
|
176
|
+
const randomNum = timestamp % 10000; // Get the last 4 digits of the timestamp
|
|
177
|
+
const orderNum = randomNum.toString().padStart(4, '1'); // Pad with leading zeroes if needed
|
|
178
|
+
lastOfflineOrderNumber = parseInt(orderNum, 10);
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
lastOfflineOrderNumber++;
|
|
182
|
+
}
|
|
183
|
+
return lastOfflineOrderNumber;
|
|
184
|
+
};
|
|
185
|
+
// ==============================>><<==============================
|
|
186
|
+
export function sanitizeText(input) {
|
|
187
|
+
// Remove new-line and tab characters
|
|
188
|
+
let sanitized = input.replace(/[\n\t]/g, '');
|
|
189
|
+
// Replace more than 4 consecutive spaces with exactly 4 spaces
|
|
190
|
+
sanitized = sanitized.replace(/ {5,}/g, ' ');
|
|
191
|
+
return sanitized;
|
|
192
|
+
}
|
|
193
|
+
export function getGSTName(country_alpha_2, tax_invoice_provider) {
|
|
194
|
+
let gstName = 'Tax';
|
|
195
|
+
if (country_alpha_2 === COUNTRY_ALPHA_2_ENUM.PK) {
|
|
196
|
+
switch (tax_invoice_provider) {
|
|
197
|
+
case TAX_INVOICE_PROVIDER_ENUM.FBR:
|
|
198
|
+
gstName = 'GST';
|
|
199
|
+
break;
|
|
200
|
+
case TAX_INVOICE_PROVIDER_ENUM.PRA:
|
|
201
|
+
gstName = 'PST';
|
|
202
|
+
break;
|
|
203
|
+
case TAX_INVOICE_PROVIDER_ENUM.SRB:
|
|
204
|
+
gstName = 'SST';
|
|
205
|
+
break;
|
|
206
|
+
case TAX_INVOICE_PROVIDER_ENUM.KPRA:
|
|
207
|
+
gstName = 'Tax';
|
|
208
|
+
break;
|
|
209
|
+
default:
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
else if (country_alpha_2 === COUNTRY_ALPHA_2_ENUM.AE) {
|
|
214
|
+
gstName = 'VAT';
|
|
215
|
+
}
|
|
216
|
+
else if (country_alpha_2 === COUNTRY_ALPHA_2_ENUM.CA) {
|
|
217
|
+
gstName = 'HST';
|
|
218
|
+
}
|
|
219
|
+
else if (country_alpha_2 === COUNTRY_ALPHA_2_ENUM.US) {
|
|
220
|
+
gstName = 'Sales Tax';
|
|
221
|
+
}
|
|
222
|
+
else if (country_alpha_2 === COUNTRY_ALPHA_2_ENUM.GB) {
|
|
223
|
+
gstName = 'VAT';
|
|
224
|
+
}
|
|
225
|
+
else if (country_alpha_2 === COUNTRY_ALPHA_2_ENUM.AU) {
|
|
226
|
+
gstName = 'GST';
|
|
227
|
+
}
|
|
228
|
+
else if (country_alpha_2 === COUNTRY_ALPHA_2_ENUM.NZ) {
|
|
229
|
+
gstName = 'GST';
|
|
230
|
+
}
|
|
231
|
+
else if (country_alpha_2 === COUNTRY_ALPHA_2_ENUM.AF) {
|
|
232
|
+
gstName = 'VAT';
|
|
233
|
+
}
|
|
234
|
+
else if (country_alpha_2 === COUNTRY_ALPHA_2_ENUM.ES) {
|
|
235
|
+
gstName = 'IVA';
|
|
236
|
+
}
|
|
237
|
+
return gstName;
|
|
238
|
+
}
|
|
239
|
+
export function getTaxNumberTitle(country_alpha_2, tax_invoice_provider) {
|
|
240
|
+
let title = 'Tax Number';
|
|
241
|
+
if (country_alpha_2 === COUNTRY_ALPHA_2_ENUM.PK) {
|
|
242
|
+
switch (tax_invoice_provider) {
|
|
243
|
+
case TAX_INVOICE_PROVIDER_ENUM.FBR:
|
|
244
|
+
title = 'NTN';
|
|
245
|
+
break;
|
|
246
|
+
case TAX_INVOICE_PROVIDER_ENUM.PRA:
|
|
247
|
+
title = 'P-NTN';
|
|
248
|
+
break;
|
|
249
|
+
case TAX_INVOICE_PROVIDER_ENUM.SRB:
|
|
250
|
+
title = 'S-NTN';
|
|
251
|
+
break;
|
|
252
|
+
case TAX_INVOICE_PROVIDER_ENUM.KPRA:
|
|
253
|
+
title = 'K-NTN';
|
|
254
|
+
break;
|
|
255
|
+
default:
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
else if (country_alpha_2 === COUNTRY_ALPHA_2_ENUM.AE) {
|
|
260
|
+
title = 'TRN';
|
|
261
|
+
}
|
|
262
|
+
else if (country_alpha_2 === COUNTRY_ALPHA_2_ENUM.ES) {
|
|
263
|
+
title = 'NIF';
|
|
264
|
+
}
|
|
265
|
+
return title;
|
|
266
|
+
}
|
|
267
|
+
// ==============================>><<==============================
|
|
268
|
+
export function getFormattedCancellationReason(reason) {
|
|
269
|
+
if (!reason)
|
|
270
|
+
return;
|
|
271
|
+
return reason.replace(/(Cancelled at )(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z)/, (_, prefix, date) => `${prefix}${moment(date).format('lll')}`);
|
|
272
|
+
}
|
|
273
|
+
export const formatAmount = (currencySymbol, amount) => localeAmount(currencySymbol, convertPriceFromCents(amount));
|
|
274
|
+
export const getSubscriptionStatus = (subscription_expiry) => {
|
|
275
|
+
let subscriptionStatus = SUBSCRIPTION_STATUS_ENUM.ACTIVE;
|
|
276
|
+
if (subscription_expiry != null) {
|
|
277
|
+
const subscriptionExpiryTime = new Date(subscription_expiry).getTime();
|
|
278
|
+
const today = new Date();
|
|
279
|
+
const now = today.getTime();
|
|
280
|
+
// Check if subscription has expired
|
|
281
|
+
if (now > subscriptionExpiryTime) {
|
|
282
|
+
const threeDaysAgo = new Date();
|
|
283
|
+
threeDaysAgo.setDate(threeDaysAgo.getDate() - 3);
|
|
284
|
+
const threeDaysAgoTime = threeDaysAgo.getTime();
|
|
285
|
+
// Check if subscription expiry was within the last 3 days
|
|
286
|
+
if (subscriptionExpiryTime < threeDaysAgoTime) {
|
|
287
|
+
subscriptionStatus = SUBSCRIPTION_STATUS_ENUM.EXPIRED;
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
subscriptionStatus = SUBSCRIPTION_STATUS_ENUM.PENDING;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
subscriptionStatus = SUBSCRIPTION_STATUS_ENUM.DUE_SOON;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return subscriptionStatus;
|
|
298
|
+
};
|
|
299
|
+
export function formattedStoreName(name) {
|
|
300
|
+
return name?.replace(/^\d+\.\s*/, '') ?? '';
|
|
301
|
+
}
|
|
302
|
+
export const formatFieldName = (field) => {
|
|
303
|
+
return sentenceCase(field
|
|
304
|
+
.replace(/^item/i, '')
|
|
305
|
+
.replace(/([A-Z])/g, ' $1')
|
|
306
|
+
.replace(/^./, (c) => c.toUpperCase())
|
|
307
|
+
.trim());
|
|
308
|
+
};
|
|
309
|
+
export function getPercentage(total, num) {
|
|
310
|
+
if (!total)
|
|
311
|
+
return 0;
|
|
312
|
+
const newNum = total - num;
|
|
313
|
+
const percent = (newNum / total) * 100;
|
|
314
|
+
const actualPercent = 100 - percent;
|
|
315
|
+
return actualPercent;
|
|
316
|
+
}
|
|
317
|
+
export function getPercentageAmount(total, percent) {
|
|
318
|
+
return (total * percent) / 100;
|
|
319
|
+
}
|
|
320
|
+
export function getCappedOfferDiscountAmount({ baseAmount, discountValue, isDiscountPercentage, maxDiscountAmount, maxDiscountPercentage, }) {
|
|
321
|
+
const normalizedBaseAmount = Number.isFinite(baseAmount) ? Math.max(0, baseAmount) : 0;
|
|
322
|
+
const normalizedDiscountValue = Number.isFinite(discountValue) ? Math.max(0, discountValue) : 0;
|
|
323
|
+
if (normalizedBaseAmount <= 0 || normalizedDiscountValue <= 0) {
|
|
324
|
+
return 0;
|
|
325
|
+
}
|
|
326
|
+
if (isDiscountPercentage) {
|
|
327
|
+
let amount = getPercentageAmount(normalizedBaseAmount, normalizedDiscountValue);
|
|
328
|
+
if (maxDiscountAmount != null && Number.isFinite(maxDiscountAmount) && maxDiscountAmount >= 0) {
|
|
329
|
+
amount = Math.min(amount, maxDiscountAmount);
|
|
330
|
+
}
|
|
331
|
+
return Math.min(amount, normalizedBaseAmount);
|
|
332
|
+
}
|
|
333
|
+
let amount = normalizedDiscountValue;
|
|
334
|
+
if (maxDiscountPercentage != null && Number.isFinite(maxDiscountPercentage) && maxDiscountPercentage >= 0) {
|
|
335
|
+
const maxAmountFromPercentage = getPercentageAmount(normalizedBaseAmount, maxDiscountPercentage);
|
|
336
|
+
amount = Math.min(amount, maxAmountFromPercentage);
|
|
337
|
+
}
|
|
338
|
+
return Math.min(amount, normalizedBaseAmount);
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Calculate the eligible subtotal by excluding items/categories in excluded_refs.
|
|
342
|
+
*
|
|
343
|
+
* Shared by the cart engine (discount application/re-sync) and the offer-stats
|
|
344
|
+
* engine (spend qualification) so both use the exact same exclusion math.
|
|
345
|
+
*/
|
|
346
|
+
export function calculateEligibleOfferDiscountDetails(categories, excluded_refs) {
|
|
347
|
+
if (!categories?.length)
|
|
348
|
+
return { subtotal: 0, hasExcludedRefs: false };
|
|
349
|
+
let eligibleSubtotal = 0;
|
|
350
|
+
let hasExcludedRefs = false;
|
|
351
|
+
for (const category of categories) {
|
|
352
|
+
// Skip entire category if it's in excluded_refs
|
|
353
|
+
if (excluded_refs.includes(category.category_id)) {
|
|
354
|
+
hasExcludedRefs = true;
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
// Otherwise, check each item
|
|
358
|
+
for (const item of category.items ?? []) {
|
|
359
|
+
if (excluded_refs.includes(item.item_id)) {
|
|
360
|
+
hasExcludedRefs = true;
|
|
361
|
+
}
|
|
362
|
+
else {
|
|
363
|
+
eligibleSubtotal += item.subtotal ?? 0;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
return { subtotal: eligibleSubtotal, hasExcludedRefs };
|
|
368
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import CryptoJS from 'crypto-js';
|
|
2
|
+
export function getEncryptionKey(key) {
|
|
3
|
+
const desiredKeyLength = 32; // 256 bits
|
|
4
|
+
if (key.length < desiredKeyLength) {
|
|
5
|
+
// Pad the key with zeros if it's too short
|
|
6
|
+
return key.padEnd(desiredKeyLength, '\0');
|
|
7
|
+
}
|
|
8
|
+
else if (key.length > desiredKeyLength) {
|
|
9
|
+
// Truncate the key if it's too long
|
|
10
|
+
return key.slice(0, desiredKeyLength);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
// Key length is already correct
|
|
14
|
+
return key;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export function encryptSecret(text, ENCRYPTION_KEY) {
|
|
18
|
+
const iv = CryptoJS.lib.WordArray.random(16);
|
|
19
|
+
const cipherText = CryptoJS.AES.encrypt(text, ENCRYPTION_KEY, { iv });
|
|
20
|
+
return iv.toString(CryptoJS.enc.Hex) + ':' + cipherText.toString();
|
|
21
|
+
}
|
|
22
|
+
export function decryptSecret(text, ENCRYPTION_KEY) {
|
|
23
|
+
const textParts = text.split(':');
|
|
24
|
+
const iv = CryptoJS.enc.Hex.parse(textParts.shift() || '');
|
|
25
|
+
const encryptedText = textParts.join(':');
|
|
26
|
+
const decrypted = CryptoJS.AES.decrypt(encryptedText, ENCRYPTION_KEY, {
|
|
27
|
+
iv,
|
|
28
|
+
});
|
|
29
|
+
return decrypted.toString(CryptoJS.enc.Utf8);
|
|
30
|
+
}
|
|
31
|
+
export function getPublicApiToken(providerId, ENCRYPTION_KEY) {
|
|
32
|
+
const dateStr = new Date().toISOString();
|
|
33
|
+
const payload = {
|
|
34
|
+
providerId,
|
|
35
|
+
signature: 'public',
|
|
36
|
+
timestamp: dateStr,
|
|
37
|
+
};
|
|
38
|
+
const token = encryptSecret(JSON.stringify(payload), ENCRYPTION_KEY);
|
|
39
|
+
return token;
|
|
40
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { convertPriceFromCents, convertPriceToCents } from './price-conversion';
|
|
2
|
+
export function getCustomerWithPrice(customer, writeable) {
|
|
3
|
+
const convertToNum = writeable ? convertPriceToCents : convertPriceFromCents;
|
|
4
|
+
return {
|
|
5
|
+
...customer,
|
|
6
|
+
cashback_balance: customer.cashback_balance != null ? convertToNum(customer.cashback_balance) : 0,
|
|
7
|
+
total_spent: customer.total_spent != null ? convertToNum(customer.total_spent) : 0,
|
|
8
|
+
total_spent_per_platform_type: customer.total_spent_per_platform_type != null
|
|
9
|
+
? Object.keys(customer.total_spent_per_platform_type).reduce((acc, key) => {
|
|
10
|
+
acc[key] = convertToNum(customer.total_spent_per_platform_type[key]);
|
|
11
|
+
return acc;
|
|
12
|
+
}, {})
|
|
13
|
+
: null,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { convertPriceFromCents, convertPriceToCents } from './price-conversion';
|
|
2
|
+
export function convertOrderFromPriceToCents(priceObj) {
|
|
3
|
+
if (!priceObj)
|
|
4
|
+
return null;
|
|
5
|
+
// check if all prices in price are 0, if so return null
|
|
6
|
+
else if (Object.values(priceObj).every((price) => price === 0))
|
|
7
|
+
return null;
|
|
8
|
+
// step 2: check if all the platform values are the same
|
|
9
|
+
// if they are, return BASE_PRICE
|
|
10
|
+
else if (Object.values(priceObj).every((price) => price === priceObj.BASE_PRICE)) {
|
|
11
|
+
return { BASE_PRICE: convertPriceToCents(priceObj.BASE_PRICE) };
|
|
12
|
+
}
|
|
13
|
+
const priceObjInCents = {};
|
|
14
|
+
for (const key in priceObj) {
|
|
15
|
+
if (key !== 'BASE_PRICE' && priceObj[key] === priceObj.BASE_PRICE) {
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
priceObjInCents[key] = convertPriceToCents(priceObj[key]);
|
|
19
|
+
}
|
|
20
|
+
return priceObjInCents;
|
|
21
|
+
}
|
|
22
|
+
export function convertOrderFromPriceFromCents(priceObj) {
|
|
23
|
+
if (!priceObj)
|
|
24
|
+
return null;
|
|
25
|
+
const keys = Object.keys(priceObj);
|
|
26
|
+
return keys.reduce((obj, key) => ({ ...obj, [key]: convertPriceFromCents(priceObj[key]) }), {});
|
|
27
|
+
}
|
|
28
|
+
export function getDeliveryAreaWithPrice(deliveryArea, writeable) {
|
|
29
|
+
const convertOrderFromNum = writeable ? convertOrderFromPriceToCents : convertOrderFromPriceFromCents;
|
|
30
|
+
return {
|
|
31
|
+
...deliveryArea,
|
|
32
|
+
...(deliveryArea.min_order_value != null
|
|
33
|
+
? { min_order_value: convertOrderFromNum(deliveryArea.min_order_value) }
|
|
34
|
+
: {}),
|
|
35
|
+
...(deliveryArea.delivery_charges != null
|
|
36
|
+
? { delivery_charges: convertOrderFromNum(deliveryArea.delivery_charges) }
|
|
37
|
+
: {}),
|
|
38
|
+
...(deliveryArea.delivery_free_over != null
|
|
39
|
+
? { delivery_free_over: convertOrderFromNum(deliveryArea.delivery_free_over) }
|
|
40
|
+
: {}),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import moment from 'moment';
|
|
2
|
+
import { DELIVERY_STATUS_ENUM } from '../../constants';
|
|
3
|
+
import { convertPriceFromCents, convertPriceToCents } from './price-conversion';
|
|
4
|
+
export function getDeliveryWithPrice(delivery, writeable) {
|
|
5
|
+
const convertToPrice = writeable ? convertPriceToCents : convertPriceFromCents;
|
|
6
|
+
return {
|
|
7
|
+
...delivery,
|
|
8
|
+
...(delivery.rider_revenue != null
|
|
9
|
+
? {
|
|
10
|
+
rider_revenue: convertToPrice(delivery.rider_revenue ?? 0),
|
|
11
|
+
}
|
|
12
|
+
: {}),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/** Distance-based fallback: 0 m -> 25 minutes; otherwise prep minutes + 2 minutes per km. */
|
|
16
|
+
const FALLBACK_ZERO_DISTANCE_MINUTES = 25;
|
|
17
|
+
const FALLBACK_MINUTES_PER_KM = 2;
|
|
18
|
+
/**
|
|
19
|
+
* Calculate the expected delivery time for a delivery order.
|
|
20
|
+
*
|
|
21
|
+
* Priority:
|
|
22
|
+
* 1. `order.delivery_details.estimated_delivery_time` - the promised ETA.
|
|
23
|
+
* 2. ASAP orders (null ETA): `createdAt` + the tenant's default `delivery_time` in milliseconds -
|
|
24
|
+
* the same value used as `now + delivery_time` when the order is punched.
|
|
25
|
+
* 3. Distance-based fallback (only when the tenant setting is unavailable): travel time at
|
|
26
|
+
* 2 minutes per km plus the tenant's default `default_prep_minutes`; a flat 25 minutes when
|
|
27
|
+
* the distance is unknown (0 m).
|
|
28
|
+
*
|
|
29
|
+
* @param deliveryTimeMs Tenant's default `delivery_time` settings value, in milliseconds.
|
|
30
|
+
* @param prepMinutes Tenant's default `default_prep_minutes` settings value, in minutes - added
|
|
31
|
+
* to the distance-based travel estimate.
|
|
32
|
+
*/
|
|
33
|
+
export const getDeliveryExpectedTime = (delivery, deliveryTimeMs, prepMinutes) => {
|
|
34
|
+
const expectedTimeValue = delivery.order?.delivery_details?.estimated_delivery_time;
|
|
35
|
+
if (expectedTimeValue) {
|
|
36
|
+
return { expectedTime: moment(expectedTimeValue), isCalculated: false };
|
|
37
|
+
}
|
|
38
|
+
const createdAt = moment(delivery.createdAt);
|
|
39
|
+
// ASAP case: same value used when punching the order (now + delivery_time).
|
|
40
|
+
if (deliveryTimeMs != null && deliveryTimeMs > 0) {
|
|
41
|
+
return { expectedTime: createdAt.clone().add(deliveryTimeMs, 'milliseconds'), isCalculated: true };
|
|
42
|
+
}
|
|
43
|
+
const distanceInMeters = delivery.order?.delivery_details?.distance_in_meters_from_store || 0;
|
|
44
|
+
const prepOffsetMinutes = prepMinutes != null && prepMinutes > 0 ? prepMinutes : 0;
|
|
45
|
+
const deliveryMinutes = distanceInMeters === 0
|
|
46
|
+
? FALLBACK_ZERO_DISTANCE_MINUTES
|
|
47
|
+
: prepOffsetMinutes + (distanceInMeters / 1000) * FALLBACK_MINUTES_PER_KM;
|
|
48
|
+
return { expectedTime: createdAt.clone().add(deliveryMinutes, 'minutes'), isCalculated: true };
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Completion tag for a finished delivery, based on how `updatedAt` (treated as the completion
|
|
52
|
+
* time) compares to the expected delivery time from `getDeliveryExpectedTime`.
|
|
53
|
+
*
|
|
54
|
+
* - Completed at least 1 minute before the expected time -> "Good" (success).
|
|
55
|
+
* - Completed within 1 minute of the expected time -> "Slight Delay" (warning).
|
|
56
|
+
* - Completed more than 1 minute after the expected time -> "Late" (error).
|
|
57
|
+
*
|
|
58
|
+
* `completionTime` is the total delivery duration (`updatedAt` - `createdAt`) formatted as
|
|
59
|
+
* `Xm` or `Xh Ym`. Returns `null` for deliveries that are not completed.
|
|
60
|
+
*
|
|
61
|
+
* @param deliveryTimeMs Tenant's default `delivery_time` settings value, in milliseconds.
|
|
62
|
+
* @param prepMinutes Tenant's default `default_prep_minutes` settings value, in minutes.
|
|
63
|
+
*/
|
|
64
|
+
export const getDeliveryCompletionTag = (delivery, deliveryTimeMs, prepMinutes) => {
|
|
65
|
+
if (delivery.status !== DELIVERY_STATUS_ENUM.COMPLETED)
|
|
66
|
+
return null;
|
|
67
|
+
const completedAt = moment(delivery.updatedAt);
|
|
68
|
+
const createdAt = moment(delivery.createdAt);
|
|
69
|
+
const { expectedTime } = getDeliveryExpectedTime(delivery, deliveryTimeMs, prepMinutes);
|
|
70
|
+
const diffMinutes = completedAt.diff(expectedTime, 'minutes');
|
|
71
|
+
const totalSeconds = completedAt.diff(createdAt, 'seconds');
|
|
72
|
+
const hours = Math.floor(totalSeconds / 3600);
|
|
73
|
+
const minutes = Math.floor((totalSeconds % 3600) / 60);
|
|
74
|
+
const completionTime = hours > 0 ? `${hours}h ${minutes}m` : `${minutes}m`;
|
|
75
|
+
if (diffMinutes <= -1) {
|
|
76
|
+
// Completed before expected time by at least 1 minute.
|
|
77
|
+
return { label: 'Good', color: 'success', completionTime };
|
|
78
|
+
}
|
|
79
|
+
else if (diffMinutes <= 1) {
|
|
80
|
+
// Completed within 1 minute of expected time.
|
|
81
|
+
return { label: 'Slight Delay', color: 'warning', completionTime };
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
// Completed after expected time by more than 1 minute.
|
|
85
|
+
return { label: 'Late', color: 'error', completionTime };
|
|
86
|
+
}
|
|
87
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { convertPriceFromCents, convertPriceToCents } from './price-conversion';
|
|
2
|
+
/**
|
|
3
|
+
* Converts the keys of a denominations map from cents to dollars
|
|
4
|
+
* (e.g. 1 -> "0.01", 100 -> "1"). Keys are monetary denomination values;
|
|
5
|
+
* the values (bill/coin counts) are left unchanged. NaN entries are ignored.
|
|
6
|
+
*/
|
|
7
|
+
export function getDenominationsFromCents(denominations) {
|
|
8
|
+
return Object.entries(denominations).reduce((acc, [denomination, count]) => {
|
|
9
|
+
const denominationValue = Number(denomination);
|
|
10
|
+
if (Number.isNaN(denominationValue) || Number.isNaN(count)) {
|
|
11
|
+
return acc;
|
|
12
|
+
}
|
|
13
|
+
const dollars = Math.round((denominationValue / 100) * 100) / 100;
|
|
14
|
+
acc[String(dollars)] = count;
|
|
15
|
+
return acc;
|
|
16
|
+
}, {});
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Converts the values of a denominations array from cents to dollars
|
|
20
|
+
* (e.g. [1, 5, 10, 25, 100] -> [0.01, 0.05, 0.1, 0.25, 1]).
|
|
21
|
+
* NaN entries are ignored.
|
|
22
|
+
*/
|
|
23
|
+
export function getDenominationsArrayFromCents(denominations) {
|
|
24
|
+
return denominations
|
|
25
|
+
.map((denomination) => convertPriceFromCents(denomination))
|
|
26
|
+
.filter((denomination) => !Number.isNaN(denomination));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Converts the keys of a denominations map from dollars to integer cents
|
|
30
|
+
* (e.g. "0.01" -> 1, "1" -> 100). Keys are monetary denomination values;
|
|
31
|
+
* the values (bill/coin counts) are left unchanged. NaN entries are ignored.
|
|
32
|
+
*/
|
|
33
|
+
export function getDenominationsWithCents(denominations) {
|
|
34
|
+
return Object.entries(denominations).reduce((acc, [denomination, count]) => {
|
|
35
|
+
const denominationValue = Number(denomination);
|
|
36
|
+
if (Number.isNaN(denominationValue) || Number.isNaN(count)) {
|
|
37
|
+
return acc;
|
|
38
|
+
}
|
|
39
|
+
const cents = Math.round(denominationValue * 100);
|
|
40
|
+
acc[String(cents)] = count;
|
|
41
|
+
return acc;
|
|
42
|
+
}, {});
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Converts the values of a denominations array from dollars to integer cents
|
|
46
|
+
* (e.g. [0.01, 0.05, 0.1, 0.25, 1] -> [1, 5, 10, 25, 100]).
|
|
47
|
+
* NaN entries are ignored.
|
|
48
|
+
*/
|
|
49
|
+
export function getDenominationsArrayWithCents(denominations) {
|
|
50
|
+
return denominations
|
|
51
|
+
.map((denomination) => convertPriceToCents(denomination))
|
|
52
|
+
.filter((denomination) => !Number.isNaN(denomination));
|
|
53
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import ObjectID from 'bson-objectid';
|
|
2
|
+
import { TABLE_TYPE_ENUM } from '../../constants';
|
|
3
|
+
export const generateTable = ({ table_type, dinein_floor_id, num_of_seats, tenant_id, }) => {
|
|
4
|
+
let name = num_of_seats.toString();
|
|
5
|
+
if (table_type === TABLE_TYPE_ENUM.PLANT) {
|
|
6
|
+
num_of_seats = 0;
|
|
7
|
+
name = '';
|
|
8
|
+
}
|
|
9
|
+
const _id = ObjectID().toHexString();
|
|
10
|
+
return {
|
|
11
|
+
_id,
|
|
12
|
+
dinein_floor_id,
|
|
13
|
+
order_id: null,
|
|
14
|
+
name,
|
|
15
|
+
num_of_guests: 0,
|
|
16
|
+
table_type,
|
|
17
|
+
scale: 1,
|
|
18
|
+
angle: 0,
|
|
19
|
+
position: [10, 10],
|
|
20
|
+
num_of_seats,
|
|
21
|
+
tenant_id,
|
|
22
|
+
order_placed_at: null,
|
|
23
|
+
seated_at: null,
|
|
24
|
+
createdAt: new Date(),
|
|
25
|
+
updatedAt: new Date(),
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export const generateFloor = (name, tenant_id) => {
|
|
29
|
+
const _id = ObjectID().toHexString();
|
|
30
|
+
return {
|
|
31
|
+
_id,
|
|
32
|
+
name,
|
|
33
|
+
tenant_id,
|
|
34
|
+
active: true,
|
|
35
|
+
sort_id: 0,
|
|
36
|
+
createdAt: new Date(),
|
|
37
|
+
updatedAt: new Date(),
|
|
38
|
+
};
|
|
39
|
+
};
|