@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,483 @@
|
|
|
1
|
+
import ObjectID from 'bson-objectid';
|
|
2
|
+
import { isEqual } from 'lodash';
|
|
3
|
+
import { SORT_TYPE_ENUM } from '../../constants';
|
|
4
|
+
import { convertDecimalToInt, convertIntToDecimal, parseNum } from '../utils';
|
|
5
|
+
import { sortByCreatedAt } from './common-order-actions';
|
|
6
|
+
import { calculateCartWarehouseSaleOrderInfoAndSyncData, getWarehouseSaleOrderItemComparableData, } from './warehouse-sale-orders-cart-actions';
|
|
7
|
+
export function getWarehouseSaleOrdersFetchedData(data) {
|
|
8
|
+
return data.map((order) => getWarehouseSaleOrderWithPrice(order, false)).sort(sortByCreatedAt);
|
|
9
|
+
}
|
|
10
|
+
// ── Iterations ──────────────────────────────────────────────────
|
|
11
|
+
export function getWarehouseSaleOrderIterationsWithPrice(iterations, writeable) {
|
|
12
|
+
if (!iterations)
|
|
13
|
+
return [];
|
|
14
|
+
return iterations.map((iteration) => getWarehouseSaleOrderWithPrice(iteration, writeable));
|
|
15
|
+
}
|
|
16
|
+
// ── Items ───────────────────────────────────────────────────────
|
|
17
|
+
export function getWarehouseSaleOrderItemsWithPrice(items, convertToPrice) {
|
|
18
|
+
if (!items)
|
|
19
|
+
return [];
|
|
20
|
+
return items.map((item) => ({
|
|
21
|
+
...item,
|
|
22
|
+
quantity: parseNum(item.quantity || 1, true),
|
|
23
|
+
price: convertToPrice(item.price ?? 0),
|
|
24
|
+
subtotal: convertToPrice(item.subtotal ?? 0),
|
|
25
|
+
_gst_amount: convertToPrice(item._gst_amount ?? 0),
|
|
26
|
+
_net_amount: convertToPrice(item._net_amount ?? 0),
|
|
27
|
+
_gross_amount: convertToPrice(item._gross_amount ?? 0),
|
|
28
|
+
_discount_amount: convertToPrice(item._discount_amount ?? 0),
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
// ── Categories ──────────────────────────────────────────────────
|
|
32
|
+
export function getWarehouseSaleOrderCategoriesWithPrice(categories, convertToPrice) {
|
|
33
|
+
if (!categories)
|
|
34
|
+
return [];
|
|
35
|
+
return categories.map((category) => ({
|
|
36
|
+
...category,
|
|
37
|
+
items: getWarehouseSaleOrderItemsWithPrice(category.items, convertToPrice),
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
// ── Main helper ─────────────────────────────────────────────────
|
|
41
|
+
export function getWarehouseSaleOrderWithPrice(order, writeable) {
|
|
42
|
+
const convertToPrice = writeable ? convertDecimalToInt : convertIntToDecimal;
|
|
43
|
+
const payload = {
|
|
44
|
+
...order,
|
|
45
|
+
...(order.iterations != null
|
|
46
|
+
? {
|
|
47
|
+
iterations: getWarehouseSaleOrderIterationsWithPrice(order.iterations, writeable),
|
|
48
|
+
}
|
|
49
|
+
: {}),
|
|
50
|
+
...(order.categories != null
|
|
51
|
+
? {
|
|
52
|
+
categories: getWarehouseSaleOrderCategoriesWithPrice(order.categories, convertToPrice),
|
|
53
|
+
}
|
|
54
|
+
: {}),
|
|
55
|
+
...(order.gst != null ? { gst: convertToPrice(order.gst) } : {}),
|
|
56
|
+
...(order.gst_amount != null ? { gst_amount: convertToPrice(order.gst_amount) } : {}),
|
|
57
|
+
...(order.amount_collected != null
|
|
58
|
+
? {
|
|
59
|
+
amount_collected: convertToPrice(order.amount_collected),
|
|
60
|
+
}
|
|
61
|
+
: {}),
|
|
62
|
+
...(order.amount_earned != null ? { amount_earned: convertToPrice(order.amount_earned) } : {}),
|
|
63
|
+
...(order.grand_total != null ? { grand_total: convertToPrice(order.grand_total) } : {}),
|
|
64
|
+
...(order.price != null ? { price: convertToPrice(order.price) } : {}),
|
|
65
|
+
};
|
|
66
|
+
return payload;
|
|
67
|
+
}
|
|
68
|
+
export function syncWarehouseSaleOrderData(order) {
|
|
69
|
+
const updatedOrder = {
|
|
70
|
+
...order,
|
|
71
|
+
iterations: [],
|
|
72
|
+
};
|
|
73
|
+
const newOrder = getWarehouseSaleOrderWithPrice(calculateCartWarehouseSaleOrderInfoAndSyncData(getWarehouseSaleOrderWithPrice(updatedOrder), true), true);
|
|
74
|
+
newOrder.iterations = order.iterations;
|
|
75
|
+
return newOrder;
|
|
76
|
+
}
|
|
77
|
+
export function skipItemMetadataFromWarehouseSaleOrderCategories(categories, previousCategories) {
|
|
78
|
+
return categories.map((category) => {
|
|
79
|
+
const previousCategory = previousCategories?.find((prevCategory) => prevCategory.category_id === category.category_id);
|
|
80
|
+
return {
|
|
81
|
+
...category,
|
|
82
|
+
items: category.items.map((item) => {
|
|
83
|
+
const previousItem = previousCategory?.items.find((prevItem) => prevItem._id === item._id);
|
|
84
|
+
const void_reason = previousItem?.void_reason ?? item.void_reason;
|
|
85
|
+
const newItem = {
|
|
86
|
+
...item,
|
|
87
|
+
void_reason,
|
|
88
|
+
_discount_amount: 0,
|
|
89
|
+
_gst_amount: 0,
|
|
90
|
+
_gross_amount: 0,
|
|
91
|
+
_net_amount: 0,
|
|
92
|
+
};
|
|
93
|
+
return newItem;
|
|
94
|
+
}),
|
|
95
|
+
};
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function getCommonOptionalBoolFieldsSaleOrder(order, partial) {
|
|
99
|
+
const defaultValue = partial ? undefined : false;
|
|
100
|
+
return {
|
|
101
|
+
is_gst_inclusive: order['is_gst_inclusive'] || defaultValue,
|
|
102
|
+
is_reopened: order['is_reopened'] || defaultValue,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function getCommonOptionalNumFieldsSaleOrder(order, partial) {
|
|
106
|
+
const defaultValue = partial ? undefined : 0;
|
|
107
|
+
return {
|
|
108
|
+
gst: order['gst'] || defaultValue,
|
|
109
|
+
gst_amount: order['gst_amount'] || defaultValue,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
export function getWarehouseSaleOrderWithAllFields(order, skipItemMetadata) {
|
|
113
|
+
return {
|
|
114
|
+
...order,
|
|
115
|
+
...getCommonOptionalBoolFieldsSaleOrder(order, false),
|
|
116
|
+
...getCommonOptionalNumFieldsSaleOrder(order, false),
|
|
117
|
+
...(skipItemMetadata && order.categories != null
|
|
118
|
+
? {
|
|
119
|
+
categories: skipItemMetadataFromWarehouseSaleOrderCategories(order.categories),
|
|
120
|
+
}
|
|
121
|
+
: {}),
|
|
122
|
+
delete_reason: order['delete_reason'] ?? null,
|
|
123
|
+
cancel_reason: order['cancel_reason'] ?? null,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
export function getWarehouseSaleOrderCartItemsObj({ currentIterationCategories, previousIterationCategories, mappedItems, shouldSortItemsViaId = true, isAnEdit, sortType, }) {
|
|
127
|
+
const newMappedItems = { ...mappedItems };
|
|
128
|
+
if (Object.keys(newMappedItems).length === 0) {
|
|
129
|
+
previousIterationCategories?.forEach((category) => {
|
|
130
|
+
category.items.forEach((item) => {
|
|
131
|
+
if (newMappedItems[item.item_id] == null) {
|
|
132
|
+
newMappedItems[item.item_id] = {
|
|
133
|
+
_id: item.item_id,
|
|
134
|
+
name: item.name,
|
|
135
|
+
category_id: category.category_id,
|
|
136
|
+
category_name: category.name,
|
|
137
|
+
category_image_url: '',
|
|
138
|
+
image_url: '',
|
|
139
|
+
description: '',
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
currentIterationCategories?.forEach((category) => {
|
|
145
|
+
category.items.forEach((item) => {
|
|
146
|
+
if (newMappedItems[item.item_id] == null) {
|
|
147
|
+
newMappedItems[item.item_id] = {
|
|
148
|
+
_id: item.item_id,
|
|
149
|
+
name: item.name,
|
|
150
|
+
category_id: category.category_id,
|
|
151
|
+
category_name: category.name,
|
|
152
|
+
category_image_url: '',
|
|
153
|
+
image_url: '',
|
|
154
|
+
description: '',
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
// =====================><=====================
|
|
161
|
+
const getCartItems = (items) => {
|
|
162
|
+
const orderItems = items.map((item) => {
|
|
163
|
+
const selectedItem = newMappedItems[item.item_id] ?? {};
|
|
164
|
+
return {
|
|
165
|
+
orderItem: item,
|
|
166
|
+
image_url: selectedItem.image_url ?? '',
|
|
167
|
+
description: selectedItem.description ?? '',
|
|
168
|
+
category_name: selectedItem.category_name ?? '',
|
|
169
|
+
category_id: selectedItem.category_id ?? '',
|
|
170
|
+
};
|
|
171
|
+
});
|
|
172
|
+
if (shouldSortItemsViaId) {
|
|
173
|
+
if (sortType === SORT_TYPE_ENUM.DESC) {
|
|
174
|
+
orderItems.sort((a, b) => ObjectID(b.orderItem._id).getTimestamp().getTime() - ObjectID(a.orderItem._id).getTimestamp().getTime());
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
orderItems.sort((a, b) => ObjectID(a.orderItem._id).getTimestamp().getTime() - ObjectID(b.orderItem._id).getTimestamp().getTime());
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return orderItems;
|
|
181
|
+
};
|
|
182
|
+
// =====================><=====================
|
|
183
|
+
let totalItemsInCart = 0;
|
|
184
|
+
const currentItems = [];
|
|
185
|
+
if (currentIterationCategories != null) {
|
|
186
|
+
for (let i = 0; i < currentIterationCategories.length; i++) {
|
|
187
|
+
const category = currentIterationCategories[i];
|
|
188
|
+
for (let j = 0; j < category.items.length; j++) {
|
|
189
|
+
const item = { ...category.items[j] };
|
|
190
|
+
currentItems.push(item);
|
|
191
|
+
totalItemsInCart += item.quantity;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
let unChangedItems = currentItems;
|
|
196
|
+
const editedItems = [];
|
|
197
|
+
let removedItems = [];
|
|
198
|
+
let newItems = [];
|
|
199
|
+
let disabledReason = '';
|
|
200
|
+
const isAnUpdate = isAnEdit ?? (previousIterationCategories != null && previousIterationCategories.length > 0);
|
|
201
|
+
if (isAnUpdate) {
|
|
202
|
+
const currentItemsMap = currentItems.reduce((acc, currentItem) => {
|
|
203
|
+
acc[currentItem._id] = currentItem;
|
|
204
|
+
return acc;
|
|
205
|
+
}, {});
|
|
206
|
+
const prevItems = [];
|
|
207
|
+
const prevItemsMap = {};
|
|
208
|
+
const prevCategories = previousIterationCategories ?? [];
|
|
209
|
+
for (let i = 0; i < prevCategories.length; i++) {
|
|
210
|
+
const category = prevCategories[i];
|
|
211
|
+
for (let j = 0; j < category.items.length; j++) {
|
|
212
|
+
const prevItem = category.items[j];
|
|
213
|
+
let item = prevItem;
|
|
214
|
+
const currentItem = currentItemsMap[prevItem._id];
|
|
215
|
+
if (currentItem != null && currentItem.is_ready != null) {
|
|
216
|
+
item = {
|
|
217
|
+
...item,
|
|
218
|
+
is_ready: currentItem.is_ready,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
prevItems.push(item);
|
|
222
|
+
prevItemsMap[item._id] = item;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
unChangedItems = [];
|
|
226
|
+
let totalTempRemovedItems = 0;
|
|
227
|
+
for (let i = 0; i < prevItems.length; i++) {
|
|
228
|
+
const prevItem = {
|
|
229
|
+
...prevItems[i],
|
|
230
|
+
};
|
|
231
|
+
const currentItem = {
|
|
232
|
+
...currentItemsMap[prevItem._id],
|
|
233
|
+
};
|
|
234
|
+
if (currentItemsMap[prevItem._id] == null) {
|
|
235
|
+
removedItems.push(prevItem);
|
|
236
|
+
}
|
|
237
|
+
else if (isEqual(getWarehouseSaleOrderItemComparableData(currentItem), getWarehouseSaleOrderItemComparableData(prevItem))) {
|
|
238
|
+
unChangedItems.push(prevItem);
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
const currQty = currentItem.quantity;
|
|
242
|
+
const prevQty = prevItem.quantity;
|
|
243
|
+
if (currQty !== prevQty) {
|
|
244
|
+
const subtotalForOne = currentItem.subtotal / currentItem.quantity;
|
|
245
|
+
const diff = currQty - prevQty;
|
|
246
|
+
const changeQty = Math.abs(diff);
|
|
247
|
+
const itm = {
|
|
248
|
+
...currentItem,
|
|
249
|
+
quantity: changeQty,
|
|
250
|
+
subtotal: parseNum(changeQty * subtotalForOne),
|
|
251
|
+
};
|
|
252
|
+
if (diff > 0) {
|
|
253
|
+
newItems.push(itm);
|
|
254
|
+
const unchangedQty = currQty - changeQty;
|
|
255
|
+
const tempUnchangedItm = {
|
|
256
|
+
...currentItem,
|
|
257
|
+
quantity: unchangedQty,
|
|
258
|
+
subtotal: parseNum(unchangedQty * subtotalForOne),
|
|
259
|
+
};
|
|
260
|
+
unChangedItems.push(tempUnchangedItm);
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
itm.void_reason = prevItem.void_reason ?? currentItem.void_reason;
|
|
264
|
+
removedItems.push(itm);
|
|
265
|
+
const unchangedQty = prevQty - changeQty;
|
|
266
|
+
const tempUnchangedItm = {
|
|
267
|
+
...currentItem,
|
|
268
|
+
quantity: unchangedQty,
|
|
269
|
+
subtotal: parseNum(unchangedQty * subtotalForOne),
|
|
270
|
+
};
|
|
271
|
+
unChangedItems.push(tempUnchangedItm);
|
|
272
|
+
totalTempRemovedItems++;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
const curr = {
|
|
277
|
+
_id: currentItem._id,
|
|
278
|
+
item_id: currentItem.item_id,
|
|
279
|
+
name: currentItem.name,
|
|
280
|
+
special_instructions: currentItem.special_instructions,
|
|
281
|
+
};
|
|
282
|
+
const prev = {
|
|
283
|
+
_id: prevItem._id,
|
|
284
|
+
item_id: prevItem.item_id,
|
|
285
|
+
name: prevItem.name,
|
|
286
|
+
special_instructions: prevItem.special_instructions,
|
|
287
|
+
};
|
|
288
|
+
const isBothEqual = isEqual(curr, prev);
|
|
289
|
+
if (isBothEqual) {
|
|
290
|
+
unChangedItems.push(currentItem);
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
editedItems.push(currentItem);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
for (let i = 0; i < currentItems.length; i++) {
|
|
299
|
+
const item = currentItems[i];
|
|
300
|
+
if (prevItemsMap[item._id] == null) {
|
|
301
|
+
newItems.push(item);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
if (removedItems.length > 0 && newItems.length > 0) {
|
|
305
|
+
const newItemsMap = newItems.reduce((acc, item) => {
|
|
306
|
+
acc[item.item_id] = [...(acc[item.item_id] ?? []), item];
|
|
307
|
+
return acc;
|
|
308
|
+
}, {});
|
|
309
|
+
const revertedRemovedItems = [];
|
|
310
|
+
const revertedNewItems = [];
|
|
311
|
+
const additionalNewItems = [];
|
|
312
|
+
for (let i = 0; i < removedItems.length; i++) {
|
|
313
|
+
const removedItem = removedItems[i];
|
|
314
|
+
const newItemsForItem = newItemsMap[removedItem.item_id];
|
|
315
|
+
if (newItemsForItem == null)
|
|
316
|
+
continue;
|
|
317
|
+
if (newItemsForItem.length > 0) {
|
|
318
|
+
const newItemsForItemLength = newItemsForItem.length;
|
|
319
|
+
for (let j = 0; j < newItemsForItemLength; j++) {
|
|
320
|
+
const newItem = newItemsForItem[j];
|
|
321
|
+
const newI = {
|
|
322
|
+
item_id: newItem.item_id,
|
|
323
|
+
name: newItem.name,
|
|
324
|
+
price: newItem.price,
|
|
325
|
+
special_instructions: newItem.special_instructions,
|
|
326
|
+
};
|
|
327
|
+
const removedI = {
|
|
328
|
+
item_id: removedItem.item_id,
|
|
329
|
+
name: removedItem.name,
|
|
330
|
+
price: removedItem.price,
|
|
331
|
+
special_instructions: removedItem.special_instructions,
|
|
332
|
+
};
|
|
333
|
+
if (isEqual(newI, removedI)) {
|
|
334
|
+
if (newItem.quantity === removedItem.quantity) {
|
|
335
|
+
newItemsMap[removedItem.item_id] = newItemsForItem.filter((item) => item._id !== newItem._id);
|
|
336
|
+
if (newItemsMap[removedItem.item_id].length === 0) {
|
|
337
|
+
delete newItemsMap[removedItem.item_id];
|
|
338
|
+
}
|
|
339
|
+
revertedNewItems.push(newItem);
|
|
340
|
+
revertedRemovedItems.push(removedItem);
|
|
341
|
+
break;
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
if (removedItem.quantity > newItem.quantity) {
|
|
345
|
+
newItemsMap[removedItem.item_id] = newItemsForItem.filter((item) => item._id !== newItem._id);
|
|
346
|
+
if (newItemsMap[removedItem.item_id].length === 0) {
|
|
347
|
+
delete newItemsMap[removedItem.item_id];
|
|
348
|
+
}
|
|
349
|
+
revertedNewItems.push(newItem);
|
|
350
|
+
const subtotalForSingle = removedItem.subtotal / removedItem.quantity;
|
|
351
|
+
const newQuantity = removedItem.quantity - newItem.quantity;
|
|
352
|
+
const newSubtotal = parseNum(newQuantity * subtotalForSingle);
|
|
353
|
+
removedItem.quantity = newQuantity;
|
|
354
|
+
removedItem.subtotal = newSubtotal;
|
|
355
|
+
}
|
|
356
|
+
else {
|
|
357
|
+
revertedRemovedItems.push(removedItem);
|
|
358
|
+
const nQuantity = newItem.quantity;
|
|
359
|
+
const subtotalForSingle = newItem.subtotal / nQuantity;
|
|
360
|
+
const newQuantity = nQuantity - removedItem.quantity;
|
|
361
|
+
const newSubtotal = parseNum(newQuantity * subtotalForSingle);
|
|
362
|
+
newItem.quantity = newQuantity;
|
|
363
|
+
newItem.subtotal = newSubtotal;
|
|
364
|
+
const remainingQuantity = nQuantity - newQuantity;
|
|
365
|
+
const adItem = {
|
|
366
|
+
...newItem,
|
|
367
|
+
quantity: remainingQuantity,
|
|
368
|
+
subtotal: parseNum(remainingQuantity * subtotalForSingle),
|
|
369
|
+
};
|
|
370
|
+
additionalNewItems.push(adItem);
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
else {
|
|
378
|
+
delete newItemsMap[removedItem.item_id];
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
for (let i = 0; i < revertedRemovedItems.length; i++) {
|
|
382
|
+
const rItem = revertedRemovedItems[i];
|
|
383
|
+
removedItems = removedItems.filter((item) => item._id !== rItem._id);
|
|
384
|
+
}
|
|
385
|
+
for (let i = 0; i < revertedNewItems.length; i++) {
|
|
386
|
+
const nItem = revertedNewItems[i];
|
|
387
|
+
newItems = newItems.filter((item) => item._id !== nItem._id);
|
|
388
|
+
unChangedItems.push(nItem);
|
|
389
|
+
}
|
|
390
|
+
for (let i = 0; i < additionalNewItems.length; i++) {
|
|
391
|
+
const aItem = additionalNewItems[i];
|
|
392
|
+
unChangedItems.push(aItem);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
disabledReason =
|
|
396
|
+
unChangedItems.length === prevItems.length &&
|
|
397
|
+
newItems.length === 0 &&
|
|
398
|
+
removedItems.length === 0 &&
|
|
399
|
+
editedItems.length === 0
|
|
400
|
+
? 'No changes in the order'
|
|
401
|
+
: prevItems.length === removedItems.length - totalTempRemovedItems &&
|
|
402
|
+
editedItems.length === 0 &&
|
|
403
|
+
newItems.length === 0
|
|
404
|
+
? 'At least one item is required'
|
|
405
|
+
: '';
|
|
406
|
+
}
|
|
407
|
+
const cartItemsObj = {
|
|
408
|
+
unChangedItems: getCartItems(unChangedItems),
|
|
409
|
+
editedItems: getCartItems(editedItems),
|
|
410
|
+
removedItems: getCartItems(removedItems),
|
|
411
|
+
newItems: getCartItems(newItems),
|
|
412
|
+
totalSelectedItems: parseNum(totalItemsInCart, true),
|
|
413
|
+
disabledReason,
|
|
414
|
+
isAnUpdate,
|
|
415
|
+
};
|
|
416
|
+
return cartItemsObj;
|
|
417
|
+
}
|
|
418
|
+
export function getVoidItemsWithReasonWarehouseSaleOrder({ currentCategories, iterationsFromFrontend, previousCategories, }) {
|
|
419
|
+
const voidOrderItemReasonsMap = {};
|
|
420
|
+
const latestIterationCategories = iterationsFromFrontend?.[0]?.categories;
|
|
421
|
+
if (latestIterationCategories != null && latestIterationCategories.length > 0) {
|
|
422
|
+
for (let i = 0; i < latestIterationCategories.length; i++) {
|
|
423
|
+
const category = latestIterationCategories[i];
|
|
424
|
+
for (let j = 0; j < category.items.length; j++) {
|
|
425
|
+
const item = category.items[j];
|
|
426
|
+
if (item.void_reason != null && item.void_reason.length > 0) {
|
|
427
|
+
voidOrderItemReasonsMap[item._id] = item.void_reason;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
const { newItems, removedItems } = getWarehouseSaleOrderCartItemsObj({
|
|
433
|
+
currentIterationCategories: currentCategories,
|
|
434
|
+
previousIterationCategories: previousCategories,
|
|
435
|
+
mappedItems: {},
|
|
436
|
+
shouldSortItemsViaId: false,
|
|
437
|
+
isAnEdit: true,
|
|
438
|
+
});
|
|
439
|
+
const hasNewItems = newItems.length > 0;
|
|
440
|
+
const voidOrderItems = [];
|
|
441
|
+
const newVoidOrderItemReasonsMap = {};
|
|
442
|
+
for (let i = 0; i < removedItems.length; i++) {
|
|
443
|
+
const { orderItem } = removedItems[i];
|
|
444
|
+
const voidReason = voidOrderItemReasonsMap[orderItem._id];
|
|
445
|
+
voidOrderItems.push({
|
|
446
|
+
...orderItem,
|
|
447
|
+
subtotal: Math.round(orderItem.subtotal),
|
|
448
|
+
void_reason: voidReason ?? '-',
|
|
449
|
+
});
|
|
450
|
+
if (voidReason != null) {
|
|
451
|
+
newVoidOrderItemReasonsMap[orderItem._id] = voidReason;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
const newIterationCategories = [];
|
|
455
|
+
for (let i = 0; i < previousCategories.length; i++) {
|
|
456
|
+
const category = previousCategories[i];
|
|
457
|
+
const newCategoryItems = [];
|
|
458
|
+
for (let j = 0; j < category.items.length; j++) {
|
|
459
|
+
const prevItem = category.items[j];
|
|
460
|
+
const voidReason = newVoidOrderItemReasonsMap[prevItem._id];
|
|
461
|
+
const orderItem = {
|
|
462
|
+
...prevItem,
|
|
463
|
+
subtotal: Math.round(prevItem.subtotal),
|
|
464
|
+
};
|
|
465
|
+
if (voidReason != null) {
|
|
466
|
+
orderItem.void_reason = voidReason;
|
|
467
|
+
}
|
|
468
|
+
newCategoryItems.push(orderItem);
|
|
469
|
+
}
|
|
470
|
+
if (newCategoryItems.length === 0)
|
|
471
|
+
continue;
|
|
472
|
+
newIterationCategories.push({
|
|
473
|
+
...category,
|
|
474
|
+
items: newCategoryItems,
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
return {
|
|
478
|
+
categories: newIterationCategories,
|
|
479
|
+
voidOrderItems,
|
|
480
|
+
hasNewItems,
|
|
481
|
+
voidItemsCount: voidOrderItems.length,
|
|
482
|
+
};
|
|
483
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { convertDecimalToInt, convertIntToDecimal } from '../utils';
|
|
2
|
+
import { getOrderPaymentsCardDetailsWithPrice } from './common-order-actions';
|
|
3
|
+
/**
|
|
4
|
+
* Convert unit_price on every financial line (invoice items).
|
|
5
|
+
*/
|
|
6
|
+
export function getWarehouseSaleOrderInvoiceLinesWithPrice(lines, convertToPrice) {
|
|
7
|
+
if (!lines)
|
|
8
|
+
return [];
|
|
9
|
+
return lines.map((line) => ({
|
|
10
|
+
...line,
|
|
11
|
+
unit_price: convertToPrice(line.unit_price),
|
|
12
|
+
}));
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Convert payments on a sale-order invoice.
|
|
16
|
+
*/
|
|
17
|
+
export function getWarehouseSaleOrderInvoicePaymentsWithPrice(payments, convertToPrice) {
|
|
18
|
+
if (!payments)
|
|
19
|
+
return [];
|
|
20
|
+
return payments.map((payment) => ({
|
|
21
|
+
...payment,
|
|
22
|
+
card_details: getOrderPaymentsCardDetailsWithPrice(payment.card_details, convertToPrice),
|
|
23
|
+
amount_paid: convertToPrice(payment.amount_paid),
|
|
24
|
+
amount_due: convertToPrice(payment.amount_due),
|
|
25
|
+
amount_refunded: convertToPrice(payment.amount_refunded),
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Convert all monetary fields on a sale-order invoice / credit note.
|
|
30
|
+
*
|
|
31
|
+
* - `writeable = true` → decimal → cents (before sending to backend)
|
|
32
|
+
* - `writeable = false` → cents → decimal (after receiving from backend)
|
|
33
|
+
*/
|
|
34
|
+
export function getWarehouseSaleOrderInvoiceWithPrice(order, writeable) {
|
|
35
|
+
const convertToPrice = writeable ? convertDecimalToInt : convertIntToDecimal;
|
|
36
|
+
return {
|
|
37
|
+
...order,
|
|
38
|
+
...(order.items != null
|
|
39
|
+
? {
|
|
40
|
+
items: getWarehouseSaleOrderInvoiceLinesWithPrice(order.items, convertToPrice),
|
|
41
|
+
}
|
|
42
|
+
: {}),
|
|
43
|
+
...(order.payments != null
|
|
44
|
+
? {
|
|
45
|
+
payments: getWarehouseSaleOrderInvoicePaymentsWithPrice(order.payments, convertToPrice),
|
|
46
|
+
}
|
|
47
|
+
: {}),
|
|
48
|
+
...(order.amount != null ? { amount: convertToPrice(order.amount) } : {}),
|
|
49
|
+
...(order.amount_paid != null ? { amount_paid: convertToPrice(order.amount_paid) } : {}),
|
|
50
|
+
...(order.down_payment_value != null ? { down_payment_value: convertToPrice(order.down_payment_value) } : {}),
|
|
51
|
+
...(order.gst != null ? { gst: convertToPrice(order.gst) } : {}),
|
|
52
|
+
...(order.gst_amount != null ? { gst_amount: convertToPrice(order.gst_amount) } : {}),
|
|
53
|
+
};
|
|
54
|
+
}
|