@managesome/eposmatic-toolkit 0.3.8 → 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/package.json +6 -3
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { convertPriceFromCents, convertPriceToCents } from './price-conversion';
|
|
2
|
+
export function getWalletTransaction(transaction, toCents) {
|
|
3
|
+
const convertToPrice = toCents ? convertPriceToCents : convertPriceFromCents;
|
|
4
|
+
return {
|
|
5
|
+
...transaction,
|
|
6
|
+
...(typeof transaction.previous_balance === 'number'
|
|
7
|
+
? {
|
|
8
|
+
previous_balance: convertToPrice(transaction.previous_balance),
|
|
9
|
+
}
|
|
10
|
+
: {}),
|
|
11
|
+
...(typeof transaction.transaction_amount === 'number'
|
|
12
|
+
? {
|
|
13
|
+
transaction_amount: convertToPrice(transaction.transaction_amount),
|
|
14
|
+
}
|
|
15
|
+
: {}),
|
|
16
|
+
...(typeof transaction.running_balance === 'number'
|
|
17
|
+
? {
|
|
18
|
+
running_balance: convertToPrice(transaction.running_balance),
|
|
19
|
+
}
|
|
20
|
+
: {}),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export function getWalletGiftCardRedemptionClaims(walletGiftCardRedemptions) {
|
|
2
|
+
const normalizedWalletGiftCardRedemptions = Array.isArray(walletGiftCardRedemptions)
|
|
3
|
+
? walletGiftCardRedemptions
|
|
4
|
+
: walletGiftCardRedemptions != null
|
|
5
|
+
? [walletGiftCardRedemptions]
|
|
6
|
+
: [];
|
|
7
|
+
const claimsByGiftCardId = {};
|
|
8
|
+
for (let i = 0; i < normalizedWalletGiftCardRedemptions.length; i++) {
|
|
9
|
+
const walletGiftCardRedemption = normalizedWalletGiftCardRedemptions[i];
|
|
10
|
+
const giftCardId = walletGiftCardRedemption.gift_card_id?.trim();
|
|
11
|
+
const redeemedTimes = Number(walletGiftCardRedemption.redeemed_times ?? walletGiftCardRedemption.value_redeemed ?? 0);
|
|
12
|
+
if (giftCardId == null || giftCardId.length === 0 || !Number.isFinite(redeemedTimes) || redeemedTimes <= 0) {
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
const existingClaim = claimsByGiftCardId[giftCardId];
|
|
16
|
+
claimsByGiftCardId[giftCardId] = {
|
|
17
|
+
gift_card_id: giftCardId,
|
|
18
|
+
redeemed_times: (existingClaim?.redeemed_times ?? 0) + Math.floor(redeemedTimes),
|
|
19
|
+
...(walletGiftCardRedemption.mystery_gift_type != null
|
|
20
|
+
? {
|
|
21
|
+
mystery_gift_type: walletGiftCardRedemption.mystery_gift_type,
|
|
22
|
+
}
|
|
23
|
+
: existingClaim?.mystery_gift_type != null
|
|
24
|
+
? {
|
|
25
|
+
mystery_gift_type: existingClaim.mystery_gift_type,
|
|
26
|
+
}
|
|
27
|
+
: {}),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return Object.values(claimsByGiftCardId);
|
|
31
|
+
}
|
|
32
|
+
export function buildWalletGiftCardRedemptionCompatPayload({ currentWalletGiftCardRedemptions, nextWalletGiftCardClaims, }) {
|
|
33
|
+
if (Array.isArray(currentWalletGiftCardRedemptions)) {
|
|
34
|
+
return nextWalletGiftCardClaims;
|
|
35
|
+
}
|
|
36
|
+
const nextWalletGiftCardClaim = nextWalletGiftCardClaims[0];
|
|
37
|
+
if (nextWalletGiftCardClaim == null) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
gift_card_id: nextWalletGiftCardClaim.gift_card_id,
|
|
42
|
+
mystery_gift_type: nextWalletGiftCardClaim.mystery_gift_type,
|
|
43
|
+
value_redeemed: nextWalletGiftCardClaim.redeemed_times,
|
|
44
|
+
redeemed_times: nextWalletGiftCardClaim.redeemed_times,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { getIngredientsWithDecimal, getIngredientsWithInt } from './ingredients';
|
|
2
|
+
import { convertDecimalToInt, convertIntToDecimal } from './price-conversion';
|
|
3
|
+
export function convertWarehousePriceObjFromDecimalToInt(price) {
|
|
4
|
+
// Step 1: check if price is null, if so return null
|
|
5
|
+
if (!price)
|
|
6
|
+
return null;
|
|
7
|
+
// check if all prices in price are 0, if so return null
|
|
8
|
+
else if (Object.values(price).every((p) => p === 0))
|
|
9
|
+
return null;
|
|
10
|
+
// step 2: check if all the platform values are the same
|
|
11
|
+
// if they are, return BASE_PRICE
|
|
12
|
+
else if (Object.values(price).every((p) => p === price.BASE_PRICE)) {
|
|
13
|
+
return { BASE_PRICE: convertDecimalToInt(price.BASE_PRICE) };
|
|
14
|
+
}
|
|
15
|
+
const priceObjInCents = {};
|
|
16
|
+
for (const key in price) {
|
|
17
|
+
const typedKey = key;
|
|
18
|
+
if (typedKey !== 'BASE_PRICE' && price[typedKey] === price.BASE_PRICE) {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
priceObjInCents[typedKey] = convertDecimalToInt(price[typedKey]);
|
|
22
|
+
}
|
|
23
|
+
return priceObjInCents;
|
|
24
|
+
}
|
|
25
|
+
export function convertWarehousePriceObjFromIntToDecimal(priceObj) {
|
|
26
|
+
if (!priceObj)
|
|
27
|
+
return null;
|
|
28
|
+
const keys = Object.keys(priceObj);
|
|
29
|
+
return keys.reduce((obj, key) => ({ ...obj, [key]: convertIntToDecimal(priceObj[key]) }), {});
|
|
30
|
+
}
|
|
31
|
+
export function getWarehouseGeneralPriceEnum(price, platform) {
|
|
32
|
+
if (!price)
|
|
33
|
+
return 0;
|
|
34
|
+
const priceInCents = price[platform] ?? price.BASE_PRICE;
|
|
35
|
+
return priceInCents;
|
|
36
|
+
}
|
|
37
|
+
export function getPartialWarehouseItemWithPrice(item, writeable) {
|
|
38
|
+
const convertPriceObj = writeable
|
|
39
|
+
? convertWarehousePriceObjFromDecimalToInt
|
|
40
|
+
: convertWarehousePriceObjFromIntToDecimal;
|
|
41
|
+
const convertPrice = writeable ? convertDecimalToInt : convertIntToDecimal;
|
|
42
|
+
const convertIngredients = writeable ? getIngredientsWithInt : getIngredientsWithDecimal;
|
|
43
|
+
return {
|
|
44
|
+
...item,
|
|
45
|
+
...(item.purchase_price !== undefined
|
|
46
|
+
? {
|
|
47
|
+
purchase_price: convertPriceObj(item.purchase_price),
|
|
48
|
+
}
|
|
49
|
+
: {}),
|
|
50
|
+
...(item.selling_price !== undefined
|
|
51
|
+
? {
|
|
52
|
+
selling_price: convertPriceObj(item.selling_price),
|
|
53
|
+
}
|
|
54
|
+
: {}),
|
|
55
|
+
...(item.threshold_quantity !== undefined ? { threshold_quantity: convertPrice(item.threshold_quantity) } : {}),
|
|
56
|
+
...(item.unit_price !== undefined ? { unit_price: convertPrice(item.unit_price) } : {}),
|
|
57
|
+
...(item.quantity_left !== undefined ? { quantity_left: convertPrice(item.quantity_left) } : {}),
|
|
58
|
+
...(item.remaining_stock_price !== undefined
|
|
59
|
+
? { remaining_stock_price: convertPrice(item.remaining_stock_price) }
|
|
60
|
+
: {}),
|
|
61
|
+
...(item.ingredients !== undefined ? { ingredients: convertIngredients(item.ingredients) } : {}),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export function getWarehouseCatalogFetchedData(categories, items) {
|
|
65
|
+
const categoriesObj = categories.reduce((acc, category) => ({
|
|
66
|
+
...acc,
|
|
67
|
+
[category.ref_id]: {
|
|
68
|
+
...category,
|
|
69
|
+
items: [],
|
|
70
|
+
},
|
|
71
|
+
}), {});
|
|
72
|
+
// Secondary lookup by category _id: synced categories carry a fresh per-target
|
|
73
|
+
// _id (≠ ref_id) while items store that category _id, so a ref_id-only lookup
|
|
74
|
+
// would silently drop those items from the catalog.
|
|
75
|
+
const categoriesByItemId = categories.reduce((acc, category) => {
|
|
76
|
+
if (category._id != null) {
|
|
77
|
+
acc[category._id] = categoriesObj[category.ref_id];
|
|
78
|
+
}
|
|
79
|
+
return acc;
|
|
80
|
+
}, {});
|
|
81
|
+
const uncategorizedItems = [];
|
|
82
|
+
for (let i = 0; i < items.length; i++) {
|
|
83
|
+
const item = items[i];
|
|
84
|
+
const sortedItem = getPartialWarehouseItemWithPrice(item);
|
|
85
|
+
if (item.category_id) {
|
|
86
|
+
(categoriesObj[item.category_id] ?? categoriesByItemId[item.category_id])?.items.push(sortedItem);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
uncategorizedItems.push(sortedItem);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const sortedCatalogs = Object.values(categoriesObj)
|
|
93
|
+
.map((category) => ({
|
|
94
|
+
...category,
|
|
95
|
+
items: category.items.sort((a, b) => a.sort_id - b.sort_id),
|
|
96
|
+
}))
|
|
97
|
+
.sort((a, b) => a.sort_id - b.sort_id);
|
|
98
|
+
if (uncategorizedItems.length > 0) {
|
|
99
|
+
const uncategorizedCatalog = {
|
|
100
|
+
_id: null,
|
|
101
|
+
brand_id: '',
|
|
102
|
+
warehouse_id: '',
|
|
103
|
+
ref_id: null,
|
|
104
|
+
image_url: null,
|
|
105
|
+
name: 'Uncategorized',
|
|
106
|
+
subtitle: '',
|
|
107
|
+
active: true,
|
|
108
|
+
category_removal_strategy: 'NONE',
|
|
109
|
+
sort_id: sortedCatalogs.length,
|
|
110
|
+
createdAt: new Date(),
|
|
111
|
+
updatedAt: new Date(),
|
|
112
|
+
items: uncategorizedItems.sort((a, b) => a.sort_id - b.sort_id),
|
|
113
|
+
};
|
|
114
|
+
sortedCatalogs.push(uncategorizedCatalog);
|
|
115
|
+
}
|
|
116
|
+
return sortedCatalogs;
|
|
117
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// =====================Fetch Stock===================
|
|
2
|
+
import { convertIntToDecimal } from './price-conversion';
|
|
3
|
+
export function getWarehouseInventoryWithDecimal(inventory) {
|
|
4
|
+
return {
|
|
5
|
+
...inventory,
|
|
6
|
+
...(typeof inventory.threshold_quantity === 'number'
|
|
7
|
+
? {
|
|
8
|
+
threshold_quantity: convertIntToDecimal(inventory.threshold_quantity),
|
|
9
|
+
}
|
|
10
|
+
: {}),
|
|
11
|
+
...(typeof inventory.quantity_left === 'number'
|
|
12
|
+
? {
|
|
13
|
+
quantity_left: convertIntToDecimal(inventory.quantity_left),
|
|
14
|
+
}
|
|
15
|
+
: {}),
|
|
16
|
+
...(typeof inventory.previous_quantity_left === 'number'
|
|
17
|
+
? {
|
|
18
|
+
previous_quantity_left: convertIntToDecimal(inventory.previous_quantity_left),
|
|
19
|
+
}
|
|
20
|
+
: {}),
|
|
21
|
+
...(typeof inventory.quantity_added === 'number'
|
|
22
|
+
? { quantity_added: convertIntToDecimal(inventory.quantity_added) }
|
|
23
|
+
: {}),
|
|
24
|
+
...(typeof inventory.quantity_consumed === 'number'
|
|
25
|
+
? { quantity_consumed: convertIntToDecimal(inventory.quantity_consumed) }
|
|
26
|
+
: {}),
|
|
27
|
+
...(typeof inventory.quantity_wasted === 'number'
|
|
28
|
+
? { quantity_wasted: convertIntToDecimal(inventory.quantity_wasted) }
|
|
29
|
+
: {}),
|
|
30
|
+
...(typeof inventory.quantity_short === 'number'
|
|
31
|
+
? { quantity_short: convertIntToDecimal(inventory.quantity_short) }
|
|
32
|
+
: {}),
|
|
33
|
+
...(typeof inventory.variance_quantity === 'number'
|
|
34
|
+
? { variance_quantity: convertIntToDecimal(inventory.variance_quantity) }
|
|
35
|
+
: {}),
|
|
36
|
+
...(typeof inventory.transfer_quantity === 'number'
|
|
37
|
+
? { transfer_quantity: convertIntToDecimal(inventory.transfer_quantity) }
|
|
38
|
+
: {}),
|
|
39
|
+
...(typeof inventory.return_quantity === 'number'
|
|
40
|
+
? { return_quantity: convertIntToDecimal(inventory.return_quantity) }
|
|
41
|
+
: {}),
|
|
42
|
+
...(typeof inventory.sale_quantity === 'number'
|
|
43
|
+
? { sale_quantity: convertIntToDecimal(inventory.sale_quantity) }
|
|
44
|
+
: {}),
|
|
45
|
+
...(typeof inventory.unit_price === 'number' ? { unit_price: convertIntToDecimal(inventory.unit_price) } : {}),
|
|
46
|
+
...(typeof inventory.remaining_stock_price === 'number'
|
|
47
|
+
? { remaining_stock_price: convertIntToDecimal(inventory.remaining_stock_price) }
|
|
48
|
+
: {}),
|
|
49
|
+
...(typeof inventory.new_stock_price === 'number'
|
|
50
|
+
? { new_stock_price: convertIntToDecimal(inventory.new_stock_price) }
|
|
51
|
+
: {}),
|
|
52
|
+
...(typeof inventory.previous_unit_price === 'number'
|
|
53
|
+
? { previous_unit_price: convertIntToDecimal(inventory.previous_unit_price) }
|
|
54
|
+
: {}),
|
|
55
|
+
...(typeof inventory.previous_remaining_stock_price === 'number'
|
|
56
|
+
? { previous_remaining_stock_price: convertIntToDecimal(inventory.previous_remaining_stock_price) }
|
|
57
|
+
: {}),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import ObjectID from 'bson-objectid';
|
|
2
|
+
export function convertWarehouseItemToPurchaseOrderItem({ vendorId, item, orderItem, }) {
|
|
3
|
+
const { _id = ObjectID().toHexString(), price = item.purchase_price?.[vendorId] ?? item.purchase_price?.BASE_PRICE ?? 0, quantity = 1, special_instructions = '', is_ready, } = orderItem ?? {};
|
|
4
|
+
const purchaseOrderItem = {
|
|
5
|
+
_id,
|
|
6
|
+
item_id: item._id,
|
|
7
|
+
name: item.name,
|
|
8
|
+
price,
|
|
9
|
+
subtotal: price * quantity,
|
|
10
|
+
quantity,
|
|
11
|
+
special_instructions,
|
|
12
|
+
is_ready,
|
|
13
|
+
// These values will be auto calculated
|
|
14
|
+
_discount_amount: 0,
|
|
15
|
+
_gross_amount: 0,
|
|
16
|
+
_gst_amount: 0,
|
|
17
|
+
_net_amount: 0,
|
|
18
|
+
};
|
|
19
|
+
return purchaseOrderItem;
|
|
20
|
+
}
|
|
21
|
+
// ==========================================================><====================================================
|
|
22
|
+
export function getCurrentWarehousePurchaseOrderItemTotalPrice(orderItem) {
|
|
23
|
+
// For purchase orders, total is simply price * quantity
|
|
24
|
+
// No modifiers, discounts, etc.
|
|
25
|
+
const total = orderItem.price * orderItem.quantity;
|
|
26
|
+
return total;
|
|
27
|
+
}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import emojiStrip from 'emoji-strip';
|
|
2
|
+
import moment from 'moment';
|
|
3
|
+
import { COUNTRY_ALPHA_2_ENUM, PAYMENT_STATUS_ENUM, PAYMENT_TYPE_ENUM, WAREHOUSE_PURCHASE_ORDER_STATUS_ENUM, } from '../../constants';
|
|
4
|
+
import { getGSTName, getTaxNumberTitle, localeAmount, parseNum, sentenceCase } from './common';
|
|
5
|
+
import { getOrderPaymentsDetails, getPaymentSmartTitle, getSortedPayments, isOrderFullyPaid } from './payment-helpers';
|
|
6
|
+
// =========================><=========================
|
|
7
|
+
export function getWarehouseReceiptEngineFooterDetails(order, settings) {
|
|
8
|
+
const currencySymbol = settings.currency_symbol ?? '';
|
|
9
|
+
const price = order.price ?? 0;
|
|
10
|
+
const grandTotal = order.grand_total ?? 0;
|
|
11
|
+
const details = [];
|
|
12
|
+
if (price !== grandTotal) {
|
|
13
|
+
const right = `${localeAmount(currencySymbol, price)}`;
|
|
14
|
+
details.push({
|
|
15
|
+
left: 'Price',
|
|
16
|
+
right,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
if (order.gst && !settings.hide_gst_value) {
|
|
20
|
+
if (order.is_gst_inclusive) {
|
|
21
|
+
const right = localeAmount(currencySymbol, Math.max(0, (order.grand_total ?? 0) - (order.gst_amount ?? 0)));
|
|
22
|
+
details.push({
|
|
23
|
+
left: `Total before ${settings.gstName}`,
|
|
24
|
+
right,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
let left = '';
|
|
28
|
+
if (order.is_gst_inclusive) {
|
|
29
|
+
left = `${settings.gstName} (${parseNum(order.gst)}% Inclusive)`;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
left = `${settings.gstName} (${parseNum(order.gst)}%)`;
|
|
33
|
+
}
|
|
34
|
+
const right = localeAmount(currencySymbol, order.gst_amount ?? 0);
|
|
35
|
+
details.push({
|
|
36
|
+
left,
|
|
37
|
+
right,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return details;
|
|
41
|
+
}
|
|
42
|
+
export function getWarehouseOrderItemReceiptBody({ orderItem, currency_symbol, displayItemInstructions, displayUnitItemPrice, isRemoved, }) {
|
|
43
|
+
const name = orderItem.name;
|
|
44
|
+
const quantity = orderItem.quantity;
|
|
45
|
+
const subtotal = parseNum(orderItem.subtotal);
|
|
46
|
+
let description = `${quantity}x ${name}`;
|
|
47
|
+
const amount = localeAmount(currency_symbol, subtotal);
|
|
48
|
+
if (displayUnitItemPrice) {
|
|
49
|
+
description += ` @\u200E${parseNum(subtotal / quantity)}`;
|
|
50
|
+
}
|
|
51
|
+
const options = [
|
|
52
|
+
{
|
|
53
|
+
left: description,
|
|
54
|
+
right: amount,
|
|
55
|
+
_id: orderItem._id,
|
|
56
|
+
item_id: orderItem.item_id,
|
|
57
|
+
image_url: orderItem.image_url,
|
|
58
|
+
},
|
|
59
|
+
];
|
|
60
|
+
if (!isRemoved && displayItemInstructions && orderItem.special_instructions.length > 0) {
|
|
61
|
+
options.push({
|
|
62
|
+
left: `** Note: ${emojiStrip(orderItem.special_instructions)} **`,
|
|
63
|
+
is_bold: true,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
if (isRemoved && orderItem.void_reason != null && orderItem.void_reason.length > 0) {
|
|
67
|
+
options.push({
|
|
68
|
+
left: `** Reason: ${emojiStrip(orderItem.void_reason)} **`,
|
|
69
|
+
is_bold: true,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return options;
|
|
73
|
+
}
|
|
74
|
+
export function getWarehouseReceiptBody({ orderItems, currency_symbol, displayItemInstructions, displayUnitItemPrice, isRemoved, }) {
|
|
75
|
+
const currency = currency_symbol ?? '';
|
|
76
|
+
const items = orderItems
|
|
77
|
+
.map((item) => getWarehouseOrderItemReceiptBody({
|
|
78
|
+
orderItem: item,
|
|
79
|
+
currency_symbol: currency,
|
|
80
|
+
displayItemInstructions,
|
|
81
|
+
displayUnitItemPrice,
|
|
82
|
+
isRemoved,
|
|
83
|
+
}))
|
|
84
|
+
.flat();
|
|
85
|
+
return items;
|
|
86
|
+
}
|
|
87
|
+
// =========================><=========================
|
|
88
|
+
export function getWarehouseReceiptEngine(payload) {
|
|
89
|
+
const { currency_symbol, image_url, name, public_phone_numbers, warehouse_address, support_email, tax_business_number, tax_invoice_provider, country_alpha_2, hide_gst_value, } = payload.warehouse_settings;
|
|
90
|
+
const { display_item_instructions, display_order_instructions, display_unit_item_price, print_staff_name } = payload.printer_settings;
|
|
91
|
+
const currencySymbol = currency_symbol ?? '';
|
|
92
|
+
const grandTotal = payload.order.grand_total ?? 0;
|
|
93
|
+
const { amountPayedSoFar, existingPayments, change } = getOrderPaymentsDetails(payload.order.grand_total, payload.order.payments);
|
|
94
|
+
const payments = getSortedPayments(existingPayments.filter((payment) => payment.payment_status === PAYMENT_STATUS_ENUM.SETTLED ||
|
|
95
|
+
payment.payment_status === PAYMENT_STATUS_ENUM.REFUNDED));
|
|
96
|
+
const gstName = getGSTName(country_alpha_2, tax_invoice_provider);
|
|
97
|
+
const taxNumberTitle = getTaxNumberTitle(country_alpha_2, tax_invoice_provider);
|
|
98
|
+
const isFullyPaid = isOrderFullyPaid(grandTotal, payload.order.payments);
|
|
99
|
+
const settings = {
|
|
100
|
+
currency_symbol,
|
|
101
|
+
gstName,
|
|
102
|
+
hide_gst_value,
|
|
103
|
+
};
|
|
104
|
+
const categories = payload.order.categories ?? [];
|
|
105
|
+
const items = categories.reduce((acc, category) => acc.concat(category.items.map((item) => ({
|
|
106
|
+
...item,
|
|
107
|
+
}))), []);
|
|
108
|
+
const receiptItems = getWarehouseReceiptBody({
|
|
109
|
+
orderItems: items,
|
|
110
|
+
currency_symbol,
|
|
111
|
+
displayItemInstructions: display_item_instructions,
|
|
112
|
+
displayUnitItemPrice: display_unit_item_price,
|
|
113
|
+
});
|
|
114
|
+
const total_items = items.length;
|
|
115
|
+
const changeAmount = change > 0 ? localeAmount(currencySymbol, change) : null;
|
|
116
|
+
const payment_details = [
|
|
117
|
+
...payments.map((payment) => {
|
|
118
|
+
const isRefund = payment.amount_refunded > 0 && payment.amount_refunded > payment.amount_paid;
|
|
119
|
+
const paymentTitle = getPaymentSmartTitle(payment.payment_type).title;
|
|
120
|
+
const amount = (payment.payment_type !== PAYMENT_TYPE_ENUM.UNPAID
|
|
121
|
+
? isRefund
|
|
122
|
+
? payment.amount_refunded - payment.amount_paid
|
|
123
|
+
: payment.amount_paid
|
|
124
|
+
: payment.amount_due) + (payment.card_details?.card_charges ?? 0);
|
|
125
|
+
return {
|
|
126
|
+
left: `${sentenceCase(paymentTitle).replace(/_/g, ' ')}${isRefund ? ' (Refund)' : ''}`,
|
|
127
|
+
right: localeAmount(currencySymbol, amount),
|
|
128
|
+
};
|
|
129
|
+
}),
|
|
130
|
+
...(changeAmount
|
|
131
|
+
? [
|
|
132
|
+
{
|
|
133
|
+
left: 'Change',
|
|
134
|
+
right: changeAmount,
|
|
135
|
+
},
|
|
136
|
+
]
|
|
137
|
+
: []),
|
|
138
|
+
];
|
|
139
|
+
const parsedAmountPayedSoFar = parseNum(amountPayedSoFar);
|
|
140
|
+
const staff_name = print_staff_name && payload.order.staff_details != null ? (payload.order.staff_details.staff_name ?? null) : null;
|
|
141
|
+
let payment_status = null;
|
|
142
|
+
if (payload.order.is_deleted) {
|
|
143
|
+
payment_status = '* DELETED *';
|
|
144
|
+
}
|
|
145
|
+
else if (payload.order.order_status === WAREHOUSE_PURCHASE_ORDER_STATUS_ENUM.CANCELLED) {
|
|
146
|
+
payment_status = '* CANCELLED *';
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
if (parsedAmountPayedSoFar >= parseNum(grandTotal)) {
|
|
150
|
+
payment_status = '* PAID *';
|
|
151
|
+
}
|
|
152
|
+
else if (parsedAmountPayedSoFar > 0) {
|
|
153
|
+
payment_status = '* PARTIALLY PAID *';
|
|
154
|
+
payment_details.push({
|
|
155
|
+
left: 'Pending Amount',
|
|
156
|
+
right: localeAmount(currencySymbol, grandTotal - parsedAmountPayedSoFar),
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
payment_status = '* UNPAID *';
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
let cancel_reason = null;
|
|
164
|
+
if (payload.order.order_status === WAREHOUSE_PURCHASE_ORDER_STATUS_ENUM.CANCELLED) {
|
|
165
|
+
cancel_reason = payload.order.cancel_reason ?? null;
|
|
166
|
+
}
|
|
167
|
+
let invoice_name = `Invoice #${payload.order.order_number ?? ''}`;
|
|
168
|
+
if (isFullyPaid) {
|
|
169
|
+
if (payload.order.tax_number || (country_alpha_2 !== COUNTRY_ALPHA_2_ENUM.PK && tax_business_number)) {
|
|
170
|
+
invoice_name = `Tax ${invoice_name}`;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
const engine = {
|
|
174
|
+
_id: payload.order._id ?? '',
|
|
175
|
+
warehouse_details: {
|
|
176
|
+
image_url,
|
|
177
|
+
name,
|
|
178
|
+
warehouse_address,
|
|
179
|
+
support_email,
|
|
180
|
+
public_phone_numbers,
|
|
181
|
+
tax_business_number,
|
|
182
|
+
taxNumberTitle,
|
|
183
|
+
},
|
|
184
|
+
placed_time: moment(payload.order.createdAt).format('ddd, MMMM Do, h:mmA'),
|
|
185
|
+
expected_time: null,
|
|
186
|
+
order_number: invoice_name,
|
|
187
|
+
vendor_details: {
|
|
188
|
+
vendor_id: payload.order.vendor_id,
|
|
189
|
+
},
|
|
190
|
+
order_details: {
|
|
191
|
+
staff_name,
|
|
192
|
+
},
|
|
193
|
+
payment_status,
|
|
194
|
+
order_link: null,
|
|
195
|
+
total_items,
|
|
196
|
+
items: receiptItems,
|
|
197
|
+
payment_details,
|
|
198
|
+
footer: getWarehouseReceiptEngineFooterDetails(payload.order, settings).concat({
|
|
199
|
+
left: `Grand Total${payload.order.gst && hide_gst_value ? ` (Incl. ${gstName})` : ''}`,
|
|
200
|
+
right: localeAmount(currencySymbol, payload.order.grand_total ?? 0),
|
|
201
|
+
}),
|
|
202
|
+
cancel_reason,
|
|
203
|
+
};
|
|
204
|
+
return engine;
|
|
205
|
+
}
|