@managesome/eposmatic-toolkit 0.2.212
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/LICENSE +13 -0
- package/lib/constants/ANALYTICS.d.ts +477 -0
- package/lib/constants/ANALYTICS.js +148 -0
- package/lib/constants/COMMON.d.ts +72 -0
- package/lib/constants/COMMON.js +334 -0
- package/lib/constants/DELIVERY.d.ts +14 -0
- package/lib/constants/DELIVERY.js +48 -0
- package/lib/constants/ENUMS.d.ts +1008 -0
- package/lib/constants/ENUMS.js +1693 -0
- package/lib/constants/FBR_ENUMS.d.ts +15 -0
- package/lib/constants/FBR_ENUMS.js +21 -0
- package/lib/constants/HUBRISE_ENUMS.d.ts +74 -0
- package/lib/constants/HUBRISE_ENUMS.js +182 -0
- package/lib/constants/NOTIFICATIONS.d.ts +5 -0
- package/lib/constants/NOTIFICATIONS.js +9 -0
- package/lib/constants/ORDER.d.ts +15 -0
- package/lib/constants/ORDER.js +242 -0
- package/lib/constants/PRA_ENUMS.d.ts +15 -0
- package/lib/constants/PRA_ENUMS.js +21 -0
- package/lib/constants/PURCHASE_ORDER.d.ts +14 -0
- package/lib/constants/PURCHASE_ORDER.js +53 -0
- package/lib/constants/SMARTPAY_ENUMS.d.ts +42 -0
- package/lib/constants/SMARTPAY_ENUMS.js +58 -0
- package/lib/constants/SOCKET.d.ts +95 -0
- package/lib/constants/SOCKET.js +135 -0
- package/lib/constants/SRB_ENUMS.d.ts +10 -0
- package/lib/constants/SRB_ENUMS.js +16 -0
- package/lib/constants/SWITCHPAY.d.ts +4 -0
- package/lib/constants/SWITCHPAY.js +8 -0
- package/lib/constants/WALLET.d.ts +13 -0
- package/lib/constants/WALLET.js +54 -0
- package/lib/constants/WAREHOUSE_ANALYTICS.d.ts +239 -0
- package/lib/constants/WAREHOUSE_ANALYTICS.js +31 -0
- package/lib/constants/WAREHOUSE_INVOICE.d.ts +14 -0
- package/lib/constants/WAREHOUSE_INVOICE.js +35 -0
- package/lib/constants/WEBVIEW.d.ts +44 -0
- package/lib/constants/WEBVIEW.js +50 -0
- package/lib/constants/index.d.ts +19 -0
- package/lib/constants/index.js +35 -0
- package/lib/constants/types.d.ts +408 -0
- package/lib/constants/types.js +3 -0
- package/lib/helpers/fbr/generate-invoice.d.ts +10 -0
- package/lib/helpers/fbr/generate-invoice.js +97 -0
- package/lib/helpers/fbr/index.d.ts +1 -0
- package/lib/helpers/fbr/index.js +17 -0
- package/lib/helpers/hubrise/hubrise-catalog.d.ts +43 -0
- package/lib/helpers/hubrise/hubrise-catalog.js +314 -0
- package/lib/helpers/hubrise/index.d.ts +1 -0
- package/lib/helpers/hubrise/index.js +17 -0
- package/lib/helpers/index.d.ts +9 -0
- package/lib/helpers/index.js +25 -0
- package/lib/helpers/kpra/generate-invoice.d.ts +8 -0
- package/lib/helpers/kpra/generate-invoice.js +29 -0
- package/lib/helpers/kpra/index.d.ts +1 -0
- package/lib/helpers/kpra/index.js +17 -0
- package/lib/helpers/order/generate-order.d.ts +12 -0
- package/lib/helpers/order/generate-order.js +409 -0
- package/lib/helpers/order/generate-purchase-order.d.ts +11 -0
- package/lib/helpers/order/generate-purchase-order.js +196 -0
- package/lib/helpers/order/generate-warehouse-invoice.d.ts +11 -0
- package/lib/helpers/order/generate-warehouse-invoice.js +196 -0
- package/lib/helpers/order/index.d.ts +3 -0
- package/lib/helpers/order/index.js +19 -0
- package/lib/helpers/pra/generate-invoice.d.ts +10 -0
- package/lib/helpers/pra/generate-invoice.js +97 -0
- package/lib/helpers/pra/index.d.ts +1 -0
- package/lib/helpers/pra/index.js +17 -0
- package/lib/helpers/srb/generate-invoice.d.ts +13 -0
- package/lib/helpers/srb/generate-invoice.js +48 -0
- package/lib/helpers/srb/index.d.ts +1 -0
- package/lib/helpers/srb/index.js +17 -0
- package/lib/helpers/store/all-orders-actions.d.ts +5 -0
- package/lib/helpers/store/all-orders-actions.js +23 -0
- package/lib/helpers/store/all-purchase-orders-actions.d.ts +13 -0
- package/lib/helpers/store/all-purchase-orders-actions.js +56 -0
- package/lib/helpers/store/all-warehouse-invoice-actions.d.ts +13 -0
- package/lib/helpers/store/all-warehouse-invoice-actions.js +58 -0
- package/lib/helpers/store/cart-actions.d.ts +159 -0
- package/lib/helpers/store/cart-actions.js +2070 -0
- package/lib/helpers/store/catalog-actions.d.ts +23 -0
- package/lib/helpers/store/catalog-actions.js +216 -0
- package/lib/helpers/store/common-order-actions.d.ts +36 -0
- package/lib/helpers/store/common-order-actions.js +878 -0
- package/lib/helpers/store/common-purchase-order-actions.d.ts +31 -0
- package/lib/helpers/store/common-purchase-order-actions.js +543 -0
- package/lib/helpers/store/common-warehouse-invoice-actions.d.ts +31 -0
- package/lib/helpers/store/common-warehouse-invoice-actions.js +545 -0
- package/lib/helpers/store/index.d.ts +11 -0
- package/lib/helpers/store/index.js +27 -0
- package/lib/helpers/store/offline-ordering.d.ts +15 -0
- package/lib/helpers/store/offline-ordering.js +258 -0
- package/lib/helpers/store/purchase-orders-cart-actions.d.ts +56 -0
- package/lib/helpers/store/purchase-orders-cart-actions.js +486 -0
- package/lib/helpers/store/warehouse-cart-actions.d.ts +54 -0
- package/lib/helpers/store/warehouse-cart-actions.js +486 -0
- package/lib/helpers/store/warehouse-catalog-actions.d.ts +4 -0
- package/lib/helpers/store/warehouse-catalog-actions.js +46 -0
- package/lib/helpers/store/warehouse-invoice-cart-actions.d.ts +56 -0
- package/lib/helpers/store/warehouse-invoice-cart-actions.js +486 -0
- package/lib/helpers/types/cart-actions.d.ts +33 -0
- package/lib/helpers/types/cart-actions.js +2 -0
- package/lib/helpers/types/cart-helpers.d.ts +7 -0
- package/lib/helpers/types/cart-helpers.js +2 -0
- package/lib/helpers/types/catalog.d.ts +149 -0
- package/lib/helpers/types/catalog.js +2 -0
- package/lib/helpers/types/common.d.ts +69 -0
- package/lib/helpers/types/common.js +2 -0
- package/lib/helpers/types/deliverect_menu.d.ts +51 -0
- package/lib/helpers/types/deliverect_menu.js +2 -0
- package/lib/helpers/types/email-templates.d.ts +173 -0
- package/lib/helpers/types/email-templates.js +2 -0
- package/lib/helpers/types/fbr-generate-invoice.d.ts +40 -0
- package/lib/helpers/types/fbr-generate-invoice.js +2 -0
- package/lib/helpers/types/hubrise_catalog.d.ts +123 -0
- package/lib/helpers/types/hubrise_catalog.js +2 -0
- package/lib/helpers/types/hubrise_customers.d.ts +36 -0
- package/lib/helpers/types/hubrise_customers.js +2 -0
- package/lib/helpers/types/hubrise_deliveries.d.ts +19 -0
- package/lib/helpers/types/hubrise_deliveries.js +2 -0
- package/lib/helpers/types/hubrise_location.d.ts +31 -0
- package/lib/helpers/types/hubrise_location.js +2 -0
- package/lib/helpers/types/hubrise_orders.d.ts +86 -0
- package/lib/helpers/types/hubrise_orders.js +2 -0
- package/lib/helpers/types/index.d.ts +25 -0
- package/lib/helpers/types/index.js +41 -0
- package/lib/helpers/types/internal-leads.d.ts +11 -0
- package/lib/helpers/types/internal-leads.js +2 -0
- package/lib/helpers/types/kpra-generate-invoice.d.ts +6 -0
- package/lib/helpers/types/kpra-generate-invoice.js +2 -0
- package/lib/helpers/types/marketing.d.ts +12 -0
- package/lib/helpers/types/marketing.js +2 -0
- package/lib/helpers/types/order-engine.d.ts +39 -0
- package/lib/helpers/types/order-engine.js +2 -0
- package/lib/helpers/types/pra-generate-invoice.d.ts +40 -0
- package/lib/helpers/types/pra-generate-invoice.js +2 -0
- package/lib/helpers/types/printer-settings.d.ts +11 -0
- package/lib/helpers/types/printer-settings.js +3 -0
- package/lib/helpers/types/purchase-order-cart-actions.d.ts +26 -0
- package/lib/helpers/types/purchase-order-cart-actions.js +2 -0
- package/lib/helpers/types/reports.d.ts +150 -0
- package/lib/helpers/types/reports.js +2 -0
- package/lib/helpers/types/smartpay-apis.d.ts +170 -0
- package/lib/helpers/types/smartpay-apis.js +3 -0
- package/lib/helpers/types/split_bill.d.ts +20 -0
- package/lib/helpers/types/split_bill.js +2 -0
- package/lib/helpers/types/srb-generate-invoice.d.ts +27 -0
- package/lib/helpers/types/srb-generate-invoice.js +2 -0
- package/lib/helpers/types/switchpay.d.ts +10 -0
- package/lib/helpers/types/switchpay.js +2 -0
- package/lib/helpers/types/usable-offers.d.ts +27 -0
- package/lib/helpers/types/usable-offers.js +2 -0
- package/lib/helpers/types/warehouse-cart-actions.d.ts +51 -0
- package/lib/helpers/types/warehouse-cart-actions.js +2 -0
- package/lib/helpers/types/warehouse-catalog.d.ts +4 -0
- package/lib/helpers/types/warehouse-catalog.js +2 -0
- package/lib/helpers/types/warehouse-invoice-cart-actions.d.ts +26 -0
- package/lib/helpers/types/warehouse-invoice-cart-actions.js +2 -0
- package/lib/helpers/types/workers.d.ts +256 -0
- package/lib/helpers/types/workers.js +2 -0
- package/lib/helpers/utils/cart-helpers.d.ts +48 -0
- package/lib/helpers/utils/cart-helpers.js +151 -0
- package/lib/helpers/utils/catalog-conversion.d.ts +9 -0
- package/lib/helpers/utils/catalog-conversion.js +123 -0
- package/lib/helpers/utils/color-helpers.d.ts +3 -0
- package/lib/helpers/utils/color-helpers.js +36 -0
- package/lib/helpers/utils/common.d.ts +36 -0
- package/lib/helpers/utils/common.js +332 -0
- package/lib/helpers/utils/comparison-report-helpers.d.ts +27 -0
- package/lib/helpers/utils/comparison-report-helpers.js +802 -0
- package/lib/helpers/utils/comparitive-report-helpers.d.ts +7 -0
- package/lib/helpers/utils/comparitive-report-helpers.js +826 -0
- package/lib/helpers/utils/crypt.d.ts +4 -0
- package/lib/helpers/utils/crypt.js +49 -0
- package/lib/helpers/utils/customers-helpers.d.ts +2 -0
- package/lib/helpers/utils/customers-helpers.js +17 -0
- package/lib/helpers/utils/delivery-area-helpers.d.ts +4 -0
- package/lib/helpers/utils/delivery-area-helpers.js +47 -0
- package/lib/helpers/utils/delivery-helpers.d.ts +2 -0
- package/lib/helpers/utils/delivery-helpers.js +15 -0
- package/lib/helpers/utils/dinein.d.ts +10 -0
- package/lib/helpers/utils/dinein.js +47 -0
- package/lib/helpers/utils/discount-helpers.d.ts +8 -0
- package/lib/helpers/utils/discount-helpers.js +59 -0
- package/lib/helpers/utils/email-helpers.d.ts +17 -0
- package/lib/helpers/utils/email-helpers.js +99 -0
- package/lib/helpers/utils/error-helpers.d.ts +9 -0
- package/lib/helpers/utils/error-helpers.js +18 -0
- package/lib/helpers/utils/expense.d.ts +4 -0
- package/lib/helpers/utils/expense.js +42 -0
- package/lib/helpers/utils/getFormFieldsDiff.d.ts +3 -0
- package/lib/helpers/utils/getFormFieldsDiff.js +18 -0
- package/lib/helpers/utils/halfhalf-setup-helpers.d.ts +22 -0
- package/lib/helpers/utils/halfhalf-setup-helpers.js +133 -0
- package/lib/helpers/utils/hourly-comparison-report-helpers.d.ts +50 -0
- package/lib/helpers/utils/hourly-comparison-report-helpers.js +861 -0
- package/lib/helpers/utils/hubrise-utils.d.ts +11 -0
- package/lib/helpers/utils/hubrise-utils.js +38 -0
- package/lib/helpers/utils/image-helpers.d.ts +3 -0
- package/lib/helpers/utils/image-helpers.js +100 -0
- package/lib/helpers/utils/index.d.ts +68 -0
- package/lib/helpers/utils/index.js +84 -0
- package/lib/helpers/utils/ingredients.d.ts +3 -0
- package/lib/helpers/utils/ingredients.js +30 -0
- package/lib/helpers/utils/inventory.d.ts +4 -0
- package/lib/helpers/utils/inventory.js +122 -0
- package/lib/helpers/utils/inventory_transactions.d.ts +3 -0
- package/lib/helpers/utils/inventory_transactions.js +95 -0
- package/lib/helpers/utils/invoice-x-report-helpers.d.ts +58 -0
- package/lib/helpers/utils/invoice-x-report-helpers.js +1432 -0
- package/lib/helpers/utils/item-report-helpers.d.ts +28 -0
- package/lib/helpers/utils/item-report-helpers.js +2494 -0
- package/lib/helpers/utils/items-comparison-report-helpers.d.ts +30 -0
- package/lib/helpers/utils/items-comparison-report-helpers.js +1066 -0
- package/lib/helpers/utils/kds-helpers.d.ts +8 -0
- package/lib/helpers/utils/kds-helpers.js +46 -0
- package/lib/helpers/utils/location-helpers.d.ts +1 -0
- package/lib/helpers/utils/location-helpers.js +16 -0
- package/lib/helpers/utils/menu-helpers.d.ts +8 -0
- package/lib/helpers/utils/menu-helpers.js +48 -0
- package/lib/helpers/utils/minified-catalog.d.ts +17 -0
- package/lib/helpers/utils/minified-catalog.js +440 -0
- package/lib/helpers/utils/offers-helpers.d.ts +47 -0
- package/lib/helpers/utils/offers-helpers.js +899 -0
- package/lib/helpers/utils/operational-roles-helpers.d.ts +2 -0
- package/lib/helpers/utils/operational-roles-helpers.js +36 -0
- package/lib/helpers/utils/order-engine.d.ts +48 -0
- package/lib/helpers/utils/order-engine.js +754 -0
- package/lib/helpers/utils/order-history.d.ts +15 -0
- package/lib/helpers/utils/order-history.js +211 -0
- package/lib/helpers/utils/payment-comparison-report-helpers.d.ts +16 -0
- package/lib/helpers/utils/payment-comparison-report-helpers.js +882 -0
- package/lib/helpers/utils/payment-helpers.d.ts +38 -0
- package/lib/helpers/utils/payment-helpers.js +285 -0
- package/lib/helpers/utils/pdf-generator.d.ts +19 -0
- package/lib/helpers/utils/pdf-generator.js +115 -0
- package/lib/helpers/utils/platform-catalog.d.ts +11 -0
- package/lib/helpers/utils/platform-catalog.js +234 -0
- package/lib/helpers/utils/platform-num.d.ts +9 -0
- package/lib/helpers/utils/platform-num.js +128 -0
- package/lib/helpers/utils/platform-specific-tenant-shifts.d.ts +8 -0
- package/lib/helpers/utils/platform-specific-tenant-shifts.js +22 -0
- package/lib/helpers/utils/price-conversion.d.ts +6 -0
- package/lib/helpers/utils/price-conversion.js +32 -0
- package/lib/helpers/utils/printer-helpers.d.ts +3 -0
- package/lib/helpers/utils/printer-helpers.js +74 -0
- package/lib/helpers/utils/public-holidays-helpers.d.ts +2 -0
- package/lib/helpers/utils/public-holidays-helpers.js +11 -0
- package/lib/helpers/utils/purchase-order-engine.d.ts +9 -0
- package/lib/helpers/utils/purchase-order-engine.js +34 -0
- package/lib/helpers/utils/purchase-order-receipt-engine.d.ts +149 -0
- package/lib/helpers/utils/purchase-order-receipt-engine.js +214 -0
- package/lib/helpers/utils/purchase-order-x-report-helpers.d.ts +58 -0
- package/lib/helpers/utils/purchase-order-x-report-helpers.js +1440 -0
- package/lib/helpers/utils/ratings-comparison-report-helpers.d.ts +37 -0
- package/lib/helpers/utils/ratings-comparison-report-helpers.js +1194 -0
- package/lib/helpers/utils/receipt-engine.d.ts +165 -0
- package/lib/helpers/utils/receipt-engine.js +856 -0
- package/lib/helpers/utils/review-helpers.d.ts +9 -0
- package/lib/helpers/utils/review-helpers.js +398 -0
- package/lib/helpers/utils/rider-tracking.d.ts +1 -0
- package/lib/helpers/utils/rider-tracking.js +16 -0
- package/lib/helpers/utils/riders-report-helpers.d.ts +62 -0
- package/lib/helpers/utils/riders-report-helpers.js +1598 -0
- package/lib/helpers/utils/sales-comparison-report-helpers.d.ts +31 -0
- package/lib/helpers/utils/sales-comparison-report-helpers.js +1266 -0
- package/lib/helpers/utils/sales-comparitive-report-helpers.d.ts +7 -0
- package/lib/helpers/utils/sales-comparitive-report-helpers.js +945 -0
- package/lib/helpers/utils/sales-overview-report-helpers.d.ts +30 -0
- package/lib/helpers/utils/sales-overview-report-helpers.js +1052 -0
- package/lib/helpers/utils/sales-summary-report-helpers.d.ts +30 -0
- package/lib/helpers/utils/sales-summary-report-helpers.js +883 -0
- package/lib/helpers/utils/short-inventory.d.ts +3 -0
- package/lib/helpers/utils/short-inventory.js +26 -0
- package/lib/helpers/utils/simplified-catalog.d.ts +8 -0
- package/lib/helpers/utils/simplified-catalog.js +115 -0
- package/lib/helpers/utils/simplified-tenant.d.ts +255 -0
- package/lib/helpers/utils/simplified-tenant.js +337 -0
- package/lib/helpers/utils/simplified-warehouse-catalog.d.ts +10 -0
- package/lib/helpers/utils/simplified-warehouse-catalog.js +108 -0
- package/lib/helpers/utils/specials-helpers.d.ts +42 -0
- package/lib/helpers/utils/specials-helpers.js +216 -0
- package/lib/helpers/utils/stock-details.d.ts +3 -0
- package/lib/helpers/utils/stock-details.js +26 -0
- package/lib/helpers/utils/stock-wastage.d.ts +3 -0
- package/lib/helpers/utils/stock-wastage.js +26 -0
- package/lib/helpers/utils/tenant-staff-helpers.d.ts +2 -0
- package/lib/helpers/utils/tenant-staff-helpers.js +22 -0
- package/lib/helpers/utils/terminal-devices-helpers.d.ts +2 -0
- package/lib/helpers/utils/terminal-devices-helpers.js +13 -0
- package/lib/helpers/utils/time-helpers.d.ts +16 -0
- package/lib/helpers/utils/time-helpers.js +57 -0
- package/lib/helpers/utils/void-items-report-helpers.d.ts +13 -0
- package/lib/helpers/utils/void-items-report-helpers.js +526 -0
- package/lib/helpers/utils/void-order-items-helpers.d.ts +3 -0
- package/lib/helpers/utils/void-order-items-helpers.js +36 -0
- package/lib/helpers/utils/voidations-summary-report-helpers.d.ts +24 -0
- package/lib/helpers/utils/voidations-summary-report-helpers.js +807 -0
- package/lib/helpers/utils/wallet-helpers.d.ts +2 -0
- package/lib/helpers/utils/wallet-helpers.js +25 -0
- package/lib/helpers/utils/warehouse-catalog-conversion.d.ts +7 -0
- package/lib/helpers/utils/warehouse-catalog-conversion.js +89 -0
- package/lib/helpers/utils/warehouse-inventory.d.ts +2 -0
- package/lib/helpers/utils/warehouse-inventory.js +53 -0
- package/lib/helpers/utils/warehouse-invoice-order-engine.d.ts +11 -0
- package/lib/helpers/utils/warehouse-invoice-order-engine.js +39 -0
- package/lib/helpers/utils/warehouse-order-engine.d.ts +9 -0
- package/lib/helpers/utils/warehouse-order-engine.js +34 -0
- package/lib/helpers/utils/warehouse-settings-helpers.d.ts +2 -0
- package/lib/helpers/utils/warehouse-settings-helpers.js +30 -0
- package/lib/helpers/utils/warehouse_inventory_transactions.d.ts +3 -0
- package/lib/helpers/utils/warehouse_inventory_transactions.js +95 -0
- package/lib/helpers/utils/x-report-helpers.d.ts +65 -0
- package/lib/helpers/utils/x-report-helpers.js +1858 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +19 -0
- package/lib/schemas/index.d.ts +2 -0
- package/lib/schemas/index.js +18 -0
- package/lib/schemas/models/app_configs.d.ts +34 -0
- package/lib/schemas/models/app_configs.js +39 -0
- package/lib/schemas/models/applied-order-discounts.d.ts +80 -0
- package/lib/schemas/models/applied-order-discounts.js +106 -0
- package/lib/schemas/models/brand.d.ts +45 -0
- package/lib/schemas/models/brand.js +45 -0
- package/lib/schemas/models/cash_drawer_sessions.d.ts +107 -0
- package/lib/schemas/models/cash_drawer_sessions.js +78 -0
- package/lib/schemas/models/cash_drawers.d.ts +44 -0
- package/lib/schemas/models/cash_drawers.js +46 -0
- package/lib/schemas/models/cash_in_out.d.ts +110 -0
- package/lib/schemas/models/cash_in_out.js +81 -0
- package/lib/schemas/models/category.d.ts +60 -0
- package/lib/schemas/models/category.js +67 -0
- package/lib/schemas/models/close_dates.d.ts +50 -0
- package/lib/schemas/models/close_dates.js +56 -0
- package/lib/schemas/models/common-models.d.ts +493 -0
- package/lib/schemas/models/common-models.js +444 -0
- package/lib/schemas/models/courses.d.ts +77 -0
- package/lib/schemas/models/courses.js +55 -0
- package/lib/schemas/models/customers.d.ts +443 -0
- package/lib/schemas/models/customers.js +197 -0
- package/lib/schemas/models/deliveries.d.ts +123 -0
- package/lib/schemas/models/deliveries.js +112 -0
- package/lib/schemas/models/delivery_areas.d.ts +263 -0
- package/lib/schemas/models/delivery_areas.js +100 -0
- package/lib/schemas/models/dinein_floors.d.ts +44 -0
- package/lib/schemas/models/dinein_floors.js +45 -0
- package/lib/schemas/models/dinein_table_fingerprints.d.ts +65 -0
- package/lib/schemas/models/dinein_table_fingerprints.js +85 -0
- package/lib/schemas/models/dinein_tables.d.ts +68 -0
- package/lib/schemas/models/dinein_tables.js +82 -0
- package/lib/schemas/models/discounts.d.ts +1254 -0
- package/lib/schemas/models/discounts.js +90 -0
- package/lib/schemas/models/drivers.d.ts +55 -0
- package/lib/schemas/models/drivers.js +60 -0
- package/lib/schemas/models/expense_category.d.ts +83 -0
- package/lib/schemas/models/expense_category.js +64 -0
- package/lib/schemas/models/expense_details.d.ts +266 -0
- package/lib/schemas/models/expense_details.js +113 -0
- package/lib/schemas/models/halfhalf_setup.d.ts +1541 -0
- package/lib/schemas/models/halfhalf_setup.js +109 -0
- package/lib/schemas/models/index.d.ts +65 -0
- package/lib/schemas/models/index.js +81 -0
- package/lib/schemas/models/instore_shift_sessions.d.ts +146 -0
- package/lib/schemas/models/instore_shift_sessions.js +125 -0
- package/lib/schemas/models/instore_shifts.d.ts +50 -0
- package/lib/schemas/models/instore_shifts.js +55 -0
- package/lib/schemas/models/internal_expense_details.d.ts +55 -0
- package/lib/schemas/models/internal_expense_details.js +63 -0
- package/lib/schemas/models/internal_leads.d.ts +69 -0
- package/lib/schemas/models/internal_leads.js +81 -0
- package/lib/schemas/models/internal_restaurant_details.d.ts +64 -0
- package/lib/schemas/models/internal_restaurant_details.js +77 -0
- package/lib/schemas/models/inventory.d.ts +99 -0
- package/lib/schemas/models/inventory.js +87 -0
- package/lib/schemas/models/inventory_categories.d.ts +50 -0
- package/lib/schemas/models/inventory_categories.js +55 -0
- package/lib/schemas/models/inventory_transactions.d.ts +83 -0
- package/lib/schemas/models/inventory_transactions.js +110 -0
- package/lib/schemas/models/item.d.ts +10822 -0
- package/lib/schemas/models/item.js +329 -0
- package/lib/schemas/models/item_transactions.d.ts +71 -0
- package/lib/schemas/models/item_transactions.js +95 -0
- package/lib/schemas/models/marketing_fingerprints.d.ts +62 -0
- package/lib/schemas/models/marketing_fingerprints.js +81 -0
- package/lib/schemas/models/menu.d.ts +905 -0
- package/lib/schemas/models/menu.js +69 -0
- package/lib/schemas/models/messaging_devices.d.ts +63 -0
- package/lib/schemas/models/messaging_devices.js +74 -0
- package/lib/schemas/models/modifier_extras.d.ts +516 -0
- package/lib/schemas/models/modifier_extras.js +123 -0
- package/lib/schemas/models/offers.d.ts +1067 -0
- package/lib/schemas/models/offers.js +286 -0
- package/lib/schemas/models/offers_fingerprints.d.ts +50 -0
- package/lib/schemas/models/offers_fingerprints.js +63 -0
- package/lib/schemas/models/operational_roles.d.ts +263 -0
- package/lib/schemas/models/operational_roles.js +158 -0
- package/lib/schemas/models/order.d.ts +15284 -0
- package/lib/schemas/models/order.js +819 -0
- package/lib/schemas/models/platform.d.ts +34 -0
- package/lib/schemas/models/platform.js +30 -0
- package/lib/schemas/models/printer_settings.d.ts +217 -0
- package/lib/schemas/models/printer_settings.js +234 -0
- package/lib/schemas/models/public_holidays.d.ts +173 -0
- package/lib/schemas/models/public_holidays.js +61 -0
- package/lib/schemas/models/purchase_orders.d.ts +2675 -0
- package/lib/schemas/models/purchase_orders.js +327 -0
- package/lib/schemas/models/reservations.d.ts +66 -0
- package/lib/schemas/models/reservations.js +88 -0
- package/lib/schemas/models/reviews.d.ts +98 -0
- package/lib/schemas/models/reviews.js +148 -0
- package/lib/schemas/models/rider.d.ts +65 -0
- package/lib/schemas/models/rider.js +74 -0
- package/lib/schemas/models/short_inventory.d.ts +65 -0
- package/lib/schemas/models/short_inventory.js +46 -0
- package/lib/schemas/models/specials.d.ts +2551 -0
- package/lib/schemas/models/specials.js +145 -0
- package/lib/schemas/models/staff_shifts.d.ts +77 -0
- package/lib/schemas/models/staff_shifts.js +69 -0
- package/lib/schemas/models/stock_consumption.d.ts +77 -0
- package/lib/schemas/models/stock_consumption.js +64 -0
- package/lib/schemas/models/stock_entry.d.ts +65 -0
- package/lib/schemas/models/stock_entry.js +46 -0
- package/lib/schemas/models/stock_wastage.d.ts +71 -0
- package/lib/schemas/models/stock_wastage.js +54 -0
- package/lib/schemas/models/tenant.d.ts +468 -0
- package/lib/schemas/models/tenant.js +673 -0
- package/lib/schemas/models/tenant_days.d.ts +134 -0
- package/lib/schemas/models/tenant_days.js +110 -0
- package/lib/schemas/models/tenant_metadata.d.ts +77 -0
- package/lib/schemas/models/tenant_metadata.js +91 -0
- package/lib/schemas/models/tenant_shift_sessions.d.ts +146 -0
- package/lib/schemas/models/tenant_shift_sessions.js +125 -0
- package/lib/schemas/models/tenant_shifts.d.ts +53 -0
- package/lib/schemas/models/tenant_shifts.js +60 -0
- package/lib/schemas/models/tenant_staff.d.ts +896 -0
- package/lib/schemas/models/tenant_staff.js +96 -0
- package/lib/schemas/models/terminal_devices.d.ts +62 -0
- package/lib/schemas/models/terminal_devices.js +74 -0
- package/lib/schemas/models/tokens.d.ts +59 -0
- package/lib/schemas/models/tokens.js +109 -0
- package/lib/schemas/models/track_order_number.d.ts +395 -0
- package/lib/schemas/models/track_order_number.js +45 -0
- package/lib/schemas/models/void_order_items.d.ts +173 -0
- package/lib/schemas/models/void_order_items.js +169 -0
- package/lib/schemas/models/wallet.d.ts +38 -0
- package/lib/schemas/models/wallet.js +37 -0
- package/lib/schemas/models/wallet_transactions.d.ts +74 -0
- package/lib/schemas/models/wallet_transactions.js +96 -0
- package/lib/schemas/models/warehouse.d.ts +156 -0
- package/lib/schemas/models/warehouse.js +213 -0
- package/lib/schemas/models/warehouse_categories.d.ts +56 -0
- package/lib/schemas/models/warehouse_categories.js +65 -0
- package/lib/schemas/models/warehouse_clients.d.ts +53 -0
- package/lib/schemas/models/warehouse_clients.js +61 -0
- package/lib/schemas/models/warehouse_inventory_transactions.d.ts +83 -0
- package/lib/schemas/models/warehouse_inventory_transactions.js +110 -0
- package/lib/schemas/models/warehouse_invoices.d.ts +2675 -0
- package/lib/schemas/models/warehouse_invoices.js +327 -0
- package/lib/schemas/models/warehouse_item_transactions.d.ts +74 -0
- package/lib/schemas/models/warehouse_item_transactions.js +100 -0
- package/lib/schemas/models/warehouse_items.d.ts +131 -0
- package/lib/schemas/models/warehouse_items.js +127 -0
- package/lib/schemas/models/warehouse_operational_roles.d.ts +77 -0
- package/lib/schemas/models/warehouse_operational_roles.js +90 -0
- package/lib/schemas/models/warehouse_settings.d.ts +40 -0
- package/lib/schemas/models/warehouse_settings.js +40 -0
- package/lib/schemas/models/warehouse_staff.d.ts +65 -0
- package/lib/schemas/models/warehouse_staff.js +78 -0
- package/lib/schemas/models/warehouse_track_order_number.d.ts +50 -0
- package/lib/schemas/models/warehouse_track_order_number.js +52 -0
- package/lib/schemas/models/warehouse_vendors.d.ts +89 -0
- package/lib/schemas/models/warehouse_vendors.js +73 -0
- package/lib/schemas/types/app_configs.d.ts +9 -0
- package/lib/schemas/types/app_configs.js +2 -0
- package/lib/schemas/types/applied-order-discounts.d.ts +22 -0
- package/lib/schemas/types/applied-order-discounts.js +2 -0
- package/lib/schemas/types/brand.d.ts +32 -0
- package/lib/schemas/types/brand.js +2 -0
- package/lib/schemas/types/cash_drawer_sessions.d.ts +18 -0
- package/lib/schemas/types/cash_drawer_sessions.js +2 -0
- package/lib/schemas/types/cash_drawers.d.ts +9 -0
- package/lib/schemas/types/cash_drawers.js +2 -0
- package/lib/schemas/types/cash_in_out.d.ts +19 -0
- package/lib/schemas/types/cash_in_out.js +2 -0
- package/lib/schemas/types/category.d.ts +15 -0
- package/lib/schemas/types/category.js +2 -0
- package/lib/schemas/types/close_dates.d.ts +12 -0
- package/lib/schemas/types/close_dates.js +2 -0
- package/lib/schemas/types/common.d.ts +34 -0
- package/lib/schemas/types/common.js +2 -0
- package/lib/schemas/types/courses.d.ts +15 -0
- package/lib/schemas/types/courses.js +2 -0
- package/lib/schemas/types/customers.d.ts +51 -0
- package/lib/schemas/types/customers.js +2 -0
- package/lib/schemas/types/deliveries.d.ts +28 -0
- package/lib/schemas/types/deliveries.js +2 -0
- package/lib/schemas/types/delivery_areas.d.ts +23 -0
- package/lib/schemas/types/delivery_areas.js +2 -0
- package/lib/schemas/types/dinein_floors.d.ts +23 -0
- package/lib/schemas/types/dinein_floors.js +2 -0
- package/lib/schemas/types/dinein_tables.d.ts +19 -0
- package/lib/schemas/types/dinein_tables.js +2 -0
- package/lib/schemas/types/dinein_tables_fingerprints.d.ts +17 -0
- package/lib/schemas/types/dinein_tables_fingerprints.js +2 -0
- package/lib/schemas/types/discounts.d.ts +21 -0
- package/lib/schemas/types/discounts.js +2 -0
- package/lib/schemas/types/drivers.d.ts +13 -0
- package/lib/schemas/types/drivers.js +2 -0
- package/lib/schemas/types/expense_category.d.ts +20 -0
- package/lib/schemas/types/expense_category.js +2 -0
- package/lib/schemas/types/expense_details.d.ts +26 -0
- package/lib/schemas/types/expense_details.js +2 -0
- package/lib/schemas/types/halfhalf_setup.d.ts +26 -0
- package/lib/schemas/types/halfhalf_setup.js +2 -0
- package/lib/schemas/types/index.d.ts +67 -0
- package/lib/schemas/types/index.js +83 -0
- package/lib/schemas/types/instore_shift_sessions.d.ts +33 -0
- package/lib/schemas/types/instore_shift_sessions.js +2 -0
- package/lib/schemas/types/instore_shifts.d.ts +11 -0
- package/lib/schemas/types/instore_shifts.js +2 -0
- package/lib/schemas/types/internal_expense_details.d.ts +14 -0
- package/lib/schemas/types/internal_expense_details.js +2 -0
- package/lib/schemas/types/internal_leads.d.ts +18 -0
- package/lib/schemas/types/internal_leads.js +2 -0
- package/lib/schemas/types/internal_restaurant_details.d.ts +17 -0
- package/lib/schemas/types/internal_restaurant_details.js +2 -0
- package/lib/schemas/types/inventory.d.ts +48 -0
- package/lib/schemas/types/inventory.js +2 -0
- package/lib/schemas/types/inventory_categories.d.ts +11 -0
- package/lib/schemas/types/inventory_categories.js +2 -0
- package/lib/schemas/types/inventory_transactions.d.ts +23 -0
- package/lib/schemas/types/inventory_transactions.js +2 -0
- package/lib/schemas/types/item.d.ts +88 -0
- package/lib/schemas/types/item.js +2 -0
- package/lib/schemas/types/item_transactions.d.ts +19 -0
- package/lib/schemas/types/item_transactions.js +2 -0
- package/lib/schemas/types/marketing.d.ts +10 -0
- package/lib/schemas/types/marketing.js +2 -0
- package/lib/schemas/types/marketing_fingerprints.d.ts +16 -0
- package/lib/schemas/types/marketing_fingerprints.js +2 -0
- package/lib/schemas/types/menu.d.ts +17 -0
- package/lib/schemas/types/menu.js +2 -0
- package/lib/schemas/types/messaging_devices.d.ts +16 -0
- package/lib/schemas/types/messaging_devices.js +2 -0
- package/lib/schemas/types/modifier_extras.d.ts +31 -0
- package/lib/schemas/types/modifier_extras.js +2 -0
- package/lib/schemas/types/multi_tenants.d.ts +24 -0
- package/lib/schemas/types/multi_tenants.js +2 -0
- package/lib/schemas/types/offers.d.ts +82 -0
- package/lib/schemas/types/offers.js +2 -0
- package/lib/schemas/types/offers_fingerprints.d.ts +11 -0
- package/lib/schemas/types/offers_fingerprints.js +2 -0
- package/lib/schemas/types/operational_roles.d.ts +41 -0
- package/lib/schemas/types/operational_roles.js +18 -0
- package/lib/schemas/types/order.d.ts +225 -0
- package/lib/schemas/types/order.js +2 -0
- package/lib/schemas/types/platform.d.ts +6 -0
- package/lib/schemas/types/platform.js +2 -0
- package/lib/schemas/types/pos_days.d.ts +29 -0
- package/lib/schemas/types/pos_days.js +2 -0
- package/lib/schemas/types/pos_shifts.d.ts +33 -0
- package/lib/schemas/types/pos_shifts.js +2 -0
- package/lib/schemas/types/printer_settings.d.ts +83 -0
- package/lib/schemas/types/printer_settings.js +3 -0
- package/lib/schemas/types/public_holidays.d.ts +14 -0
- package/lib/schemas/types/public_holidays.js +2 -0
- package/lib/schemas/types/purchase_orders.d.ts +69 -0
- package/lib/schemas/types/purchase_orders.js +2 -0
- package/lib/schemas/types/reservations.d.ts +17 -0
- package/lib/schemas/types/reservations.js +2 -0
- package/lib/schemas/types/reviews.d.ts +28 -0
- package/lib/schemas/types/reviews.js +2 -0
- package/lib/schemas/types/rider.d.ts +16 -0
- package/lib/schemas/types/rider.js +2 -0
- package/lib/schemas/types/short_inventory.d.ts +9 -0
- package/lib/schemas/types/short_inventory.js +2 -0
- package/lib/schemas/types/specials.d.ts +42 -0
- package/lib/schemas/types/specials.js +2 -0
- package/lib/schemas/types/split_bill.d.ts +18 -0
- package/lib/schemas/types/split_bill.js +2 -0
- package/lib/schemas/types/staff_shifts.d.ts +15 -0
- package/lib/schemas/types/staff_shifts.js +2 -0
- package/lib/schemas/types/stock_consumption.d.ts +13 -0
- package/lib/schemas/types/stock_consumption.js +2 -0
- package/lib/schemas/types/stock_entry.d.ts +9 -0
- package/lib/schemas/types/stock_entry.js +2 -0
- package/lib/schemas/types/stock_wastage.d.ts +11 -0
- package/lib/schemas/types/stock_wastage.js +2 -0
- package/lib/schemas/types/tenant.d.ts +175 -0
- package/lib/schemas/types/tenant.js +2 -0
- package/lib/schemas/types/tenant_days.d.ts +29 -0
- package/lib/schemas/types/tenant_days.js +2 -0
- package/lib/schemas/types/tenant_metadata.d.ts +13 -0
- package/lib/schemas/types/tenant_metadata.js +2 -0
- package/lib/schemas/types/tenant_shift_sessions.d.ts +33 -0
- package/lib/schemas/types/tenant_shift_sessions.js +2 -0
- package/lib/schemas/types/tenant_shifts.d.ts +13 -0
- package/lib/schemas/types/tenant_shifts.js +2 -0
- package/lib/schemas/types/tenant_staff.d.ts +22 -0
- package/lib/schemas/types/tenant_staff.js +2 -0
- package/lib/schemas/types/terminal_devices.d.ts +16 -0
- package/lib/schemas/types/terminal_devices.js +2 -0
- package/lib/schemas/types/third_party_payments.d.ts +41 -0
- package/lib/schemas/types/third_party_payments.js +2 -0
- package/lib/schemas/types/tokens.d.ts +15 -0
- package/lib/schemas/types/tokens.js +2 -0
- package/lib/schemas/types/track_order_number.d.ts +10 -0
- package/lib/schemas/types/track_order_number.js +2 -0
- package/lib/schemas/types/used_ingredients.d.ts +8 -0
- package/lib/schemas/types/used_ingredients.js +2 -0
- package/lib/schemas/types/void_order_items.d.ts +36 -0
- package/lib/schemas/types/void_order_items.js +2 -0
- package/lib/schemas/types/wallet.d.ts +7 -0
- package/lib/schemas/types/wallet.js +2 -0
- package/lib/schemas/types/wallet_transactions.d.ts +20 -0
- package/lib/schemas/types/wallet_transactions.js +2 -0
- package/lib/schemas/types/warehouse.d.ts +47 -0
- package/lib/schemas/types/warehouse.js +2 -0
- package/lib/schemas/types/warehouse_categories.d.ts +13 -0
- package/lib/schemas/types/warehouse_categories.js +2 -0
- package/lib/schemas/types/warehouse_clients.d.ts +13 -0
- package/lib/schemas/types/warehouse_clients.js +2 -0
- package/lib/schemas/types/warehouse_inventory_transactions.d.ts +23 -0
- package/lib/schemas/types/warehouse_inventory_transactions.js +2 -0
- package/lib/schemas/types/warehouse_invoices.d.ts +69 -0
- package/lib/schemas/types/warehouse_invoices.js +2 -0
- package/lib/schemas/types/warehouse_item_transactions.d.ts +20 -0
- package/lib/schemas/types/warehouse_item_transactions.js +2 -0
- package/lib/schemas/types/warehouse_items.d.ts +65 -0
- package/lib/schemas/types/warehouse_items.js +2 -0
- package/lib/schemas/types/warehouse_operational_roles.d.ts +22 -0
- package/lib/schemas/types/warehouse_operational_roles.js +18 -0
- package/lib/schemas/types/warehouse_settings.d.ts +8 -0
- package/lib/schemas/types/warehouse_settings.js +2 -0
- package/lib/schemas/types/warehouse_staff.d.ts +17 -0
- package/lib/schemas/types/warehouse_staff.js +2 -0
- package/lib/schemas/types/warehouse_track_order_number.d.ts +11 -0
- package/lib/schemas/types/warehouse_track_order_number.js +2 -0
- package/lib/schemas/types/warehouse_vendors.d.ts +16 -0
- package/lib/schemas/types/warehouse_vendors.js +2 -0
- package/package.json +59 -0
|
@@ -0,0 +1,856 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getPartialItems = exports.minusSymbolModifierTitles = exports.plusSymbolModifierTitles = void 0;
|
|
7
|
+
exports.getDiscountLabel = getDiscountLabel;
|
|
8
|
+
exports.getReceiptEngineFooterDetails = getReceiptEngineFooterDetails;
|
|
9
|
+
exports.getItemModifierTitle = getItemModifierTitle;
|
|
10
|
+
exports.getItemModifierOptionTitle = getItemModifierOptionTitle;
|
|
11
|
+
exports.getReceiptItemModifiers = getReceiptItemModifiers;
|
|
12
|
+
exports.getOrderItemReceiptBody = getOrderItemReceiptBody;
|
|
13
|
+
exports.getReceiptBody = getReceiptBody;
|
|
14
|
+
exports.receiptEngine = receiptEngine;
|
|
15
|
+
const emoji_strip_1 = __importDefault(require("emoji-strip"));
|
|
16
|
+
const moment_1 = __importDefault(require("moment"));
|
|
17
|
+
const constants_1 = require("../../constants");
|
|
18
|
+
const store_1 = require("../store");
|
|
19
|
+
const cart_helpers_1 = require("./cart-helpers");
|
|
20
|
+
const common_1 = require("./common");
|
|
21
|
+
const payment_helpers_1 = require("./payment-helpers");
|
|
22
|
+
// =========================><=========================
|
|
23
|
+
function getDiscountLabel(discount_details) {
|
|
24
|
+
let label = 'Discount';
|
|
25
|
+
if (discount_details != null) {
|
|
26
|
+
if (discount_details.special_discount != null &&
|
|
27
|
+
discount_details.special_discount > 0 &&
|
|
28
|
+
discount_details.is_special_discount_percentage &&
|
|
29
|
+
!discount_details.loyalty_discount &&
|
|
30
|
+
!discount_details.voucher_discount) {
|
|
31
|
+
label = `Discount (${discount_details.special_discount}%)`;
|
|
32
|
+
}
|
|
33
|
+
else if (discount_details.loyalty_discount != null &&
|
|
34
|
+
discount_details.loyalty_discount > 0 &&
|
|
35
|
+
!discount_details.is_loyalty_discount_percentage &&
|
|
36
|
+
!discount_details.special_discount &&
|
|
37
|
+
!discount_details.voucher_discount) {
|
|
38
|
+
label = `Loyalty Discount (${discount_details.loyalty_discount}%)`;
|
|
39
|
+
}
|
|
40
|
+
else if (discount_details.voucher_discount != null &&
|
|
41
|
+
discount_details.voucher_discount > 0 &&
|
|
42
|
+
!discount_details.is_voucher_discount_percentage &&
|
|
43
|
+
!discount_details.special_discount &&
|
|
44
|
+
!discount_details.loyalty_discount) {
|
|
45
|
+
label = `Voucher Discount (${discount_details.voucher_discount}%)`;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return label;
|
|
49
|
+
}
|
|
50
|
+
function getReceiptEngineFooterDetails(order, settings) {
|
|
51
|
+
const currencySymbol = settings.currency_symbol ?? '';
|
|
52
|
+
const price = order.price ?? 0;
|
|
53
|
+
const grandTotal = order.grand_total ?? 0;
|
|
54
|
+
const totalDiscount = order.total_discount_applied ?? 0;
|
|
55
|
+
const orderDiscount = order.order_discount_details?.total_discount ?? 0;
|
|
56
|
+
const itemDiscount = totalDiscount - orderDiscount;
|
|
57
|
+
const deliveryFee = order.delivery_details?.delivery_cost;
|
|
58
|
+
const itemsPriceWithoutDiscount = price - totalDiscount;
|
|
59
|
+
let orderSubtotal = itemsPriceWithoutDiscount;
|
|
60
|
+
if (order.is_surcharge_taxable) {
|
|
61
|
+
orderSubtotal += order.surcharge_amount ?? 0;
|
|
62
|
+
}
|
|
63
|
+
if (order.is_service_fee_taxable) {
|
|
64
|
+
orderSubtotal += order.service_fee_amount ?? 0;
|
|
65
|
+
}
|
|
66
|
+
const { cardCharges } = (0, payment_helpers_1.getOrderPaymentsDetails)(order.grand_total, order.payments);
|
|
67
|
+
// =========================><=========================
|
|
68
|
+
const details = [];
|
|
69
|
+
// 1. Price (base price before any adjustments)
|
|
70
|
+
if (price !== grandTotal || totalDiscount) {
|
|
71
|
+
const right = `${(0, common_1.localeAmount)(currencySymbol, price)}`;
|
|
72
|
+
details.push({
|
|
73
|
+
left: 'Price',
|
|
74
|
+
right,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
// 2. Item Discount
|
|
78
|
+
if (itemDiscount) {
|
|
79
|
+
let label = getDiscountLabel(order.categories?.[0]?.items?.[0]?.item_discount_details);
|
|
80
|
+
const areAllDiscountsSame = label.endsWith('%)') &&
|
|
81
|
+
order.categories?.every((cat) => cat.items?.every((item) => getDiscountLabel(item.item_discount_details) === label));
|
|
82
|
+
if (!areAllDiscountsSame) {
|
|
83
|
+
label = 'Discount';
|
|
84
|
+
}
|
|
85
|
+
const right = `${(0, common_1.localeAmount)(currencySymbol, itemDiscount)}`;
|
|
86
|
+
details.push({
|
|
87
|
+
left: `Item ${label}`,
|
|
88
|
+
right,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
// 3. Order Discount
|
|
92
|
+
if (orderDiscount) {
|
|
93
|
+
const right = `${(0, common_1.localeAmount)(currencySymbol, orderDiscount)}`;
|
|
94
|
+
const label = getDiscountLabel(order.order_discount_details);
|
|
95
|
+
details.push({
|
|
96
|
+
left: label,
|
|
97
|
+
right,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
// 4. Taxable Surcharge
|
|
101
|
+
if (order.is_surcharge_taxable && order.surcharge) {
|
|
102
|
+
const surchargePercentage = order.is_surcharge_percentage ? ` (${order.surcharge}%)` : '';
|
|
103
|
+
const right = (0, common_1.localeAmount)(currencySymbol, order.surcharge_amount ?? 0);
|
|
104
|
+
details.push({
|
|
105
|
+
left: `Surcharge${surchargePercentage}`,
|
|
106
|
+
right,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
// 5. Taxable Service Charges
|
|
110
|
+
if (order.is_service_fee_taxable && order.service_fee) {
|
|
111
|
+
const seriveFeePercentage = order.is_service_fee_percentage ? ` (${order.service_fee}%)` : '';
|
|
112
|
+
const right = (0, common_1.localeAmount)(currencySymbol, order.service_fee_amount ?? 0);
|
|
113
|
+
details.push({
|
|
114
|
+
left: `Service Charges${seriveFeePercentage}`,
|
|
115
|
+
right,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
// 6. Tax
|
|
119
|
+
if (order.tax_amount) {
|
|
120
|
+
const right = (0, common_1.localeAmount)(currencySymbol, order.tax_amount);
|
|
121
|
+
details.push({
|
|
122
|
+
left: 'Tax',
|
|
123
|
+
right,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
// 7. GST (Total before GST and GST amount)
|
|
127
|
+
if (order.gst && !settings.hide_gst_value && order.is_gst_inclusive) {
|
|
128
|
+
const right = (0, common_1.localeAmount)(currencySymbol, (order.grand_total ?? 0) - (order.gst_amount ?? 0));
|
|
129
|
+
details.push({
|
|
130
|
+
left: `Total before ${settings.gstName}`,
|
|
131
|
+
right,
|
|
132
|
+
});
|
|
133
|
+
const gstRight = (0, common_1.localeAmount)(currencySymbol, order.gst_amount ?? 0);
|
|
134
|
+
details.push({
|
|
135
|
+
left: `${settings.gstName} (${(0, common_1.parseNum)(order.gst)}% Inclusive)`,
|
|
136
|
+
right: gstRight,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
// 8. Subtotal (after discounts, before non-inclusive GST breakdown)
|
|
140
|
+
if (orderSubtotal !== price && orderSubtotal !== grandTotal) {
|
|
141
|
+
const right = (0, common_1.localeAmount)(currencySymbol, orderSubtotal);
|
|
142
|
+
details.push({
|
|
143
|
+
left: 'Subtotal',
|
|
144
|
+
right,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
// 9. GST (non-inclusive)
|
|
148
|
+
if (order.gst && !settings.hide_gst_value && !order.is_gst_inclusive) {
|
|
149
|
+
const right = (0, common_1.localeAmount)(currencySymbol, order.gst_amount ?? 0);
|
|
150
|
+
details.push({
|
|
151
|
+
left: `${settings.gstName} (${(0, common_1.parseNum)(order.gst)}%)`,
|
|
152
|
+
right,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
// 9. Non-Taxable Surcharge
|
|
156
|
+
if (!order.is_surcharge_taxable && order.surcharge) {
|
|
157
|
+
const right = (0, common_1.localeAmount)(currencySymbol, order.surcharge_amount ?? 0);
|
|
158
|
+
const surchargePercentage = order.is_surcharge_percentage ? ` (${order.surcharge}%)` : '';
|
|
159
|
+
details.push({
|
|
160
|
+
left: `Surcharge${surchargePercentage}`,
|
|
161
|
+
right,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
// 10. Non-Taxable Service Charges
|
|
165
|
+
if (!order.is_service_fee_taxable && order.service_fee) {
|
|
166
|
+
const right = (0, common_1.localeAmount)(currencySymbol, order.service_fee_amount ?? 0);
|
|
167
|
+
const seriveFeePercentage = order.is_service_fee_percentage ? ` (${order.service_fee}%)` : '';
|
|
168
|
+
details.push({
|
|
169
|
+
left: `Service Charges${seriveFeePercentage}`,
|
|
170
|
+
right,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
// 11. Delivery Charges
|
|
174
|
+
if (deliveryFee) {
|
|
175
|
+
const right = (0, common_1.localeAmount)(currencySymbol, deliveryFee);
|
|
176
|
+
details.push({
|
|
177
|
+
left: 'Delivery Charges',
|
|
178
|
+
right,
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
// 12. Tip
|
|
182
|
+
if (order.tip_amount) {
|
|
183
|
+
const right = (0, common_1.localeAmount)(currencySymbol, order.tip_amount);
|
|
184
|
+
details.push({
|
|
185
|
+
left: 'Tip',
|
|
186
|
+
right,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
// 13. POS Charges (added last in calculateCartOrderInfoAndSyncData)
|
|
190
|
+
if (order.tax_invoice_provider_charges) {
|
|
191
|
+
const right = (0, common_1.localeAmount)(currencySymbol, order.tax_invoice_provider_charges);
|
|
192
|
+
details.push({
|
|
193
|
+
left: 'POS Charges',
|
|
194
|
+
right,
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
// 14. Card Charges (Non Refundable)
|
|
198
|
+
if (cardCharges > 0) {
|
|
199
|
+
const right = (0, common_1.localeAmount)(currencySymbol, cardCharges);
|
|
200
|
+
details.push({
|
|
201
|
+
left: 'Card Charges (Non Refundable)',
|
|
202
|
+
right,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
return details;
|
|
206
|
+
}
|
|
207
|
+
// =========================><=========================
|
|
208
|
+
const removeModifierFirstWord = ['select', 'choose', 'recommended', 'pick'];
|
|
209
|
+
const removeModifierSecondWord = ['your', 'one', 'any', 'a', 'an', 'the'];
|
|
210
|
+
exports.plusSymbolModifierTitles = [
|
|
211
|
+
'modifier',
|
|
212
|
+
'modifiers',
|
|
213
|
+
'add',
|
|
214
|
+
'add-on',
|
|
215
|
+
'add-ons',
|
|
216
|
+
'add on',
|
|
217
|
+
'add ons',
|
|
218
|
+
'addon',
|
|
219
|
+
'addons',
|
|
220
|
+
'addition',
|
|
221
|
+
'additions',
|
|
222
|
+
'additionals',
|
|
223
|
+
'additional',
|
|
224
|
+
'topping',
|
|
225
|
+
'toppings',
|
|
226
|
+
'extra',
|
|
227
|
+
'extras',
|
|
228
|
+
];
|
|
229
|
+
exports.minusSymbolModifierTitles = [
|
|
230
|
+
'without',
|
|
231
|
+
'exclude',
|
|
232
|
+
'excluded',
|
|
233
|
+
'remove',
|
|
234
|
+
'removed',
|
|
235
|
+
'less',
|
|
236
|
+
'lessen',
|
|
237
|
+
'lessened',
|
|
238
|
+
'lessening',
|
|
239
|
+
'minus',
|
|
240
|
+
'minused',
|
|
241
|
+
];
|
|
242
|
+
function getItemModifierTitle(name) {
|
|
243
|
+
let modifierName = name;
|
|
244
|
+
const words = name.toLowerCase().split(' ');
|
|
245
|
+
// check if name has plus symbol
|
|
246
|
+
const plusSymbol = exports.plusSymbolModifierTitles.some((title) => words.includes(title));
|
|
247
|
+
// check if name has minus symbol
|
|
248
|
+
const minusSymbol = exports.minusSymbolModifierTitles.some((title) => words.includes(title));
|
|
249
|
+
if (words.length > 1) {
|
|
250
|
+
const firstWord = words[0];
|
|
251
|
+
if (removeModifierFirstWord.includes(firstWord)) {
|
|
252
|
+
let index = 1;
|
|
253
|
+
if (words.length > 2) {
|
|
254
|
+
const secondWord = words[1];
|
|
255
|
+
if (removeModifierSecondWord.includes(secondWord)) {
|
|
256
|
+
index = 2;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
modifierName = words.slice(index).join(' ');
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
modifierName = modifierName.trim().toUpperCase();
|
|
263
|
+
if (minusSymbol) {
|
|
264
|
+
modifierName = `- ${modifierName}`;
|
|
265
|
+
}
|
|
266
|
+
else if (plusSymbol) {
|
|
267
|
+
modifierName = `+ ${modifierName}`;
|
|
268
|
+
}
|
|
269
|
+
return modifierName;
|
|
270
|
+
}
|
|
271
|
+
function getItemModifierOptionTitle(modifierTitle, name) {
|
|
272
|
+
// replace modifier title with empty string in name
|
|
273
|
+
// it should be case insensitive
|
|
274
|
+
const optionTitle = name.replace(new RegExp(modifierTitle.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'gi'), '');
|
|
275
|
+
return optionTitle.trim();
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Mutates the options array by adding modifier options to it.
|
|
279
|
+
*
|
|
280
|
+
* @param itemModifiers - The item modifiers
|
|
281
|
+
* @param options - An array of IReceiptItem. Default is empty array []
|
|
282
|
+
* @param space - Space parameter would add space on left to the children of each modifier. Default is empty string ''
|
|
283
|
+
*
|
|
284
|
+
*/
|
|
285
|
+
function getReceiptItemModifiers(itemModifiers, options = [], display_modifiers_on_separate_lines = false, space = '', hide_modifier_name = false) {
|
|
286
|
+
space = space + ' ';
|
|
287
|
+
if (!display_modifiers_on_separate_lines) {
|
|
288
|
+
for (let i = 0; i < itemModifiers.length; i++) {
|
|
289
|
+
const modifier = itemModifiers[i];
|
|
290
|
+
const modifierName = getItemModifierTitle(modifier.name);
|
|
291
|
+
let modifierOptions = modifier.options;
|
|
292
|
+
if (modifierOptions.length > 1) {
|
|
293
|
+
const optionsWithModifiers = [];
|
|
294
|
+
const optionsWithoutModifiers = {};
|
|
295
|
+
for (let j = 0; j < modifierOptions.length; j++) {
|
|
296
|
+
const option = {
|
|
297
|
+
...modifierOptions[j],
|
|
298
|
+
};
|
|
299
|
+
if (option.modifiers != null && option.modifiers.length > 0) {
|
|
300
|
+
optionsWithModifiers.push(option);
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
if (optionsWithoutModifiers[option.quantity] != null) {
|
|
304
|
+
optionsWithoutModifiers[option.quantity].name += `, ${(0, common_1.titleCase)(option.name).trim()}`;
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
option.name = (0, common_1.titleCase)(option.name).trim();
|
|
308
|
+
optionsWithoutModifiers[option.quantity] = option;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
modifierOptions = [];
|
|
313
|
+
for (const quantity in optionsWithoutModifiers) {
|
|
314
|
+
modifierOptions.push(optionsWithoutModifiers[quantity]);
|
|
315
|
+
}
|
|
316
|
+
for (const option of optionsWithModifiers) {
|
|
317
|
+
modifierOptions.push(option);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
modifierOptions = modifierOptions.map((option) => ({
|
|
322
|
+
...option,
|
|
323
|
+
name: (0, common_1.titleCase)(getItemModifierOptionTitle(modifierName, option.name)),
|
|
324
|
+
}));
|
|
325
|
+
}
|
|
326
|
+
for (let j = 0; j < modifierOptions.length; j++) {
|
|
327
|
+
const option = modifierOptions[j];
|
|
328
|
+
const optionQuantity = option.quantity > 1 ? `${option.quantity}x ` : '';
|
|
329
|
+
const optionDescription = hide_modifier_name
|
|
330
|
+
? `${space}${optionQuantity}`
|
|
331
|
+
: `${space}${optionQuantity}${modifierName} `;
|
|
332
|
+
options.push({
|
|
333
|
+
left: (0, emoji_strip_1.default)(optionDescription),
|
|
334
|
+
option_name: (0, emoji_strip_1.default)(option.name),
|
|
335
|
+
});
|
|
336
|
+
if (option.modifiers != null && option.modifiers.length > 0) {
|
|
337
|
+
getReceiptItemModifiers(option.modifiers, options, display_modifiers_on_separate_lines, space, hide_modifier_name);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
for (let i = 0; i < itemModifiers.length; i++) {
|
|
344
|
+
const modifier = itemModifiers[i];
|
|
345
|
+
const modifierName = getItemModifierTitle(modifier.name);
|
|
346
|
+
for (let j = 0; j < modifier.options.length; j++) {
|
|
347
|
+
const option = modifier.options[j];
|
|
348
|
+
const optionName = (0, common_1.sentenceCase)(getItemModifierOptionTitle(modifierName, option.name));
|
|
349
|
+
const optionQuantity = option.quantity > 1 ? `${option.quantity}x ` : '';
|
|
350
|
+
const optionDescription = hide_modifier_name
|
|
351
|
+
? `${space}${optionQuantity}`
|
|
352
|
+
: `${space}${optionQuantity}${modifierName} `;
|
|
353
|
+
options.push({
|
|
354
|
+
left: (0, emoji_strip_1.default)(optionDescription),
|
|
355
|
+
option_name: (0, emoji_strip_1.default)(optionName),
|
|
356
|
+
});
|
|
357
|
+
if (option.modifiers) {
|
|
358
|
+
getReceiptItemModifiers(option.modifiers, options, display_modifiers_on_separate_lines, space, hide_modifier_name);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
function getOrderItemReceiptBody({ orderItem, currency_symbol, display_modifiers_on_separate_lines, displayItemInstructions, show_modifiers, displayUnitItemPrice, isRemoved, hide_modifier_name, }) {
|
|
365
|
+
const name = orderItem.name;
|
|
366
|
+
const quantity = orderItem.quantity;
|
|
367
|
+
const subtotal = (0, common_1.parseNum)(orderItem.subtotal);
|
|
368
|
+
const itemModifiers = orderItem.modifiers ?? [];
|
|
369
|
+
let description = `${quantity}x ${name}`;
|
|
370
|
+
const amount = (0, common_1.localeAmount)(currency_symbol, subtotal);
|
|
371
|
+
const prevItemPrice = (0, cart_helpers_1.optionallyGetOrderItemOriginalQuantityPrice)(orderItem);
|
|
372
|
+
const showPrevPrice = prevItemPrice != null && prevItemPrice > subtotal;
|
|
373
|
+
const prev_right = showPrevPrice ? `${prevItemPrice}` : undefined;
|
|
374
|
+
if (displayUnitItemPrice) {
|
|
375
|
+
const total = showPrevPrice ? prevItemPrice : orderItem.subtotal;
|
|
376
|
+
description += ` @\u200E${(0, common_1.parseNum)(total / quantity)}`;
|
|
377
|
+
}
|
|
378
|
+
const options = [
|
|
379
|
+
// main orderItem
|
|
380
|
+
{
|
|
381
|
+
left: description,
|
|
382
|
+
right: amount,
|
|
383
|
+
prev_right,
|
|
384
|
+
_id: orderItem._id,
|
|
385
|
+
item_id: orderItem.item_id,
|
|
386
|
+
image_url: orderItem.image_url,
|
|
387
|
+
},
|
|
388
|
+
// modifiers
|
|
389
|
+
];
|
|
390
|
+
// =========================><=========================
|
|
391
|
+
if (show_modifiers) {
|
|
392
|
+
// This mutates the options array
|
|
393
|
+
getReceiptItemModifiers(itemModifiers, options, display_modifiers_on_separate_lines, '', hide_modifier_name);
|
|
394
|
+
}
|
|
395
|
+
// =========================><=========================
|
|
396
|
+
// check if item has special instructions
|
|
397
|
+
if (!isRemoved && displayItemInstructions && orderItem.special_instructions.length > 0) {
|
|
398
|
+
options.push({
|
|
399
|
+
left: `** Note: ${(0, emoji_strip_1.default)(orderItem.special_instructions)} **`,
|
|
400
|
+
is_bold: true,
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
if (isRemoved && orderItem.void_reason != null && orderItem.void_reason.length > 0) {
|
|
404
|
+
options.push({
|
|
405
|
+
left: `** Reason: ${(0, emoji_strip_1.default)(orderItem.void_reason)} **`,
|
|
406
|
+
is_bold: true,
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
return options;
|
|
410
|
+
}
|
|
411
|
+
function getReceiptBody({ orderItems, currency_symbol, show_modifiers, display_modifiers_on_separate_lines, displayItemInstructions, displayUnitItemPrice, isRemoved, hide_modifier_name, }) {
|
|
412
|
+
const currency = currency_symbol ?? '';
|
|
413
|
+
const items = orderItems
|
|
414
|
+
.map((item) => getOrderItemReceiptBody({
|
|
415
|
+
orderItem: item,
|
|
416
|
+
currency_symbol: currency,
|
|
417
|
+
display_modifiers_on_separate_lines,
|
|
418
|
+
displayItemInstructions,
|
|
419
|
+
show_modifiers,
|
|
420
|
+
displayUnitItemPrice,
|
|
421
|
+
isRemoved,
|
|
422
|
+
hide_modifier_name,
|
|
423
|
+
}))
|
|
424
|
+
.flat();
|
|
425
|
+
return items;
|
|
426
|
+
}
|
|
427
|
+
// =========================><=========================
|
|
428
|
+
const getPartialItems = (categories = [], included_categories_map, filterEmpty) => {
|
|
429
|
+
const partialCategories = [];
|
|
430
|
+
for (let i = 0; i < categories.length; i++) {
|
|
431
|
+
const category = categories[i];
|
|
432
|
+
const includedCategory = included_categories_map[category.category_id];
|
|
433
|
+
if (!includedCategory)
|
|
434
|
+
continue;
|
|
435
|
+
const partialItems = [];
|
|
436
|
+
for (let j = 0; j < category.items.length; j++) {
|
|
437
|
+
const item = category.items[j];
|
|
438
|
+
const includedItem = includedCategory.includedItemsMap[item.item_id];
|
|
439
|
+
if (!includedItem)
|
|
440
|
+
continue;
|
|
441
|
+
partialItems.push({
|
|
442
|
+
sortId: includedItem.sortId,
|
|
443
|
+
item,
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
// sort partial items
|
|
447
|
+
partialItems.sort((a, b) => a.sortId - b.sortId);
|
|
448
|
+
// get items from partial items
|
|
449
|
+
const items = partialItems.map((partialItem) => partialItem.item);
|
|
450
|
+
if (filterEmpty && items.length === 0)
|
|
451
|
+
continue;
|
|
452
|
+
const orderCategory = {
|
|
453
|
+
name: category.name,
|
|
454
|
+
category_id: category.category_id,
|
|
455
|
+
items,
|
|
456
|
+
};
|
|
457
|
+
partialCategories.push({
|
|
458
|
+
sortId: includedCategory.sortId,
|
|
459
|
+
orderCategory,
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
// sort partial categories
|
|
463
|
+
partialCategories.sort((a, b) => a.sortId - b.sortId);
|
|
464
|
+
const categoriesFromPartialCategories = partialCategories.map((partialCategory) => partialCategory.orderCategory);
|
|
465
|
+
return categoriesFromPartialCategories;
|
|
466
|
+
};
|
|
467
|
+
exports.getPartialItems = getPartialItems;
|
|
468
|
+
function receiptEngine(payload, mappedItems = {}) {
|
|
469
|
+
const { business_website, currency_symbol, image_url, name, public_phone_numbers, restaurant_address, support_email, tax_business_number, takeaway_is_pickup, tax_invoice_provider, country_alpha_2, hide_gst_value, } = payload.tenant_settings;
|
|
470
|
+
const { full_width, included_categories_map, printing_preference, receipt_type, show_modifiers, display_modifiers_on_separate_lines, display_item_instructions_on_customer_receipt, display_order_instructions_on_customer_receipt, display_unit_item_price_on_customer_receipt, hide_modifier_name, } = payload.printer_settings;
|
|
471
|
+
const currencySymbol = currency_symbol ?? '';
|
|
472
|
+
const grandTotal = payload.order.grand_total ?? 0;
|
|
473
|
+
const { amountPayedSoFar, existingPayments, change, openAmount } = (0, payment_helpers_1.getOrderPaymentsDetails)(payload.order.grand_total, payload.order.payments);
|
|
474
|
+
const payments = (0, payment_helpers_1.getSortedPayments)(existingPayments.filter((payment) => payment.payment_status === constants_1.PAYMENT_STATUS_ENUM.SETTLED ||
|
|
475
|
+
payment.payment_status === constants_1.PAYMENT_STATUS_ENUM.REFUNDED));
|
|
476
|
+
const gstName = (0, common_1.getGSTName)(country_alpha_2, tax_invoice_provider);
|
|
477
|
+
const taxNumberTitle = (0, common_1.getTaxNumberTitle)(country_alpha_2, tax_invoice_provider);
|
|
478
|
+
const isFullyPaid = (0, payment_helpers_1.isOrderFullyPaid)(grandTotal, payload.order.payments);
|
|
479
|
+
const settings = {
|
|
480
|
+
currency_symbol,
|
|
481
|
+
show_modifiers,
|
|
482
|
+
tax_invoice_provider,
|
|
483
|
+
gstName,
|
|
484
|
+
hide_gst_value,
|
|
485
|
+
};
|
|
486
|
+
const estimated_time = payload.order.takeaway_details?.estimated_takeaway_time !== undefined
|
|
487
|
+
? payload.order.takeaway_details?.estimated_takeaway_time
|
|
488
|
+
: payload.order.delivery_details?.estimated_delivery_time;
|
|
489
|
+
// =========================><=========================
|
|
490
|
+
const [order_from, order_type] = payload.order.platform?.split('_') ?? ['', ''];
|
|
491
|
+
let orderTypeName = order_type;
|
|
492
|
+
if (takeaway_is_pickup && order_type === constants_1.ORDER_TYPE_ENUM.TAKE_AWAY) {
|
|
493
|
+
orderTypeName = 'PICK-UP';
|
|
494
|
+
}
|
|
495
|
+
const is_kitchen_receipt = receipt_type === constants_1.RECEIPT_TYPE_ENUM.KITCHEN;
|
|
496
|
+
const displayItemInstructions = is_kitchen_receipt || display_item_instructions_on_customer_receipt;
|
|
497
|
+
const displayOrderInstructions = is_kitchen_receipt || display_order_instructions_on_customer_receipt;
|
|
498
|
+
let unchanged_items;
|
|
499
|
+
let edited_items;
|
|
500
|
+
let removed_items;
|
|
501
|
+
let new_items;
|
|
502
|
+
let order_courses;
|
|
503
|
+
let total_items = 0;
|
|
504
|
+
let prev_dinein_table_name = null;
|
|
505
|
+
const categories = payload.order.categories ?? [];
|
|
506
|
+
if (is_kitchen_receipt) {
|
|
507
|
+
const firstIteration = payload.order.iterations?.[0];
|
|
508
|
+
let currentIterationCategories = payload.order.categories;
|
|
509
|
+
let currentDineinCourses = payload.order.dinein_details?.courses;
|
|
510
|
+
let previousIterationCategories = firstIteration?.categories;
|
|
511
|
+
let previousDineinCourses = firstIteration?.dinein_details?.courses;
|
|
512
|
+
if (payload.order.dinein_details != null &&
|
|
513
|
+
firstIteration != null &&
|
|
514
|
+
firstIteration.dinein_details != null &&
|
|
515
|
+
firstIteration.dinein_details.table_name !== payload.order.dinein_details.table_name) {
|
|
516
|
+
prev_dinein_table_name = firstIteration.dinein_details.table_name ?? null;
|
|
517
|
+
}
|
|
518
|
+
const isPartial = printing_preference === constants_1.PRINTING_PREFERENCE_ENUM.PARTIAL;
|
|
519
|
+
const isAnEdit = firstIteration != null && firstIteration.categories != null && firstIteration.categories.length > 0;
|
|
520
|
+
const printUnchangedItems = payload.printer_settings.display_old_items_on_kitchen_receipt || !isAnEdit;
|
|
521
|
+
if (isPartial) {
|
|
522
|
+
currentIterationCategories = (0, exports.getPartialItems)(currentIterationCategories, included_categories_map);
|
|
523
|
+
if (currentDineinCourses) {
|
|
524
|
+
const currentIterationItemIds = currentIterationCategories.reduce((acc, category) => {
|
|
525
|
+
category.items.forEach((item) => {
|
|
526
|
+
acc.push(item.item_id);
|
|
527
|
+
});
|
|
528
|
+
return acc;
|
|
529
|
+
}, []);
|
|
530
|
+
currentDineinCourses.forEach((courseObj) => {
|
|
531
|
+
courseObj.item_ids = courseObj.item_ids.filter((itemId) => currentIterationItemIds.includes(itemId));
|
|
532
|
+
});
|
|
533
|
+
currentDineinCourses = currentDineinCourses.filter((courseObj) => courseObj.item_ids.length > 0);
|
|
534
|
+
}
|
|
535
|
+
previousIterationCategories = (0, exports.getPartialItems)(previousIterationCategories, included_categories_map);
|
|
536
|
+
if (previousDineinCourses) {
|
|
537
|
+
const previousIterationItemIds = previousIterationCategories.reduce((acc, category) => {
|
|
538
|
+
category.items.forEach((item) => {
|
|
539
|
+
acc.push(item.item_id);
|
|
540
|
+
});
|
|
541
|
+
return acc;
|
|
542
|
+
}, []);
|
|
543
|
+
previousDineinCourses = previousDineinCourses.map((courseObj) => ({
|
|
544
|
+
...courseObj,
|
|
545
|
+
item_ids: courseObj.item_ids.filter((itemId) => previousIterationItemIds.includes(itemId)),
|
|
546
|
+
}));
|
|
547
|
+
previousDineinCourses = previousDineinCourses.filter((courseObj) => courseObj.item_ids.length > 0);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
const cartItems = (0, store_1.getCartItemsObj)({
|
|
551
|
+
currentIterationCategories,
|
|
552
|
+
currentDineinCourses,
|
|
553
|
+
previousIterationCategories,
|
|
554
|
+
previousDineinCourses,
|
|
555
|
+
mappedItems,
|
|
556
|
+
shouldSortItemsViaId: !isPartial,
|
|
557
|
+
platform: payload.order.platform,
|
|
558
|
+
isAnEdit,
|
|
559
|
+
});
|
|
560
|
+
total_items = cartItems.totalSelectedItems;
|
|
561
|
+
if (printUnchangedItems || prev_dinein_table_name) {
|
|
562
|
+
const unchanged = getReceiptBody({
|
|
563
|
+
orderItems: cartItems.unChangedItems.map((item) => ({ ...item.orderItem, image_url: item.image_url })),
|
|
564
|
+
currency_symbol,
|
|
565
|
+
show_modifiers,
|
|
566
|
+
display_modifiers_on_separate_lines,
|
|
567
|
+
displayItemInstructions,
|
|
568
|
+
hide_modifier_name,
|
|
569
|
+
});
|
|
570
|
+
if (prev_dinein_table_name != null && unchanged.length === 0) {
|
|
571
|
+
prev_dinein_table_name = null;
|
|
572
|
+
}
|
|
573
|
+
if (printUnchangedItems) {
|
|
574
|
+
unchanged_items = unchanged;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
edited_items = getReceiptBody({
|
|
578
|
+
orderItems: cartItems.editedItems.map((item) => ({ ...item.orderItem, image_url: item.image_url })),
|
|
579
|
+
currency_symbol,
|
|
580
|
+
show_modifiers,
|
|
581
|
+
display_modifiers_on_separate_lines,
|
|
582
|
+
displayItemInstructions,
|
|
583
|
+
hide_modifier_name,
|
|
584
|
+
});
|
|
585
|
+
removed_items = getReceiptBody({
|
|
586
|
+
orderItems: cartItems.removedItems.map((item) => ({ ...item.orderItem, image_url: item.image_url })),
|
|
587
|
+
currency_symbol,
|
|
588
|
+
show_modifiers,
|
|
589
|
+
display_modifiers_on_separate_lines,
|
|
590
|
+
displayItemInstructions,
|
|
591
|
+
isRemoved: true,
|
|
592
|
+
hide_modifier_name,
|
|
593
|
+
});
|
|
594
|
+
new_items = getReceiptBody({
|
|
595
|
+
orderItems: cartItems.newItems.map((item) => ({ ...item.orderItem, image_url: item.image_url })),
|
|
596
|
+
currency_symbol,
|
|
597
|
+
show_modifiers,
|
|
598
|
+
display_modifiers_on_separate_lines,
|
|
599
|
+
displayItemInstructions,
|
|
600
|
+
hide_modifier_name,
|
|
601
|
+
});
|
|
602
|
+
order_courses = [];
|
|
603
|
+
for (let i = 0; i < cartItems.orderCourses.length; i++) {
|
|
604
|
+
const courseObj = cartItems.orderCourses[i];
|
|
605
|
+
const called = courseObj.called && !courseObj.has_already_been_called;
|
|
606
|
+
const uncalled = !courseObj.called && courseObj.has_already_been_called;
|
|
607
|
+
const unchanged_items = printUnchangedItems || called || uncalled
|
|
608
|
+
? getReceiptBody({
|
|
609
|
+
orderItems: courseObj.cartItemsObj.unChangedItems.map((item) => ({
|
|
610
|
+
...item.orderItem,
|
|
611
|
+
image_url: item.image_url,
|
|
612
|
+
})),
|
|
613
|
+
currency_symbol,
|
|
614
|
+
show_modifiers,
|
|
615
|
+
display_modifiers_on_separate_lines,
|
|
616
|
+
displayItemInstructions,
|
|
617
|
+
hide_modifier_name,
|
|
618
|
+
})
|
|
619
|
+
: [];
|
|
620
|
+
const edited_items = getReceiptBody({
|
|
621
|
+
orderItems: courseObj.cartItemsObj.editedItems.map((item) => ({
|
|
622
|
+
...item.orderItem,
|
|
623
|
+
image_url: item.image_url,
|
|
624
|
+
})),
|
|
625
|
+
currency_symbol,
|
|
626
|
+
show_modifiers,
|
|
627
|
+
display_modifiers_on_separate_lines,
|
|
628
|
+
displayItemInstructions,
|
|
629
|
+
hide_modifier_name,
|
|
630
|
+
});
|
|
631
|
+
const removed_items = getReceiptBody({
|
|
632
|
+
orderItems: courseObj.cartItemsObj.removedItems.map((item) => ({
|
|
633
|
+
...item.orderItem,
|
|
634
|
+
image_url: item.image_url,
|
|
635
|
+
})),
|
|
636
|
+
currency_symbol,
|
|
637
|
+
show_modifiers,
|
|
638
|
+
display_modifiers_on_separate_lines,
|
|
639
|
+
displayItemInstructions,
|
|
640
|
+
isRemoved: true,
|
|
641
|
+
hide_modifier_name,
|
|
642
|
+
});
|
|
643
|
+
const new_items = getReceiptBody({
|
|
644
|
+
orderItems: courseObj.cartItemsObj.newItems.map((item) => ({ ...item.orderItem, image_url: item.image_url })),
|
|
645
|
+
currency_symbol,
|
|
646
|
+
show_modifiers,
|
|
647
|
+
display_modifiers_on_separate_lines,
|
|
648
|
+
displayItemInstructions,
|
|
649
|
+
hide_modifier_name,
|
|
650
|
+
});
|
|
651
|
+
if (!unchanged_items.length && !edited_items.length && !removed_items.length && !new_items.length) {
|
|
652
|
+
continue;
|
|
653
|
+
}
|
|
654
|
+
order_courses.push({
|
|
655
|
+
called: courseObj.called,
|
|
656
|
+
has_already_been_called: courseObj.has_already_been_called,
|
|
657
|
+
is_removed: courseObj.is_removed,
|
|
658
|
+
name: courseObj.name,
|
|
659
|
+
total_amount: courseObj.total_amount,
|
|
660
|
+
total_selected_items: courseObj.totalSelectedItems,
|
|
661
|
+
course_items_obj: {
|
|
662
|
+
unchanged_items,
|
|
663
|
+
edited_items,
|
|
664
|
+
removed_items,
|
|
665
|
+
new_items,
|
|
666
|
+
},
|
|
667
|
+
});
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
else {
|
|
671
|
+
const items = categories.reduce((acc, category) => acc.concat(category.items.map((item) => ({
|
|
672
|
+
...item,
|
|
673
|
+
image_url: mappedItems[item.item_id]?.image_url,
|
|
674
|
+
}))), []);
|
|
675
|
+
unchanged_items = getReceiptBody({
|
|
676
|
+
orderItems: items,
|
|
677
|
+
currency_symbol,
|
|
678
|
+
show_modifiers,
|
|
679
|
+
display_modifiers_on_separate_lines,
|
|
680
|
+
displayItemInstructions,
|
|
681
|
+
displayUnitItemPrice: display_unit_item_price_on_customer_receipt,
|
|
682
|
+
hide_modifier_name,
|
|
683
|
+
});
|
|
684
|
+
total_items = items.length;
|
|
685
|
+
}
|
|
686
|
+
const changeAmount = change > 0 ? (0, common_1.localeAmount)(currencySymbol, change) : null;
|
|
687
|
+
const payment_details = [
|
|
688
|
+
...payments.map((payment) => {
|
|
689
|
+
const isRefund = payment.amount_refunded > 0 && payment.amount_refunded > payment.amount_paid;
|
|
690
|
+
const paymentTitle = (0, payment_helpers_1.getPaymentSmartTitle)(payment.payment_type).title;
|
|
691
|
+
const amount = (payment.payment_type !== constants_1.PAYMENT_TYPE_ENUM.UNPAID
|
|
692
|
+
? isRefund
|
|
693
|
+
? payment.amount_refunded - payment.amount_paid
|
|
694
|
+
: payment.amount_paid
|
|
695
|
+
: payment.amount_due) + (payment.card_details?.card_charges ?? 0);
|
|
696
|
+
return {
|
|
697
|
+
left: `${(0, common_1.sentenceCase)(paymentTitle).replace(/_/g, ' ')}${isRefund ? ' (Refund)' : ''}`,
|
|
698
|
+
right: (0, common_1.localeAmount)(currencySymbol, amount),
|
|
699
|
+
};
|
|
700
|
+
}),
|
|
701
|
+
...(changeAmount
|
|
702
|
+
? [
|
|
703
|
+
{
|
|
704
|
+
left: 'Change',
|
|
705
|
+
right: changeAmount,
|
|
706
|
+
},
|
|
707
|
+
]
|
|
708
|
+
: []),
|
|
709
|
+
];
|
|
710
|
+
const parsedAmountPayedSoFar = (0, common_1.parseNum)(amountPayedSoFar);
|
|
711
|
+
let customerName = null;
|
|
712
|
+
let customerPhone = null;
|
|
713
|
+
if (payload.order.consumer != null &&
|
|
714
|
+
(payload.order.staff_details == null || payload.order.consumer.phone !== payload.order.staff_details.staff_mobile)) {
|
|
715
|
+
const phoneNumber = (0, common_1.getNationalNumberFromPhone)(payload.order.consumer.phone);
|
|
716
|
+
customerName = `${payload.order.consumer.first_name} ${payload.order.consumer.last_name}`.trim();
|
|
717
|
+
customerPhone = phoneNumber ?? payload.order.consumer.phone;
|
|
718
|
+
}
|
|
719
|
+
const staff_name = payload.printer_settings.print_staff_name && payload.order.staff_details != null
|
|
720
|
+
? (payload.order.staff_details.staff_name ?? null)
|
|
721
|
+
: null;
|
|
722
|
+
const order_taker_name = payload.order.dinein_details?.order_taker_details?.staff_name ?? staff_name;
|
|
723
|
+
const rider_name = payload.order.delivery_details?.rider_details?.staff_name ?? null;
|
|
724
|
+
let payment_status = null;
|
|
725
|
+
// Helper to get expected payment label suffix
|
|
726
|
+
const getExpectedPaymentLabel = () => {
|
|
727
|
+
if (payload.order.payment_method_expected) {
|
|
728
|
+
return ` (Expected: ${(0, common_1.sentenceCase)(payload.order.payment_method_expected.replace(/_/g, ' '))})`;
|
|
729
|
+
}
|
|
730
|
+
return '';
|
|
731
|
+
};
|
|
732
|
+
if (payload.order.is_deleted) {
|
|
733
|
+
payment_status = '* DELETED *';
|
|
734
|
+
}
|
|
735
|
+
else if (payload.order.order_status === constants_1.ORDER_STATUS_ENUM.CANCELLED) {
|
|
736
|
+
payment_status = '* CANCELLED *';
|
|
737
|
+
}
|
|
738
|
+
else if (receipt_type === constants_1.RECEIPT_TYPE_ENUM.CUSTOMER || !payload.printer_settings.keep_kitchen_receipt_concise) {
|
|
739
|
+
// OPEN BILL has priority - check first if there's an open amount (PAY_LATER)
|
|
740
|
+
if (openAmount > 0) {
|
|
741
|
+
payment_status = '* OPEN BILL *';
|
|
742
|
+
payment_details.push({
|
|
743
|
+
left: `Open Amount${getExpectedPaymentLabel()}`,
|
|
744
|
+
right: (0, common_1.localeAmount)(currencySymbol, openAmount),
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
else if (parsedAmountPayedSoFar >= (0, common_1.parseNum)(grandTotal)) {
|
|
748
|
+
payment_status = '* PAID *';
|
|
749
|
+
}
|
|
750
|
+
else if (parsedAmountPayedSoFar > 0) {
|
|
751
|
+
payment_status = '* PARTIALLY PAID *';
|
|
752
|
+
payment_details.push({
|
|
753
|
+
left: `Pending Amount${getExpectedPaymentLabel()}`,
|
|
754
|
+
right: (0, common_1.localeAmount)(currencySymbol, grandTotal - parsedAmountPayedSoFar),
|
|
755
|
+
});
|
|
756
|
+
}
|
|
757
|
+
else {
|
|
758
|
+
payment_status = '* UNPAID *';
|
|
759
|
+
const expectedPaymentLabel = getExpectedPaymentLabel();
|
|
760
|
+
if (expectedPaymentLabel) {
|
|
761
|
+
payment_details.push({
|
|
762
|
+
left: `Amount Due${expectedPaymentLabel}`,
|
|
763
|
+
right: (0, common_1.localeAmount)(currencySymbol, grandTotal),
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
let delivery_instructions = null;
|
|
769
|
+
let cancel_reason = null;
|
|
770
|
+
if (payload.order.order_status === constants_1.ORDER_STATUS_ENUM.CANCELLED) {
|
|
771
|
+
cancel_reason = (0, common_1.getFormattedCancellationReason)(payload.order.cancel_reason) ?? null;
|
|
772
|
+
}
|
|
773
|
+
else if (payload.order.delivery_details != null && payload.printer_settings.print_delivery_details) {
|
|
774
|
+
delivery_instructions = `${payload.order.delivery_details.street}${payload.order.delivery_details.address_instructions.trim() !== ''
|
|
775
|
+
? `\n** ${payload.order.delivery_details.address_instructions} **`
|
|
776
|
+
: ''}`.trim();
|
|
777
|
+
}
|
|
778
|
+
let invoice_name = '';
|
|
779
|
+
if (is_kitchen_receipt) {
|
|
780
|
+
invoice_name = `Order #${payload.order.order_number ?? ''}`;
|
|
781
|
+
}
|
|
782
|
+
else {
|
|
783
|
+
invoice_name = `Invoice #${payload.order.order_number ?? ''}`;
|
|
784
|
+
if (isFullyPaid) {
|
|
785
|
+
// Either tax invoice ID is present or country is not Pakistan and tax business number is present
|
|
786
|
+
if (payload.order.tax_invoice_id || (country_alpha_2 !== constants_1.COUNTRY_ALPHA_2_ENUM.PK && tax_business_number)) {
|
|
787
|
+
invoice_name = `Tax ${invoice_name}`;
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
const engine = {
|
|
792
|
+
_id: payload.order._id ?? '',
|
|
793
|
+
tenant_details: {
|
|
794
|
+
image_url,
|
|
795
|
+
name,
|
|
796
|
+
restaurant_address,
|
|
797
|
+
support_email,
|
|
798
|
+
public_phone_numbers,
|
|
799
|
+
tax_business_number,
|
|
800
|
+
taxNumberTitle,
|
|
801
|
+
},
|
|
802
|
+
order_type: orderTypeName,
|
|
803
|
+
order_from,
|
|
804
|
+
placed_time: (0, moment_1.default)(payload.order.createdAt).format('ddd, MMMM Do, h:mmA'),
|
|
805
|
+
expected_time: estimated_time === null
|
|
806
|
+
? '(ASAP)'
|
|
807
|
+
: estimated_time
|
|
808
|
+
? `${(0, moment_1.default)(new Date(estimated_time).getTime()).calendar()}`
|
|
809
|
+
: null,
|
|
810
|
+
order_number: invoice_name,
|
|
811
|
+
customer_details: {
|
|
812
|
+
customer: receipt_type === constants_1.RECEIPT_TYPE_ENUM.CUSTOMER || !payload.printer_settings.keep_kitchen_receipt_concise
|
|
813
|
+
? `${customerName ?? ''}${customerName && customerPhone ? ' - ' : ''}${customerPhone ?? ''}`
|
|
814
|
+
: null,
|
|
815
|
+
special_instructions: displayOrderInstructions && payload.order.special_instructions != null
|
|
816
|
+
? payload.order.special_instructions
|
|
817
|
+
: null,
|
|
818
|
+
delivery_instructions,
|
|
819
|
+
},
|
|
820
|
+
order_details: {
|
|
821
|
+
staff_name,
|
|
822
|
+
order_taker_name,
|
|
823
|
+
rider_name,
|
|
824
|
+
covers: payload.order.dinein_details?.num_of_guests ?? null,
|
|
825
|
+
dinein_table_name: payload.order.dinein_details?.table_name ?? null,
|
|
826
|
+
prev_dinein_table_name,
|
|
827
|
+
},
|
|
828
|
+
payment_status,
|
|
829
|
+
order_link: payload.order.tax_invoice_id ??
|
|
830
|
+
(business_website ? `https://${business_website}/orders/${payload.order._id}` : null),
|
|
831
|
+
total_items,
|
|
832
|
+
unchanged_items,
|
|
833
|
+
edited_items,
|
|
834
|
+
removed_items,
|
|
835
|
+
new_items,
|
|
836
|
+
order_courses,
|
|
837
|
+
payment_details,
|
|
838
|
+
// // ====================<Footer>====================
|
|
839
|
+
footer: (() => {
|
|
840
|
+
const orderGrandTotal = payload.order.grand_total ?? 0;
|
|
841
|
+
const footerDetails = getReceiptEngineFooterDetails(payload.order, settings);
|
|
842
|
+
return footerDetails.concat({
|
|
843
|
+
left: `Grand Total${payload.order.gst && hide_gst_value ? ` (Incl. ${gstName})` : ''}`,
|
|
844
|
+
right: (0, common_1.localeAmount)(currencySymbol, orderGrandTotal),
|
|
845
|
+
});
|
|
846
|
+
})(),
|
|
847
|
+
show_modifiers,
|
|
848
|
+
is_kitchen_receipt,
|
|
849
|
+
full_width,
|
|
850
|
+
font_preference: payload.printer_settings.font_preference ?? constants_1.KITCHEN_DOCKET_FONT_TYPE_ENUM.DEFAULT,
|
|
851
|
+
display_item_price_on_kitchen_receipt: payload.printer_settings.display_item_price_on_kitchen_receipt,
|
|
852
|
+
keep_kitchen_receipt_concise: payload.printer_settings.keep_kitchen_receipt_concise,
|
|
853
|
+
cancel_reason,
|
|
854
|
+
};
|
|
855
|
+
return engine;
|
|
856
|
+
}
|