@infrab4a/connect-angular 4.4.1-beta.4 → 4.4.2-beta.1

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.
@@ -1066,21 +1066,21 @@ class CouponService {
1066
1066
  async calcDiscountByType(type, value, categories, checkout) {
1067
1067
  let discount = 0;
1068
1068
  let lineItensElegibleForDiscount = await this.getLineItensEligebleForDiscount(categories, checkout);
1069
- const subTotal = this.calcCheckoutSubtotal(lineItensElegibleForDiscount, checkout.user, checkout.shop);
1069
+ const subTotal = this.calcCheckoutSubtotal(lineItensElegibleForDiscount, checkout.user);
1070
1070
  if (type == CouponTypes.ABSOLUTE) {
1071
1071
  discount = value > subTotal ? subTotal : value;
1072
1072
  }
1073
1073
  else {
1074
1074
  discount = subTotal * (value / 100);
1075
1075
  }
1076
- const lineItems = this.calcLineItenDiscount(type, lineItensElegibleForDiscount, value, checkout.subTotalPrice);
1076
+ const lineItems = this.calcLineItenDiscount(type, lineItensElegibleForDiscount, value, subTotal);
1077
1077
  return { discount, lineItems };
1078
1078
  }
1079
1079
  async hasMinSubTotal(coupon, checkout) {
1080
1080
  if (!coupon.minSubTotalValue)
1081
1081
  return true;
1082
1082
  let lineItensDiscount = await this.getLineItensEligebleForDiscount(coupon.productsCategories, checkout);
1083
- const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user, checkout.shop);
1083
+ const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user);
1084
1084
  if (coupon.minSubTotalValue <= subTotal)
1085
1085
  return true;
1086
1086
  return false;
@@ -1148,7 +1148,7 @@ class CouponService {
1148
1148
  }
1149
1149
  return lineItensDiscount;
1150
1150
  }
1151
- calcCheckoutSubtotal(lineItens, user, shop) {
1151
+ calcCheckoutSubtotal(lineItens, user) {
1152
1152
  return (lineItens?.reduce((acc, curr) => user?.isSubscriber && curr.price.subscriberPrice
1153
1153
  ? acc + curr.price?.subscriberPrice * curr.quantity
1154
1154
  : acc + curr.pricePaid * curr.quantity, 0) || 0);
@@ -1195,7 +1195,7 @@ class CouponService {
1195
1195
  console.log(item.name, item.pricePaid, subTotal, 'absolute', couponDiscount, totalItemPercentage, discountItem);
1196
1196
  return {
1197
1197
  ...item,
1198
- discount: discountItem,
1198
+ discount: Number(discountItem.toFixed(2)),
1199
1199
  };
1200
1200
  });
1201
1201
  }
@@ -1205,7 +1205,7 @@ class CouponService {
1205
1205
  console.log(item.name, item.pricePaid, 'percentage', couponDiscount, discountItem);
1206
1206
  return {
1207
1207
  ...item,
1208
- discount: discountItem,
1208
+ discount: Number(discountItem.toFixed(2)),
1209
1209
  };
1210
1210
  });
1211
1211
  }