@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,899 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAppliedOfferIds = exports.getTotalSelectedOfferItemsAgainstOffer = void 0;
|
|
4
|
+
exports.getOfferWithPrice = getOfferWithPrice;
|
|
5
|
+
exports.convertOffersToWorkableOffers = convertOffersToWorkableOffers;
|
|
6
|
+
exports.calculatePointsRedeemedForOffer = calculatePointsRedeemedForOffer;
|
|
7
|
+
exports.calculateCustomerLoyaltyPoints = calculateCustomerLoyaltyPoints;
|
|
8
|
+
exports.getOffersWithStats = getOffersWithStats;
|
|
9
|
+
const constants_1 = require("../../constants");
|
|
10
|
+
const common_1 = require("./common");
|
|
11
|
+
const platform_catalog_1 = require("./platform-catalog");
|
|
12
|
+
const platform_num_1 = require("./platform-num");
|
|
13
|
+
const price_conversion_1 = require("./price-conversion");
|
|
14
|
+
function getOfferWithPrice(offer, writeable) {
|
|
15
|
+
// const convertToPrice = writeable ? convertPriceObjToCents : convertPriceObjFromCents;
|
|
16
|
+
const convertItemSpecialHours = writeable ? platform_num_1.convertSpecialHoursToCents : platform_num_1.convertSpecialHoursFromCents;
|
|
17
|
+
const convertToNum = writeable ? price_conversion_1.convertPriceToCents : price_conversion_1.convertPriceFromCents;
|
|
18
|
+
const newOffer = {
|
|
19
|
+
...offer,
|
|
20
|
+
};
|
|
21
|
+
if (writeable) {
|
|
22
|
+
if (newOffer.offer_special_hours != null && newOffer.offer_special_hours.length === 0) {
|
|
23
|
+
newOffer.offer_special_hours = null;
|
|
24
|
+
}
|
|
25
|
+
if (newOffer.pathway_to_unlock_type === constants_1.PATHWAY_TO_UNLOCK_TYPE_ENUM.ITEMS &&
|
|
26
|
+
newOffer.pathway_to_unlock_type_items != null) {
|
|
27
|
+
newOffer.pathway_to_unlock_type_orders = null;
|
|
28
|
+
newOffer.pathway_to_unlock_type_points = null;
|
|
29
|
+
}
|
|
30
|
+
else if (newOffer.pathway_to_unlock_type === constants_1.PATHWAY_TO_UNLOCK_TYPE_ENUM.ORDERS &&
|
|
31
|
+
newOffer.pathway_to_unlock_type_orders != null) {
|
|
32
|
+
newOffer.pathway_to_unlock_type_items = null;
|
|
33
|
+
newOffer.pathway_to_unlock_type_points = null;
|
|
34
|
+
}
|
|
35
|
+
else if (newOffer.pathway_to_unlock_type === constants_1.PATHWAY_TO_UNLOCK_TYPE_ENUM.POINTS &&
|
|
36
|
+
newOffer.pathway_to_unlock_type_points != null) {
|
|
37
|
+
newOffer.pathway_to_unlock_type_items = null;
|
|
38
|
+
newOffer.pathway_to_unlock_type_orders = null;
|
|
39
|
+
}
|
|
40
|
+
if (newOffer.reward_type === constants_1.OFFER_REWARD_TYPE_ENUM.ITEMS && newOffer.reward_items != null) {
|
|
41
|
+
newOffer.reward_discount = null;
|
|
42
|
+
newOffer.reward_discount_items = null;
|
|
43
|
+
newOffer.reward_points = null;
|
|
44
|
+
}
|
|
45
|
+
else if (newOffer.reward_type === constants_1.OFFER_REWARD_TYPE_ENUM.DISCOUNT && newOffer.reward_discount != null) {
|
|
46
|
+
newOffer.reward_items = null;
|
|
47
|
+
newOffer.reward_discount_items = null;
|
|
48
|
+
newOffer.reward_points = null;
|
|
49
|
+
}
|
|
50
|
+
else if (newOffer.reward_type === constants_1.OFFER_REWARD_TYPE_ENUM.DISCOUNT_ITEMS &&
|
|
51
|
+
newOffer.reward_discount_items != null) {
|
|
52
|
+
newOffer.reward_items = null;
|
|
53
|
+
newOffer.reward_points = null;
|
|
54
|
+
newOffer.reward_discount = null;
|
|
55
|
+
}
|
|
56
|
+
else if (newOffer.reward_type === constants_1.OFFER_REWARD_TYPE_ENUM.POINTS && newOffer.reward_points != null) {
|
|
57
|
+
newOffer.reward_items = null;
|
|
58
|
+
newOffer.reward_discount = null;
|
|
59
|
+
newOffer.reward_discount_items = null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
...newOffer,
|
|
64
|
+
...(newOffer.offer_special_hours != null
|
|
65
|
+
? {
|
|
66
|
+
offer_special_hours: convertItemSpecialHours(newOffer.offer_special_hours),
|
|
67
|
+
}
|
|
68
|
+
: {}),
|
|
69
|
+
...(newOffer.pathway_to_unlock_type_orders != null
|
|
70
|
+
? {
|
|
71
|
+
pathway_to_unlock_type_orders: {
|
|
72
|
+
...newOffer.pathway_to_unlock_type_orders,
|
|
73
|
+
total_amount: convertToNum(newOffer.pathway_to_unlock_type_orders.total_amount),
|
|
74
|
+
max_amount: newOffer.pathway_to_unlock_type_orders.max_amount != null
|
|
75
|
+
? convertToNum(newOffer.pathway_to_unlock_type_orders.max_amount)
|
|
76
|
+
: null,
|
|
77
|
+
},
|
|
78
|
+
}
|
|
79
|
+
: {}),
|
|
80
|
+
...(newOffer.pathway_to_unlock_type_items != null
|
|
81
|
+
? {
|
|
82
|
+
pathway_to_unlock_type_items: {
|
|
83
|
+
...newOffer.pathway_to_unlock_type_items,
|
|
84
|
+
total_amount: convertToNum(newOffer.pathway_to_unlock_type_items.total_amount),
|
|
85
|
+
},
|
|
86
|
+
}
|
|
87
|
+
: {}),
|
|
88
|
+
...(newOffer.pathway_to_unlock_type_points != null
|
|
89
|
+
? {
|
|
90
|
+
pathway_to_unlock_type_points: {
|
|
91
|
+
...newOffer.pathway_to_unlock_type_points,
|
|
92
|
+
total_amount: convertToNum(newOffer.pathway_to_unlock_type_points.total_amount),
|
|
93
|
+
},
|
|
94
|
+
}
|
|
95
|
+
: {}),
|
|
96
|
+
...(newOffer.reward_discount != null
|
|
97
|
+
? {
|
|
98
|
+
reward_discount: {
|
|
99
|
+
...newOffer.reward_discount,
|
|
100
|
+
discount_value: convertToNum(newOffer.reward_discount.discount_value),
|
|
101
|
+
},
|
|
102
|
+
}
|
|
103
|
+
: {}),
|
|
104
|
+
...(newOffer.reward_discount_items != null
|
|
105
|
+
? {
|
|
106
|
+
reward_discount_items: {
|
|
107
|
+
...newOffer.reward_discount_items,
|
|
108
|
+
discount_value: convertToNum(newOffer.reward_discount_items.discount_value),
|
|
109
|
+
},
|
|
110
|
+
}
|
|
111
|
+
: {}),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
// ====================================================================================================================
|
|
115
|
+
function convertOffersToWorkableOffers(offers, platform) {
|
|
116
|
+
const filteredOffers = [];
|
|
117
|
+
for (let i = 0; i < offers.length; i++) {
|
|
118
|
+
const offer = offers[i];
|
|
119
|
+
if (!offer.active || !offer.included_platforms.includes(platform)) {
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
// we try to find a schedule that is applicable to the current date and time
|
|
123
|
+
const applicableSchedule = (0, platform_catalog_1.findApplicableSchedule)(offer.offer_special_hours, platform);
|
|
124
|
+
// if there is no applicable schedule, we skip the item
|
|
125
|
+
if (applicableSchedule === false)
|
|
126
|
+
continue;
|
|
127
|
+
filteredOffers.push(offer);
|
|
128
|
+
}
|
|
129
|
+
filteredOffers.sort((a, b) => a.sort_id - b.sort_id);
|
|
130
|
+
return filteredOffers;
|
|
131
|
+
}
|
|
132
|
+
// ====================================================================================================================
|
|
133
|
+
function calculatePointsRedeemedForOffer(redeemedOffer, totalOrderPrice, categories) {
|
|
134
|
+
if (redeemedOffer.reward_type !== constants_1.OFFER_REWARD_TYPE_ENUM.POINTS || redeemedOffer.reward_points == null) {
|
|
135
|
+
return 0;
|
|
136
|
+
}
|
|
137
|
+
let times = 1;
|
|
138
|
+
if (!redeemedOffer.reward_points.once_per_order) {
|
|
139
|
+
// This means that we need to see if the condition to unlock the redeemedOffer is met multiple times
|
|
140
|
+
// i.e. if the customer has ordered 2 pizzas, and the redeemedOffer is applicable for 1 pizza
|
|
141
|
+
// then we need to calculate the points redeemed for 2 pizzas
|
|
142
|
+
if (redeemedOffer.pathway_to_unlock_type === constants_1.PATHWAY_TO_UNLOCK_TYPE_ENUM.ITEMS) {
|
|
143
|
+
if (redeemedOffer.pathway_to_unlock_type_items != null) {
|
|
144
|
+
const { num_of_items, total_amount, excluded_refs, exclusive_refs, item_ids } = redeemedOffer.pathway_to_unlock_type_items;
|
|
145
|
+
// A Bachelor Item is an item that meets the criteria of the redeemedOffer and doesn't have any redeemedOffer applied to it
|
|
146
|
+
const bachelorItems = getCartItemsApplicableToOfferItemsQuantity({
|
|
147
|
+
categories,
|
|
148
|
+
excluded_refs,
|
|
149
|
+
exclusive_refs,
|
|
150
|
+
item_ids,
|
|
151
|
+
});
|
|
152
|
+
if (bachelorItems >= num_of_items) {
|
|
153
|
+
if (totalOrderPrice >= total_amount) {
|
|
154
|
+
const timesForItems = Math.floor(bachelorItems / (num_of_items || 1));
|
|
155
|
+
const timesForAmount = Math.floor(totalOrderPrice / (total_amount || 1));
|
|
156
|
+
// we need to find the minimum of the two
|
|
157
|
+
const minTimes = Math.min(timesForItems, timesForAmount);
|
|
158
|
+
if (minTimes > 1) {
|
|
159
|
+
times = minTimes;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
else if (redeemedOffer.pathway_to_unlock_type === constants_1.PATHWAY_TO_UNLOCK_TYPE_ENUM.ORDERS) {
|
|
166
|
+
if (redeemedOffer.pathway_to_unlock_type_orders != null) {
|
|
167
|
+
const { total_amount } = redeemedOffer.pathway_to_unlock_type_orders;
|
|
168
|
+
if (totalOrderPrice >= total_amount) {
|
|
169
|
+
const timesForAmount = Math.floor(totalOrderPrice / (total_amount || 1));
|
|
170
|
+
if (timesForAmount > 1) {
|
|
171
|
+
times = timesForAmount;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
// 💡 NOTE: We don't need to check for pathway_to_unlock_type_points because it is not possible to have
|
|
177
|
+
// pathway_to_unlock_type_points and reward_points at the same time
|
|
178
|
+
// TODO: Add pathway_to_unlock_type_vouchers
|
|
179
|
+
}
|
|
180
|
+
let pointsRedeemed = redeemedOffer.reward_points.num_of_points ?? 0;
|
|
181
|
+
pointsRedeemed *= times;
|
|
182
|
+
return pointsRedeemed;
|
|
183
|
+
}
|
|
184
|
+
// The purpose of this function is to calculate the total number of points that are applied/consumed by the cart items
|
|
185
|
+
function calculateCustomerLoyaltyPoints({ customerLoyaltyPoints, orderDiscountDetails, currentItemsPrice, totalDiscountApplied, categories, offers, }) {
|
|
186
|
+
const totalOrderPrice = (currentItemsPrice ?? 0) - (totalDiscountApplied ?? 0);
|
|
187
|
+
let loyaltyPoints = customerLoyaltyPoints ?? 0;
|
|
188
|
+
let addedLoyaltyPoints = loyaltyPoints;
|
|
189
|
+
let deductedLoyaltyPoints = loyaltyPoints;
|
|
190
|
+
const offerApplicableQuantity = {};
|
|
191
|
+
const offerConsumedQuantity = {};
|
|
192
|
+
const renderClaimPoints = (redeemedOffer) => {
|
|
193
|
+
// if we find the offer that has been redeemed
|
|
194
|
+
if (redeemedOffer == null)
|
|
195
|
+
return;
|
|
196
|
+
const applicableQuantity = offerApplicableQuantity[redeemedOffer._id] ?? 1;
|
|
197
|
+
const consumedQuantity = offerConsumedQuantity[redeemedOffer._id] ?? 0;
|
|
198
|
+
if (consumedQuantity >= applicableQuantity) {
|
|
199
|
+
offerConsumedQuantity[redeemedOffer._id] = 0;
|
|
200
|
+
}
|
|
201
|
+
if (!offerConsumedQuantity[redeemedOffer._id]) {
|
|
202
|
+
if (redeemedOffer.reward_type === constants_1.OFFER_REWARD_TYPE_ENUM.POINTS) {
|
|
203
|
+
const points = calculatePointsRedeemedForOffer(redeemedOffer, totalOrderPrice, categories);
|
|
204
|
+
loyaltyPoints += points;
|
|
205
|
+
addedLoyaltyPoints += points;
|
|
206
|
+
}
|
|
207
|
+
else if (redeemedOffer.pathway_to_unlock_type === constants_1.PATHWAY_TO_UNLOCK_TYPE_ENUM.POINTS) {
|
|
208
|
+
const points = redeemedOffer.pathway_to_unlock_type_points?.num_of_points ?? 0;
|
|
209
|
+
loyaltyPoints -= points;
|
|
210
|
+
deductedLoyaltyPoints += points;
|
|
211
|
+
}
|
|
212
|
+
offerConsumedQuantity[redeemedOffer._id] = 1;
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
offerConsumedQuantity[redeemedOffer._id] += 1;
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
const offersThatHavePointsMap = {};
|
|
219
|
+
let hasOffersThatHavePoints = false;
|
|
220
|
+
for (let i = 0; i < offers.length; i++) {
|
|
221
|
+
const offer = offers[i];
|
|
222
|
+
if (offer.reward_type === constants_1.OFFER_REWARD_TYPE_ENUM.POINTS) {
|
|
223
|
+
offersThatHavePointsMap[offer._id] = offer;
|
|
224
|
+
hasOffersThatHavePoints = true;
|
|
225
|
+
offerApplicableQuantity[offer._id] = 1;
|
|
226
|
+
}
|
|
227
|
+
else if (offer.pathway_to_unlock_type === constants_1.PATHWAY_TO_UNLOCK_TYPE_ENUM.POINTS) {
|
|
228
|
+
offersThatHavePointsMap[offer._id] = offer;
|
|
229
|
+
hasOffersThatHavePoints = true;
|
|
230
|
+
if (offer.reward_type === constants_1.OFFER_REWARD_TYPE_ENUM.ITEMS) {
|
|
231
|
+
offerApplicableQuantity[offer._id] = offer.reward_items?.num_of_items ?? 1;
|
|
232
|
+
}
|
|
233
|
+
else if (offer.reward_type === constants_1.OFFER_REWARD_TYPE_ENUM.DISCOUNT_ITEMS) {
|
|
234
|
+
offerApplicableQuantity[offer._id] = offer.reward_discount_items?.num_of_items ?? 1;
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
offerApplicableQuantity[offer._id] = 1;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
if (hasOffersThatHavePoints) {
|
|
242
|
+
// Check if the order has any loyalty or voucher applied
|
|
243
|
+
if (orderDiscountDetails != null) {
|
|
244
|
+
const loyaltyDiscountId = orderDiscountDetails.loyalty_discount_id;
|
|
245
|
+
if (loyaltyDiscountId != null) {
|
|
246
|
+
const redeemedOffer = offersThatHavePointsMap[loyaltyDiscountId];
|
|
247
|
+
if (redeemedOffer != null) {
|
|
248
|
+
renderClaimPoints(redeemedOffer);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
const voucherDiscountId = orderDiscountDetails.voucher_discount_id;
|
|
252
|
+
if (voucherDiscountId != null) {
|
|
253
|
+
const redeemedOffer = offersThatHavePointsMap[voucherDiscountId];
|
|
254
|
+
if (redeemedOffer != null) {
|
|
255
|
+
renderClaimPoints(redeemedOffer);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
// ===========================================================================================
|
|
260
|
+
// Calculate the total number of points that are applied/consumed by the cart items
|
|
261
|
+
const itemsThatHaveLoyaltyOrVoucherApplied = categories?.reduce((acc, category) => {
|
|
262
|
+
const items = [];
|
|
263
|
+
category.items.forEach((item) => {
|
|
264
|
+
if (item.item_discount_details != null &&
|
|
265
|
+
(item.item_discount_details.voucher_discount_id != null ||
|
|
266
|
+
item.item_discount_details.loyalty_discount_id != null)) {
|
|
267
|
+
items.push(item);
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
return acc.concat(items);
|
|
271
|
+
}, []) ?? [];
|
|
272
|
+
if (itemsThatHaveLoyaltyOrVoucherApplied.length > 0) {
|
|
273
|
+
// it means there are items that have loyalty or voucher applied
|
|
274
|
+
for (let i = 0; i < itemsThatHaveLoyaltyOrVoucherApplied.length; i++) {
|
|
275
|
+
const item = itemsThatHaveLoyaltyOrVoucherApplied[i];
|
|
276
|
+
// we skip the item if it doesn't have any loyalty or voucher applied
|
|
277
|
+
if (item.item_discount_details == null)
|
|
278
|
+
continue;
|
|
279
|
+
// Step 1: Use Case for Offers
|
|
280
|
+
if (item.item_discount_details.loyalty_discount_id != null) {
|
|
281
|
+
const loyaltyDiscountId = item.item_discount_details.loyalty_discount_id;
|
|
282
|
+
const redeemedOffer = offersThatHavePointsMap[loyaltyDiscountId];
|
|
283
|
+
if (redeemedOffer != null) {
|
|
284
|
+
renderClaimPoints(redeemedOffer);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
if (item.item_discount_details.voucher_discount_id != null) {
|
|
288
|
+
const voucherDiscountId = item.item_discount_details.voucher_discount_id;
|
|
289
|
+
const redeemedOffer = offersThatHavePointsMap[voucherDiscountId];
|
|
290
|
+
if (redeemedOffer != null) {
|
|
291
|
+
renderClaimPoints(redeemedOffer);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return {
|
|
298
|
+
loyaltyPoints,
|
|
299
|
+
addedLoyaltyPoints,
|
|
300
|
+
deductedLoyaltyPoints,
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
function getCartItemsApplicableToOfferItemsQuantity({ categories, excluded_refs, exclusive_refs, item_ids, }) {
|
|
304
|
+
if (categories == null)
|
|
305
|
+
return 0;
|
|
306
|
+
const checkIfItemHasAnyRef = (item, refs_arr) => {
|
|
307
|
+
let hasRef = false;
|
|
308
|
+
if (item.modifiers != null) {
|
|
309
|
+
const recursiveCheck = (modifiers) => {
|
|
310
|
+
outer: for (let i = 0; i < modifiers.length; i++) {
|
|
311
|
+
if (hasRef)
|
|
312
|
+
break outer;
|
|
313
|
+
const modifier = modifiers[i];
|
|
314
|
+
if (refs_arr.includes(modifier.ref)) {
|
|
315
|
+
hasRef = true;
|
|
316
|
+
break outer;
|
|
317
|
+
}
|
|
318
|
+
for (let j = 0; j < modifier.options.length; j++) {
|
|
319
|
+
const option = modifier.options[j];
|
|
320
|
+
if (refs_arr.includes(option.ref)) {
|
|
321
|
+
hasRef = true;
|
|
322
|
+
break outer;
|
|
323
|
+
}
|
|
324
|
+
if (option.modifiers != null) {
|
|
325
|
+
recursiveCheck(option.modifiers);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
recursiveCheck(item.modifiers);
|
|
331
|
+
}
|
|
332
|
+
return hasRef;
|
|
333
|
+
};
|
|
334
|
+
const applicableItems = categories.reduce((acc, category) => {
|
|
335
|
+
category.items.forEach((item) => {
|
|
336
|
+
if (
|
|
337
|
+
// We only want to check for items that don't have any loyalty or voucher discounts
|
|
338
|
+
item.item_discount_details?.loyalty_discount_id == null &&
|
|
339
|
+
item.item_discount_details?.voucher_discount_id == null &&
|
|
340
|
+
item_ids.includes(item.item_id) &&
|
|
341
|
+
// We only want to check for items that don't have any modifiers/options that are excluded
|
|
342
|
+
(excluded_refs.length === 0 || (excluded_refs.length > 0 && !checkIfItemHasAnyRef(item, excluded_refs))) &&
|
|
343
|
+
// We only want to check for items that have at least one modifier/option that is inclusive
|
|
344
|
+
(exclusive_refs.length === 0 || (exclusive_refs.length > 0 && checkIfItemHasAnyRef(item, exclusive_refs)))) {
|
|
345
|
+
acc.push({
|
|
346
|
+
item_id: item.item_id,
|
|
347
|
+
quantity: item.quantity,
|
|
348
|
+
subtotal: item.subtotal,
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
return acc;
|
|
353
|
+
}, []) ?? [];
|
|
354
|
+
const totalQuantity = applicableItems.reduce((acc, item) => {
|
|
355
|
+
acc += item.quantity;
|
|
356
|
+
return acc;
|
|
357
|
+
}, 0);
|
|
358
|
+
return totalQuantity;
|
|
359
|
+
}
|
|
360
|
+
// ====================================================================================================================
|
|
361
|
+
/**
|
|
362
|
+
* Check if there are any eligible items for a discount offer
|
|
363
|
+
* Returns true if at least one item in categories is NOT in excluded_refs
|
|
364
|
+
*/
|
|
365
|
+
function hasEligibleItemsForDiscount(categories, excluded_refs) {
|
|
366
|
+
if (!categories?.length)
|
|
367
|
+
return false;
|
|
368
|
+
if (!excluded_refs?.length)
|
|
369
|
+
return true; // No exclusions means all items are eligible
|
|
370
|
+
for (const category of categories) {
|
|
371
|
+
// If category is excluded, skip it
|
|
372
|
+
if (excluded_refs.includes(category.category_id)) {
|
|
373
|
+
continue;
|
|
374
|
+
}
|
|
375
|
+
// Check if any item in this category is NOT excluded
|
|
376
|
+
for (const item of category.items ?? []) {
|
|
377
|
+
if (!excluded_refs.includes(item.item_id)) {
|
|
378
|
+
return true; // Found at least one eligible item
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
return false; // All items are excluded
|
|
383
|
+
}
|
|
384
|
+
// ====================================================================================================================
|
|
385
|
+
const getTotalSelectedOfferItemsAgainstOffer = (categories, offer_id) => {
|
|
386
|
+
const totalOfferItems = categories?.reduce((acc, category) => {
|
|
387
|
+
let totalItems = 0;
|
|
388
|
+
category.items.forEach((item) => {
|
|
389
|
+
if (item.item_discount_details != null &&
|
|
390
|
+
(item.item_discount_details.loyalty_discount_id === offer_id ||
|
|
391
|
+
item.item_discount_details.voucher_discount_id === offer_id)) {
|
|
392
|
+
totalItems += item.quantity;
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
return acc + totalItems;
|
|
396
|
+
}, 0) ?? 0;
|
|
397
|
+
return totalOfferItems;
|
|
398
|
+
};
|
|
399
|
+
exports.getTotalSelectedOfferItemsAgainstOffer = getTotalSelectedOfferItemsAgainstOffer;
|
|
400
|
+
// export function getOffersWithStats({
|
|
401
|
+
// offers,
|
|
402
|
+
// customer,
|
|
403
|
+
// currency_symbol,
|
|
404
|
+
// currentItemsPrice,
|
|
405
|
+
// totalDiscountApplied,
|
|
406
|
+
// categories,
|
|
407
|
+
// order_discount_details,
|
|
408
|
+
// }: IGetOffersWithStats) {
|
|
409
|
+
// let totalLoyaltyPointsOfCustomer: number | null = null;
|
|
410
|
+
// let totalAddedLoyaltyPoints = 0;
|
|
411
|
+
// let totalClaimableOffers = 0;
|
|
412
|
+
// const unlockedOffersApplicableTimes: Record<string, number> = {};
|
|
413
|
+
// const offersWithStats = offers.map((offer) => {
|
|
414
|
+
// const orderValue = (currentItemsPrice ?? 0) - (totalDiscountApplied ?? 0);
|
|
415
|
+
// const totalOrders = customer?.total_orders ?? 0;
|
|
416
|
+
// const stats: IOfferStats = {
|
|
417
|
+
// progress: 0,
|
|
418
|
+
// is_unlocked: false,
|
|
419
|
+
// message: '',
|
|
420
|
+
// invalid_offer: false,
|
|
421
|
+
// redeemed_times: 0,
|
|
422
|
+
// claimable: false,
|
|
423
|
+
// applicable_quantity: 0,
|
|
424
|
+
// };
|
|
425
|
+
// let totalOfferItemsSelected = 0;
|
|
426
|
+
// let applicableQuantity = 1;
|
|
427
|
+
// let maxRedeemableTimes = 1;
|
|
428
|
+
// // First We Check if the offer is already redeemed
|
|
429
|
+
// if (offer.reward_type === OFFER_REWARD_TYPE_ENUM.ITEMS && offer.reward_items != null) {
|
|
430
|
+
// // we check if the newCustomer has redeemed enough items to mark the offer as redeemed
|
|
431
|
+
// totalOfferItemsSelected = getTotalSelectedOfferItemsAgainstOffer(categories, offer._id);
|
|
432
|
+
// applicableQuantity = offer.reward_items.num_of_items || 1;
|
|
433
|
+
// stats.redeemed_times = Math.floor(totalOfferItemsSelected / applicableQuantity);
|
|
434
|
+
// maxRedeemableTimes = 100;
|
|
435
|
+
// } else if (offer.reward_type === OFFER_REWARD_TYPE_ENUM.DISCOUNT_ITEMS && offer.reward_discount_items != null) {
|
|
436
|
+
// // we check if the newCustomer has redeemed enough items to mark the offer as redeemed
|
|
437
|
+
// totalOfferItemsSelected = getTotalSelectedOfferItemsAgainstOffer(categories, offer._id);
|
|
438
|
+
// applicableQuantity = offer.reward_discount_items.num_of_items || 1;
|
|
439
|
+
// stats.redeemed_times = Math.floor(totalOfferItemsSelected / applicableQuantity);
|
|
440
|
+
// maxRedeemableTimes = 100;
|
|
441
|
+
// } else if (offer.reward_type === OFFER_REWARD_TYPE_ENUM.POINTS && offer.reward_points) {
|
|
442
|
+
// // we check if the order_discount_details.loyalty_discount_id has the same id as the offer._id
|
|
443
|
+
// const isRedeemed =
|
|
444
|
+
// order_discount_details != null &&
|
|
445
|
+
// (order_discount_details.loyalty_discount_id === offer._id ||
|
|
446
|
+
// order_discount_details.voucher_discount_id === offer._id);
|
|
447
|
+
// stats.redeemed_times = isRedeemed ? 1 : 0;
|
|
448
|
+
// maxRedeemableTimes = 1;
|
|
449
|
+
// } else if (offer.reward_type === OFFER_REWARD_TYPE_ENUM.DISCOUNT && offer.reward_discount != null) {
|
|
450
|
+
// // we check if the order_discount_details.loyalty_discount_id has the same id as the offer._id
|
|
451
|
+
// const isRedeemed =
|
|
452
|
+
// order_discount_details != null &&
|
|
453
|
+
// (order_discount_details.loyalty_discount_id === offer._id ||
|
|
454
|
+
// order_discount_details.voucher_discount_id === offer._id);
|
|
455
|
+
// stats.redeemed_times = isRedeemed ? 1 : 0;
|
|
456
|
+
// maxRedeemableTimes = 1;
|
|
457
|
+
// }
|
|
458
|
+
// if (offer.pathway_to_unlock_type === PATHWAY_TO_UNLOCK_TYPE_ENUM.ITEMS) {
|
|
459
|
+
// if (offer.pathway_to_unlock_type_items != null) {
|
|
460
|
+
// const { num_of_items, total_amount, excluded_refs, exclusive_refs, item_ids } =
|
|
461
|
+
// offer.pathway_to_unlock_type_items;
|
|
462
|
+
// // A Bachelor Item is an item that meets the criteria of the offer and doesn't have any offer applied to it
|
|
463
|
+
// const bachelorItems = getCartItemsApplicableToOfferItemsQuantity({
|
|
464
|
+
// categories,
|
|
465
|
+
// excluded_refs,
|
|
466
|
+
// exclusive_refs,
|
|
467
|
+
// item_ids,
|
|
468
|
+
// });
|
|
469
|
+
// const totalItemsSelected = totalOfferItemsSelected + bachelorItems;
|
|
470
|
+
// // This means that the offer is only applicable for the current day
|
|
471
|
+
// if (totalItemsSelected >= num_of_items) {
|
|
472
|
+
// if (orderValue >= total_amount) {
|
|
473
|
+
// if (bachelorItems >= num_of_items) {
|
|
474
|
+
// // This means that the customer has enough items to unlock the offer
|
|
475
|
+
// stats.progress = 100;
|
|
476
|
+
// stats.is_unlocked = true;
|
|
477
|
+
// stats.claimable = stats.redeemed_times < maxRedeemableTimes;
|
|
478
|
+
// if (stats.claimable) {
|
|
479
|
+
// stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
480
|
+
// stats.applicable_quantity = applicableQuantity * (stats.redeemed_times + 1);
|
|
481
|
+
// } else {
|
|
482
|
+
// stats.message = `You have already redeemed this offer ✅`;
|
|
483
|
+
// stats.applicable_quantity = applicableQuantity * (stats.redeemed_times || 1);
|
|
484
|
+
// }
|
|
485
|
+
// unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
|
|
486
|
+
// } else {
|
|
487
|
+
// stats.progress = Math.round((bachelorItems / (applicableQuantity || 1)) * 100);
|
|
488
|
+
// stats.message = `You are ${applicableQuantity - bachelorItems} items away from unlocking this offer`;
|
|
489
|
+
// stats.is_unlocked = true;
|
|
490
|
+
// stats.claimable = false;
|
|
491
|
+
// if (stats.redeemed_times > 0) {
|
|
492
|
+
// stats.applicable_quantity = applicableQuantity * stats.redeemed_times;
|
|
493
|
+
// unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
|
|
494
|
+
// }
|
|
495
|
+
// }
|
|
496
|
+
// } else {
|
|
497
|
+
// // This means that the customer has not spent enough to unlock the offer
|
|
498
|
+
// // But they have enough items to unlock the offer
|
|
499
|
+
// stats.progress = 90;
|
|
500
|
+
// stats.message = `You are almost there. Spend ${currency_symbol}${parseNum(
|
|
501
|
+
// total_amount - orderValue,
|
|
502
|
+
// )} more in this order to unlock this offer 🔓`;
|
|
503
|
+
// }
|
|
504
|
+
// } else {
|
|
505
|
+
// // This means that the customer has not yet added enough items to unlock the offer
|
|
506
|
+
// stats.progress = Math.round((bachelorItems / (num_of_items || 1)) * 100);
|
|
507
|
+
// stats.message = `You are ${num_of_items - bachelorItems} items away from unlocking this offer`;
|
|
508
|
+
// }
|
|
509
|
+
// } else {
|
|
510
|
+
// // If pathway to unlock type items is null then we can't proceed
|
|
511
|
+
// stats.invalid_offer = true;
|
|
512
|
+
// stats.message = `Offer pathway to unlock type items is empty`;
|
|
513
|
+
// }
|
|
514
|
+
// }
|
|
515
|
+
// // If pathway to unlock type is orders
|
|
516
|
+
// else if (offer.pathway_to_unlock_type === PATHWAY_TO_UNLOCK_TYPE_ENUM.ORDERS) {
|
|
517
|
+
// // If pathway to unlock type is orders then pathway to unlock type orders should not be null in order to proceed
|
|
518
|
+
// if (offer.pathway_to_unlock_type_orders != null) {
|
|
519
|
+
// const { min_num_of_orders, max_num_of_orders, total_amount } = offer.pathway_to_unlock_type_orders;
|
|
520
|
+
// if (totalOrders >= min_num_of_orders) {
|
|
521
|
+
// // Either the max_num_of_orders is infinity, or the customer has not reached the max_num_of_orders
|
|
522
|
+
// if (max_num_of_orders == null || totalOrders <= max_num_of_orders) {
|
|
523
|
+
// if (orderValue >= total_amount) {
|
|
524
|
+
// stats.progress = 100;
|
|
525
|
+
// stats.is_unlocked = true;
|
|
526
|
+
// stats.claimable = stats.redeemed_times < maxRedeemableTimes;
|
|
527
|
+
// if (stats.claimable) {
|
|
528
|
+
// stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
529
|
+
// stats.applicable_quantity = applicableQuantity * (stats.redeemed_times + 1);
|
|
530
|
+
// } else {
|
|
531
|
+
// stats.message = `You have already redeemed this offer ✅`;
|
|
532
|
+
// stats.applicable_quantity = applicableQuantity * (stats.redeemed_times || 1);
|
|
533
|
+
// }
|
|
534
|
+
// unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
|
|
535
|
+
// } else {
|
|
536
|
+
// // This means that the customer has not spent enough to unlock the offer
|
|
537
|
+
// // But they have enough orders to unlock the offer
|
|
538
|
+
// stats.progress = 90;
|
|
539
|
+
// stats.message = `You are almost there. Spend ${currency_symbol}${parseNum(
|
|
540
|
+
// total_amount - orderValue,
|
|
541
|
+
// )} more in this order to unlock this offer 🔓`;
|
|
542
|
+
// }
|
|
543
|
+
// } else {
|
|
544
|
+
// // This means that the customer has reached the max_num_of_orders
|
|
545
|
+
// stats.progress = 100;
|
|
546
|
+
// stats.is_unlocked = false;
|
|
547
|
+
// stats.message = `⛔️ You are not eligible for this offer ⛔️`;
|
|
548
|
+
// }
|
|
549
|
+
// } else {
|
|
550
|
+
// stats.progress = Math.round((totalOrders / (min_num_of_orders || 1)) * 100);
|
|
551
|
+
// stats.message = `You are ${min_num_of_orders - totalOrders} orders away from unlocking this offer`;
|
|
552
|
+
// }
|
|
553
|
+
// } else {
|
|
554
|
+
// // If pathway to unlock type orders is null then we can't proceed
|
|
555
|
+
// stats.invalid_offer = true;
|
|
556
|
+
// stats.message = `Offer pathway to unlock type orders is empty`;
|
|
557
|
+
// }
|
|
558
|
+
// }
|
|
559
|
+
// // If pathway to unlock type is points
|
|
560
|
+
// else if (offer.pathway_to_unlock_type === PATHWAY_TO_UNLOCK_TYPE_ENUM.POINTS) {
|
|
561
|
+
// // If pathway to unlock type is points then pathway to unlock type points should not be null in order to proceed
|
|
562
|
+
// if (offer.pathway_to_unlock_type_points != null) {
|
|
563
|
+
// // Pathway to unlock type points should have num_of_points, total_amount and applicable_unlock_days
|
|
564
|
+
// // Applicant unlock days can be null if there is no restriction on days
|
|
565
|
+
// const { num_of_points, total_amount } = offer.pathway_to_unlock_type_points;
|
|
566
|
+
// if (totalLoyaltyPointsOfCustomer == null) {
|
|
567
|
+
// const { addedLoyaltyPoints, loyaltyPoints } = calculateCustomerLoyaltyPoints({
|
|
568
|
+
// customerLoyaltyPoints: customer?.loyalty_points,
|
|
569
|
+
// orderDiscountDetails: order_discount_details,
|
|
570
|
+
// currentItemsPrice,
|
|
571
|
+
// categories,
|
|
572
|
+
// totalDiscountApplied,
|
|
573
|
+
// offers,
|
|
574
|
+
// });
|
|
575
|
+
// totalLoyaltyPointsOfCustomer = loyaltyPoints;
|
|
576
|
+
// totalAddedLoyaltyPoints = addedLoyaltyPoints;
|
|
577
|
+
// }
|
|
578
|
+
// if (totalAddedLoyaltyPoints >= num_of_points) {
|
|
579
|
+
// // This means that the offer is only applicable for the current day
|
|
580
|
+
// if (orderValue >= total_amount) {
|
|
581
|
+
// if (totalLoyaltyPointsOfCustomer >= num_of_points) {
|
|
582
|
+
// stats.progress = 100;
|
|
583
|
+
// stats.is_unlocked = true;
|
|
584
|
+
// stats.claimable = stats.redeemed_times < maxRedeemableTimes;
|
|
585
|
+
// if (stats.claimable) {
|
|
586
|
+
// stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
587
|
+
// stats.applicable_quantity = applicableQuantity * (stats.redeemed_times + 1);
|
|
588
|
+
// } else {
|
|
589
|
+
// stats.message = `You have already redeemed this offer ✅`;
|
|
590
|
+
// stats.applicable_quantity = applicableQuantity * (stats.redeemed_times || 1);
|
|
591
|
+
// }
|
|
592
|
+
// unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
|
|
593
|
+
// } else {
|
|
594
|
+
// stats.progress = Math.round((totalLoyaltyPointsOfCustomer / (num_of_points || 1)) * 100);
|
|
595
|
+
// stats.message = `You are ${
|
|
596
|
+
// num_of_points - totalLoyaltyPointsOfCustomer
|
|
597
|
+
// } points away from unlocking this offer`;
|
|
598
|
+
// stats.is_unlocked = true;
|
|
599
|
+
// stats.claimable = false;
|
|
600
|
+
// if (stats.redeemed_times > 0) {
|
|
601
|
+
// // By Default
|
|
602
|
+
// let redeemed_times = stats.redeemed_times;
|
|
603
|
+
// let leftPoints = totalLoyaltyPointsOfCustomer;
|
|
604
|
+
// while (leftPoints < 0) {
|
|
605
|
+
// redeemed_times -= 1;
|
|
606
|
+
// leftPoints += num_of_points;
|
|
607
|
+
// }
|
|
608
|
+
// stats.applicable_quantity = applicableQuantity * redeemed_times;
|
|
609
|
+
// unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
|
|
610
|
+
// }
|
|
611
|
+
// }
|
|
612
|
+
// } else {
|
|
613
|
+
// // This means that the customer has not spent enough to unlock the offer
|
|
614
|
+
// // But they have enough points to unlock the offer
|
|
615
|
+
// stats.progress = 90;
|
|
616
|
+
// stats.message = `You are almost there. Spend ${currency_symbol}${parseNum(
|
|
617
|
+
// parseNum(total_amount - orderValue),
|
|
618
|
+
// )} more in this order to unlock this offer 🔓`;
|
|
619
|
+
// }
|
|
620
|
+
// } else {
|
|
621
|
+
// stats.progress = Math.round((totalLoyaltyPointsOfCustomer / (num_of_points || 1)) * 100);
|
|
622
|
+
// stats.message = `You are ${
|
|
623
|
+
// num_of_points - totalLoyaltyPointsOfCustomer
|
|
624
|
+
// } points away from unlocking this offer`;
|
|
625
|
+
// }
|
|
626
|
+
// } else {
|
|
627
|
+
// // If pathway to unlock type points is null then we can't proceed
|
|
628
|
+
// stats.invalid_offer = true;
|
|
629
|
+
// stats.message = `Offer pathway to unlock type points is empty`;
|
|
630
|
+
// }
|
|
631
|
+
// }
|
|
632
|
+
// stats.claimable = stats.claimable && stats.is_unlocked;
|
|
633
|
+
// if (stats.claimable) {
|
|
634
|
+
// totalClaimableOffers += 1;
|
|
635
|
+
// }
|
|
636
|
+
// return {
|
|
637
|
+
// offer,
|
|
638
|
+
// stats,
|
|
639
|
+
// };
|
|
640
|
+
// });
|
|
641
|
+
// return { offersWithStats, totalClaimableOffers, unlockedOffersApplicableTimes };
|
|
642
|
+
// }
|
|
643
|
+
// =====================><=====================
|
|
644
|
+
function getOffersWithStats({ offers, customer, currency_symbol, currentItemsPrice, totalDiscountApplied, categories, order_discount_details, }) {
|
|
645
|
+
const offersWithStats = [];
|
|
646
|
+
const totalOrders = customer?.total_orders ?? 0;
|
|
647
|
+
const orderPrice = currentItemsPrice ?? 0;
|
|
648
|
+
const totalDiscount = totalDiscountApplied ?? 0;
|
|
649
|
+
const orderDiscount = order_discount_details?.total_discount ?? 0;
|
|
650
|
+
const itemsDiscount = totalDiscount - orderDiscount;
|
|
651
|
+
const unlockedOffersApplicableTimes = {};
|
|
652
|
+
let totalClaimableOffers = 0;
|
|
653
|
+
for (let i = 0; i < offers.length; i++) {
|
|
654
|
+
const offer = offers[i];
|
|
655
|
+
const stats = {
|
|
656
|
+
progress: 0,
|
|
657
|
+
message: '',
|
|
658
|
+
invalid_offer: false,
|
|
659
|
+
redeemed_times: 0,
|
|
660
|
+
claimable: false,
|
|
661
|
+
applicable_quantity: 0,
|
|
662
|
+
};
|
|
663
|
+
if (offer.pathway_to_unlock_type === constants_1.PATHWAY_TO_UNLOCK_TYPE_ENUM.ORDERS) {
|
|
664
|
+
if (offer.pathway_to_unlock_type_orders == null)
|
|
665
|
+
continue;
|
|
666
|
+
const orderValue = orderPrice - itemsDiscount;
|
|
667
|
+
// Need to check if offer is unlocked
|
|
668
|
+
const { min_num_of_orders, max_num_of_orders, total_amount, max_amount } = offer.pathway_to_unlock_type_orders;
|
|
669
|
+
if (totalOrders >= min_num_of_orders) {
|
|
670
|
+
// Either the max_num_of_orders is infinity, or the customer has not reached the max_num_of_orders
|
|
671
|
+
if ((max_num_of_orders == null || totalOrders <= max_num_of_orders) &&
|
|
672
|
+
(max_amount == null || orderValue <= max_amount)) {
|
|
673
|
+
if (orderValue >= total_amount) {
|
|
674
|
+
stats.progress = 100;
|
|
675
|
+
stats.claimable = false;
|
|
676
|
+
stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
677
|
+
stats.applicable_quantity = 1;
|
|
678
|
+
}
|
|
679
|
+
else {
|
|
680
|
+
// This means that the customer has not spent enough to unlock the offer
|
|
681
|
+
// But they have enough orders to unlock the offer
|
|
682
|
+
stats.progress = 90;
|
|
683
|
+
stats.message = `You are almost there. Spend ${currency_symbol}${(0, common_1.parseNum)(total_amount - orderValue)} more in this order to unlock this offer 🔓`;
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
else {
|
|
687
|
+
// This means that the customer has reached the max_num_of_orders
|
|
688
|
+
stats.progress = 0;
|
|
689
|
+
stats.message = `⛔️ You are not eligible for this offer ⛔️`;
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
else {
|
|
693
|
+
stats.progress = Math.round((totalOrders / (min_num_of_orders || 1)) * 100);
|
|
694
|
+
stats.message = `You are ${min_num_of_orders - totalOrders} orders away from unlocking this offer`;
|
|
695
|
+
}
|
|
696
|
+
if (stats.progress >= 100) {
|
|
697
|
+
if (offer.reward_type === constants_1.OFFER_REWARD_TYPE_ENUM.DISCOUNT) {
|
|
698
|
+
if (offer.reward_discount == null)
|
|
699
|
+
continue;
|
|
700
|
+
// Check if at least one item is eligible for the discount (not in excluded_refs)
|
|
701
|
+
const excluded_refs = offer.reward_discount.excluded_refs ?? [];
|
|
702
|
+
if (excluded_refs.length > 0 && !hasEligibleItemsForDiscount(categories, excluded_refs)) {
|
|
703
|
+
// All items are excluded, offer cannot be unlocked
|
|
704
|
+
stats.progress = 0;
|
|
705
|
+
stats.claimable = false;
|
|
706
|
+
stats.message = `⛔️ No eligible items for this offer ⛔️`;
|
|
707
|
+
offersWithStats.push({ offer, stats });
|
|
708
|
+
continue;
|
|
709
|
+
}
|
|
710
|
+
const claimable = order_discount_details == null ||
|
|
711
|
+
(order_discount_details.loyalty_discount_id != offer._id &&
|
|
712
|
+
order_discount_details.voucher_discount_id != offer._id);
|
|
713
|
+
stats.claimable = claimable;
|
|
714
|
+
stats.applicable_quantity = 1;
|
|
715
|
+
if (claimable) {
|
|
716
|
+
totalClaimableOffers += 1;
|
|
717
|
+
stats.redeemed_times = 0;
|
|
718
|
+
stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
719
|
+
}
|
|
720
|
+
else {
|
|
721
|
+
stats.message = 'This offer is redeemed ✅';
|
|
722
|
+
stats.redeemed_times = 1;
|
|
723
|
+
}
|
|
724
|
+
unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
|
|
725
|
+
}
|
|
726
|
+
else if (offer.reward_type === constants_1.OFFER_REWARD_TYPE_ENUM.DISCOUNT_ITEMS) {
|
|
727
|
+
// TODO:
|
|
728
|
+
// if (offer.reward_discount_items == null)
|
|
729
|
+
continue;
|
|
730
|
+
}
|
|
731
|
+
else if (offer.reward_type === constants_1.OFFER_REWARD_TYPE_ENUM.POINTS) {
|
|
732
|
+
// TODO:
|
|
733
|
+
// if (offer.reward_points == null)
|
|
734
|
+
continue;
|
|
735
|
+
}
|
|
736
|
+
else if (offer.reward_type === constants_1.OFFER_REWARD_TYPE_ENUM.VOUCHER) {
|
|
737
|
+
// TODO:
|
|
738
|
+
// if (offer.reward_voucher == null)
|
|
739
|
+
continue;
|
|
740
|
+
}
|
|
741
|
+
else if (offer.reward_type === constants_1.OFFER_REWARD_TYPE_ENUM.ITEMS) {
|
|
742
|
+
if (offer.reward_items == null)
|
|
743
|
+
continue;
|
|
744
|
+
const applicableQuantity = offer.reward_items.num_of_items || 1;
|
|
745
|
+
const totalOfferItemsSelected = (0, exports.getTotalSelectedOfferItemsAgainstOffer)(categories, offer._id);
|
|
746
|
+
const redeemedTimes = Math.floor(totalOfferItemsSelected / applicableQuantity);
|
|
747
|
+
const isClaimable = totalOfferItemsSelected < applicableQuantity;
|
|
748
|
+
stats.redeemed_times = redeemedTimes;
|
|
749
|
+
stats.applicable_quantity = applicableQuantity;
|
|
750
|
+
if (isClaimable) {
|
|
751
|
+
totalClaimableOffers += 1;
|
|
752
|
+
stats.claimable = true;
|
|
753
|
+
stats.message = `🎉 You have unlocked this offer 🎉`;
|
|
754
|
+
}
|
|
755
|
+
else {
|
|
756
|
+
stats.claimable = false;
|
|
757
|
+
stats.message = `This offer is redeemed ✅`;
|
|
758
|
+
}
|
|
759
|
+
unlockedOffersApplicableTimes[offer._id] = stats.applicable_quantity;
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
offersWithStats.push({
|
|
763
|
+
offer,
|
|
764
|
+
stats,
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
else if (offer.pathway_to_unlock_type === constants_1.PATHWAY_TO_UNLOCK_TYPE_ENUM.ITEMS) {
|
|
768
|
+
if (offer.pathway_to_unlock_type_items == null)
|
|
769
|
+
continue;
|
|
770
|
+
if (offer.reward_type === constants_1.OFFER_REWARD_TYPE_ENUM.DISCOUNT) {
|
|
771
|
+
// TODO:
|
|
772
|
+
// if (offer.reward_discount == null)
|
|
773
|
+
continue;
|
|
774
|
+
}
|
|
775
|
+
else if (offer.reward_type === constants_1.OFFER_REWARD_TYPE_ENUM.DISCOUNT_ITEMS) {
|
|
776
|
+
// TODO:
|
|
777
|
+
// if (offer.reward_discount_items == null)
|
|
778
|
+
continue;
|
|
779
|
+
}
|
|
780
|
+
else if (offer.reward_type === constants_1.OFFER_REWARD_TYPE_ENUM.POINTS) {
|
|
781
|
+
// TODO:
|
|
782
|
+
// if (offer.reward_points == null)
|
|
783
|
+
continue;
|
|
784
|
+
}
|
|
785
|
+
else if (offer.reward_type === constants_1.OFFER_REWARD_TYPE_ENUM.VOUCHER) {
|
|
786
|
+
// TODO:
|
|
787
|
+
// if (offer.reward_voucher == null) continue;
|
|
788
|
+
continue;
|
|
789
|
+
}
|
|
790
|
+
else if (offer.reward_type === constants_1.OFFER_REWARD_TYPE_ENUM.ITEMS) {
|
|
791
|
+
// TODO:
|
|
792
|
+
// if (offer.reward_items == null)
|
|
793
|
+
continue;
|
|
794
|
+
}
|
|
795
|
+
offersWithStats.push({
|
|
796
|
+
offer,
|
|
797
|
+
stats,
|
|
798
|
+
});
|
|
799
|
+
}
|
|
800
|
+
else if (offer.pathway_to_unlock_type === constants_1.PATHWAY_TO_UNLOCK_TYPE_ENUM.POINTS) {
|
|
801
|
+
if (offer.pathway_to_unlock_type_points == null)
|
|
802
|
+
continue;
|
|
803
|
+
if (offer.reward_type === constants_1.OFFER_REWARD_TYPE_ENUM.DISCOUNT) {
|
|
804
|
+
// TODO:
|
|
805
|
+
// if (offer.reward_discount == null)
|
|
806
|
+
continue;
|
|
807
|
+
}
|
|
808
|
+
else if (offer.reward_type === constants_1.OFFER_REWARD_TYPE_ENUM.DISCOUNT_ITEMS) {
|
|
809
|
+
// TODO:
|
|
810
|
+
// if (offer.reward_discount_items == null)
|
|
811
|
+
continue;
|
|
812
|
+
}
|
|
813
|
+
else if (offer.reward_type === constants_1.OFFER_REWARD_TYPE_ENUM.POINTS) {
|
|
814
|
+
// TODO:
|
|
815
|
+
// if (offer.reward_points == null)
|
|
816
|
+
continue;
|
|
817
|
+
}
|
|
818
|
+
else if (offer.reward_type === constants_1.OFFER_REWARD_TYPE_ENUM.VOUCHER) {
|
|
819
|
+
// TODO:
|
|
820
|
+
// if (offer.reward_voucher == null) continue;
|
|
821
|
+
continue;
|
|
822
|
+
}
|
|
823
|
+
else if (offer.reward_type === constants_1.OFFER_REWARD_TYPE_ENUM.ITEMS) {
|
|
824
|
+
// TODO:
|
|
825
|
+
// if (offer.reward_items == null)
|
|
826
|
+
continue;
|
|
827
|
+
}
|
|
828
|
+
offersWithStats.push({
|
|
829
|
+
offer,
|
|
830
|
+
stats,
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
else if (offer.pathway_to_unlock_type === constants_1.PATHWAY_TO_UNLOCK_TYPE_ENUM.VOUCHER) {
|
|
834
|
+
if (offer.reward_type === constants_1.OFFER_REWARD_TYPE_ENUM.DISCOUNT) {
|
|
835
|
+
// TODO:
|
|
836
|
+
// if (offer.reward_discount == null)
|
|
837
|
+
continue;
|
|
838
|
+
}
|
|
839
|
+
else if (offer.reward_type === constants_1.OFFER_REWARD_TYPE_ENUM.DISCOUNT_ITEMS) {
|
|
840
|
+
// TODO:
|
|
841
|
+
// if (offer.reward_discount_items == null)
|
|
842
|
+
continue;
|
|
843
|
+
}
|
|
844
|
+
else if (offer.reward_type === constants_1.OFFER_REWARD_TYPE_ENUM.POINTS) {
|
|
845
|
+
// TODO:
|
|
846
|
+
// if (offer.reward_points == null)
|
|
847
|
+
continue;
|
|
848
|
+
}
|
|
849
|
+
else if (offer.reward_type === constants_1.OFFER_REWARD_TYPE_ENUM.VOUCHER) {
|
|
850
|
+
// TODO:
|
|
851
|
+
// if (offer.reward_voucher == null)
|
|
852
|
+
continue;
|
|
853
|
+
continue;
|
|
854
|
+
}
|
|
855
|
+
else if (offer.reward_type === constants_1.OFFER_REWARD_TYPE_ENUM.ITEMS) {
|
|
856
|
+
// TODO:
|
|
857
|
+
// if (offer.reward_items == null)
|
|
858
|
+
continue;
|
|
859
|
+
}
|
|
860
|
+
offersWithStats.push({
|
|
861
|
+
offer,
|
|
862
|
+
stats,
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
return {
|
|
867
|
+
offersWithStats,
|
|
868
|
+
totalClaimableOffers,
|
|
869
|
+
unlockedOffersApplicableTimes,
|
|
870
|
+
};
|
|
871
|
+
}
|
|
872
|
+
const getAppliedOfferIds = (order_discount_details, categories) => {
|
|
873
|
+
const appliedOfferIds = new Set();
|
|
874
|
+
if (order_discount_details != null) {
|
|
875
|
+
if (order_discount_details.loyalty_discount_id) {
|
|
876
|
+
appliedOfferIds.add(order_discount_details.loyalty_discount_id);
|
|
877
|
+
}
|
|
878
|
+
if (order_discount_details.voucher_discount_id) {
|
|
879
|
+
appliedOfferIds.add(order_discount_details.voucher_discount_id);
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
const totalCategories = categories?.length ?? 0;
|
|
883
|
+
for (let i = 0; i < totalCategories; i++) {
|
|
884
|
+
const category = categories[i];
|
|
885
|
+
for (let j = 0; j < category.items.length; j++) {
|
|
886
|
+
const item = category.items[j];
|
|
887
|
+
if (item.item_discount_details != null) {
|
|
888
|
+
if (item.item_discount_details.loyalty_discount_id) {
|
|
889
|
+
appliedOfferIds.add(item.item_discount_details.loyalty_discount_id);
|
|
890
|
+
}
|
|
891
|
+
if (item.item_discount_details.voucher_discount_id) {
|
|
892
|
+
appliedOfferIds.add(item.item_discount_details.voucher_discount_id);
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
return Array.from(appliedOfferIds);
|
|
898
|
+
};
|
|
899
|
+
exports.getAppliedOfferIds = getAppliedOfferIds;
|