@managesome/eposmatic-toolkit 0.2.280 → 0.2.281
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.
|
@@ -6,6 +6,7 @@ function getCustomerWithPrice(customer, writeable) {
|
|
|
6
6
|
const convertToNum = writeable ? price_conversion_1.convertPriceToCents : price_conversion_1.convertPriceFromCents;
|
|
7
7
|
return {
|
|
8
8
|
...customer,
|
|
9
|
+
cashback_balance: customer.cashback_balance != null ? convertToNum(customer.cashback_balance) : 0,
|
|
9
10
|
total_spent: customer.total_spent != null ? convertToNum(customer.total_spent) : 0,
|
|
10
11
|
total_spent_per_platform_type: customer.total_spent_per_platform_type != null
|
|
11
12
|
? Object.keys(customer.total_spent_per_platform_type).reduce((acc, key) => {
|
|
@@ -424,6 +424,35 @@ function convertCatalogItemToOrderEngineItem({ item, orderItem, platform, tenant
|
|
|
424
424
|
const { _id = (0, bson_objectid_1.default)().toHexString(), menu_id = defaultMenuId,
|
|
425
425
|
// For New Item, If zeroPriceRefs is present then we set the price to 0
|
|
426
426
|
price = defaultItemPrice, tax_rate = (0, platform_catalog_1.getPriceEnum)(item.tax_rate, platform), quantity = 1, subtotal = 0, special_instructions = '', item_discount_details = convertItemDiscountToOrderItemDiscount(discount_amount, is_special_discount_percentage, platform, item._id), item_type = orderItemType, is_ready, is_split, } = orderItem ?? {};
|
|
427
|
+
const loyaltyApplied = applyLoyalty != null && applyLoyalty.refs.includes(item._id);
|
|
428
|
+
const voucherApplied = applyVoucher != null && applyVoucher.refs.includes(item._id);
|
|
429
|
+
let mergedItemDiscountDetails = item_discount_details;
|
|
430
|
+
if (loyaltyApplied && applyLoyalty != null) {
|
|
431
|
+
const loyaltyDiscountDetails = applyLoyalty.discount_details ?? {
|
|
432
|
+
discount_value: 100,
|
|
433
|
+
is_discount_percentage: true,
|
|
434
|
+
};
|
|
435
|
+
mergedItemDiscountDetails = {
|
|
436
|
+
...(mergedItemDiscountDetails ?? { total_discount: 0 }),
|
|
437
|
+
loyalty_discount_id: applyLoyalty.loyalty_id,
|
|
438
|
+
loyalty_discount_name: applyLoyalty.name,
|
|
439
|
+
loyalty_discount: loyaltyDiscountDetails.discount_value,
|
|
440
|
+
is_loyalty_discount_percentage: loyaltyDiscountDetails.is_discount_percentage,
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
if (voucherApplied && applyVoucher != null) {
|
|
444
|
+
const voucherDiscountDetails = applyVoucher.discount_details ?? {
|
|
445
|
+
discount_value: 100,
|
|
446
|
+
is_discount_percentage: true,
|
|
447
|
+
};
|
|
448
|
+
mergedItemDiscountDetails = {
|
|
449
|
+
...(mergedItemDiscountDetails ?? { total_discount: 0 }),
|
|
450
|
+
voucher_discount_id: applyVoucher.voucher_id,
|
|
451
|
+
voucher_discount_name: applyVoucher.name,
|
|
452
|
+
voucher_discount: voucherDiscountDetails.discount_value,
|
|
453
|
+
is_voucher_discount_percentage: voucherDiscountDetails.is_discount_percentage,
|
|
454
|
+
};
|
|
455
|
+
}
|
|
427
456
|
const orderEngineItem = syncOrderEngineItem({
|
|
428
457
|
_id,
|
|
429
458
|
category_id: item.category_id,
|
|
@@ -441,10 +470,10 @@ function convertCatalogItemToOrderEngineItem({ item, orderItem, platform, tenant
|
|
|
441
470
|
quantity,
|
|
442
471
|
subtotal,
|
|
443
472
|
gross_total: 0,
|
|
444
|
-
loyalty_applied:
|
|
445
|
-
voucher_applied:
|
|
473
|
+
loyalty_applied: loyaltyApplied,
|
|
474
|
+
voucher_applied: voucherApplied,
|
|
446
475
|
special_instructions,
|
|
447
|
-
item_discount_details,
|
|
476
|
+
item_discount_details: mergedItemDiscountDetails,
|
|
448
477
|
modifiers: orderEngineModifiers,
|
|
449
478
|
});
|
|
450
479
|
return orderEngineItem;
|