@managesome/eposmatic-toolkit 0.2.279 → 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: applyLoyalty != null && applyLoyalty.refs.includes(item._id),
445
- voucher_applied: applyVoucher != null && applyVoucher.refs.includes(item._id),
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;
@@ -8,12 +8,11 @@ export declare const OfferFingerprintSchema: Schema<any, import("mongoose").Mode
8
8
  updatedAt: NativeDate;
9
9
  } & {
10
10
  _id: import("mongoose").Types.ObjectId;
11
- tenants: string[];
11
+ tenant_id: string;
12
12
  order_id: import("mongoose").Types.ObjectId;
13
13
  createdAt_mins: number;
14
14
  createdAt: NativeDate;
15
15
  updatedAt: NativeDate;
16
- brand_id: string;
17
16
  customer_phone: string;
18
17
  customer_name: string;
19
18
  offer_id: import("mongoose").Types.ObjectId;
@@ -22,12 +21,11 @@ export declare const OfferFingerprintSchema: Schema<any, import("mongoose").Mode
22
21
  updatedAt: NativeDate;
23
22
  } & {
24
23
  _id: import("mongoose").Types.ObjectId;
25
- tenants: string[];
24
+ tenant_id: string;
26
25
  order_id: import("mongoose").Types.ObjectId;
27
26
  createdAt_mins: number;
28
27
  createdAt: NativeDate;
29
28
  updatedAt: NativeDate;
30
- brand_id: string;
31
29
  customer_phone: string;
32
30
  customer_name: string;
33
31
  offer_id: import("mongoose").Types.ObjectId;
@@ -36,12 +34,11 @@ export declare const OfferFingerprintSchema: Schema<any, import("mongoose").Mode
36
34
  updatedAt: NativeDate;
37
35
  } & {
38
36
  _id: import("mongoose").Types.ObjectId;
39
- tenants: string[];
37
+ tenant_id: string;
40
38
  order_id: import("mongoose").Types.ObjectId;
41
39
  createdAt_mins: number;
42
40
  createdAt: NativeDate;
43
41
  updatedAt: NativeDate;
44
- brand_id: string;
45
42
  customer_phone: string;
46
43
  customer_name: string;
47
44
  offer_id: import("mongoose").Types.ObjectId;
@@ -8,15 +8,11 @@ exports.OfferFingerprintSchema = new mongoose_1.Schema({
8
8
  required: true,
9
9
  immutable: true,
10
10
  },
11
- brand_id: {
11
+ tenant_id: {
12
12
  type: String,
13
13
  required: true,
14
14
  immutable: true,
15
- ref: 'brands',
16
- },
17
- tenants: {
18
- type: [String],
19
- required: true,
15
+ ref: 'tenants',
20
16
  },
21
17
  offer_id: {
22
18
  type: mongoose_1.Schema.Types.ObjectId,
@@ -1,7 +1,6 @@
1
1
  export interface IOfferFingerprint {
2
2
  _id: string;
3
- brand_id: string;
4
- tenants: string[];
3
+ tenant_id: string;
5
4
  offer_id: string;
6
5
  customer_phone: string;
7
6
  customer_name: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@managesome/eposmatic-toolkit",
3
- "version": "0.2.279",
3
+ "version": "0.2.281",
4
4
  "description": "A Toolkit Library for Eposmatic",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",