@infrab4a/connect-angular 4.14.4-beta.0 → 4.14.4-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.
@@ -1137,7 +1137,7 @@ class CouponService {
1137
1137
  let discount = 0;
1138
1138
  if (type == CouponTypes.SHIPPING) {
1139
1139
  const subTotal = checkout.shipping.ShippingPrice;
1140
- const discount = subTotal * ((value > 100 ? 100 : value) / 100);
1140
+ const discount = +(subTotal * ((value > 100 ? 100 : value) / 100)).toFixed(2);
1141
1141
  return { discount, lineItems: checkout.lineItems };
1142
1142
  }
1143
1143
  let lineItensElegibleForDiscount = await this.getLineItensEligebleForDiscount(categories, checkout);
@@ -1146,7 +1146,7 @@ class CouponService {
1146
1146
  discount = value > subTotal ? subTotal : value;
1147
1147
  }
1148
1148
  else {
1149
- discount = subTotal * ((value > 100 ? 100 : value) / 100);
1149
+ discount = +(subTotal * ((value > 100 ? 100 : value) / 100)).toFixed(2);
1150
1150
  }
1151
1151
  const lineItems = this.calcLineItenDiscount(type, lineItensElegibleForDiscount, value, subTotal);
1152
1152
  return { discount, lineItems };
@@ -1165,10 +1165,12 @@ class CouponService {
1165
1165
  return true;
1166
1166
  }
1167
1167
  const couponCategories = await this.getCouponCategoriesId(coupon.productsCategories);
1168
- const hasCategories = checkout.lineItems?.filter((i) => {
1169
- if (!i.categories || !i.categories?.length)
1168
+ const hasCategories = checkout.lineItems?.filter((item) => {
1169
+ if (item.isGift)
1170
+ return false;
1171
+ if (!item.categories || !item.categories?.length)
1170
1172
  return true;
1171
- return i.categories.some((c) => couponCategories.some((cat) => cat == c));
1173
+ return item.categories.some((c) => couponCategories.some((cat) => cat == c));
1172
1174
  });
1173
1175
  return hasCategories.length ? true : false;
1174
1176
  }
@@ -1211,20 +1213,24 @@ class CouponService {
1211
1213
  let lineItensDiscount = [];
1212
1214
  const couponCategories = await this.getCouponCategoriesId(productsCategories);
1213
1215
  if (productsCategories && productsCategories.length) {
1214
- lineItensDiscount = checkout.lineItems?.filter((i) => {
1215
- if (i.categories?.length) {
1216
- return i.categories.some((c) => couponCategories.some((cat) => cat == c));
1216
+ lineItensDiscount = checkout.lineItems?.filter((item) => {
1217
+ if (item.isGift)
1218
+ return false;
1219
+ if (item.categories?.length) {
1220
+ return item.categories.some((c) => couponCategories.some((cat) => cat == c));
1217
1221
  }
1218
1222
  return true;
1219
1223
  });
1220
1224
  }
1221
1225
  else {
1222
- lineItensDiscount = checkout.lineItems;
1226
+ lineItensDiscount = checkout.lineItems.filter((item) => !item.isGift);
1223
1227
  }
1224
1228
  return lineItensDiscount;
1225
1229
  }
1226
1230
  calcCheckoutSubtotal(lineItens, user) {
1227
- return (lineItens?.reduce((acc, curr) => user?.isSubscriber && curr.price.subscriberPrice
1231
+ return (lineItens
1232
+ ?.filter((item) => !item.isGift)
1233
+ .reduce((acc, curr) => user?.isSubscriber && curr.price.subscriberPrice
1228
1234
  ? acc + curr.price?.subscriberPrice * curr.quantity
1229
1235
  : acc + curr.pricePaid * curr.quantity, 0) || 0);
1230
1236
  }