@infrab4a/connect-angular 4.4.2-beta.2 → 4.4.3-beta.0

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.
@@ -1062,29 +1062,28 @@ class CouponService {
1062
1062
  }
1063
1063
  calcDiscountShopping(coupon, checkout) {
1064
1064
  return __awaiter(this, void 0, void 0, function* () {
1065
- let discountInfo = null;
1065
+ let discount = 0;
1066
1066
  if (checkout.user.isSubscriber && coupon.discount.subscriber.value) {
1067
- discountInfo = yield this.calcDiscountByType(coupon.discount.subscriber.type, coupon.discount.subscriber.value, coupon.productsCategories, checkout);
1067
+ discount = yield this.calcDiscountByType(coupon.discount.subscriber.type, coupon.discount.subscriber.value, coupon.productsCategories, checkout);
1068
1068
  }
1069
1069
  else {
1070
- discountInfo = yield this.calcDiscountByType(coupon.discount.non_subscriber.type, coupon.discount.non_subscriber.value, coupon.productsCategories, checkout);
1070
+ discount = yield this.calcDiscountByType(coupon.discount.non_subscriber.type, coupon.discount.non_subscriber.value, coupon.productsCategories, checkout);
1071
1071
  }
1072
- return { discount: discountInfo.discount, lineItems: discountInfo.lineItems };
1072
+ return discount;
1073
1073
  });
1074
1074
  }
1075
1075
  calcDiscountByType(type, value, categories, checkout) {
1076
1076
  return __awaiter(this, void 0, void 0, function* () {
1077
1077
  let discount = 0;
1078
- let lineItensElegibleForDiscount = yield this.getLineItensEligebleForDiscount(categories, checkout);
1079
- const subTotal = this.calcCheckoutSubtotal(lineItensElegibleForDiscount, checkout.user);
1078
+ let lineItensDiscount = yield this.getLineItensEligebleForDiscount(categories, checkout);
1079
+ const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user, checkout.shop);
1080
1080
  if (type == CouponTypes.ABSOLUTE) {
1081
1081
  discount = value > subTotal ? subTotal : value;
1082
1082
  }
1083
1083
  else {
1084
1084
  discount = subTotal * (value / 100);
1085
1085
  }
1086
- const lineItems = this.calcLineItenDiscount(type, lineItensElegibleForDiscount, value, subTotal);
1087
- return { discount, lineItems };
1086
+ return discount;
1088
1087
  });
1089
1088
  }
1090
1089
  hasMinSubTotal(coupon, checkout) {
@@ -1092,7 +1091,7 @@ class CouponService {
1092
1091
  if (!coupon.minSubTotalValue)
1093
1092
  return true;
1094
1093
  let lineItensDiscount = yield this.getLineItensEligebleForDiscount(coupon.productsCategories, checkout);
1095
- const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user);
1094
+ const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user, checkout.shop);
1096
1095
  if (coupon.minSubTotalValue <= subTotal)
1097
1096
  return true;
1098
1097
  return false;
@@ -1171,7 +1170,7 @@ class CouponService {
1171
1170
  return lineItensDiscount;
1172
1171
  });
1173
1172
  }
1174
- calcCheckoutSubtotal(lineItens, user) {
1173
+ calcCheckoutSubtotal(lineItens, user, shop) {
1175
1174
  return ((lineItens === null || lineItens === void 0 ? void 0 : lineItens.reduce((acc, curr) => {
1176
1175
  var _a;
1177
1176
  return (user === null || user === void 0 ? void 0 : user.isSubscriber) && curr.price.subscriberPrice
@@ -1216,26 +1215,6 @@ class CouponService {
1216
1215
  }
1217
1216
  return couponUseLimits;
1218
1217
  }
1219
- calcLineItenDiscount(type, lineItems, couponDiscount, subTotal) {
1220
- let lineItemsDiscount = [];
1221
- if (type === CouponTypes.ABSOLUTE) {
1222
- const couponDiscountMax = couponDiscount > subTotal ? subTotal : couponDiscount;
1223
- lineItemsDiscount = lineItems.map((item) => {
1224
- const totalItemPercentage = item.pricePaid / subTotal;
1225
- const discountItem = couponDiscountMax * totalItemPercentage;
1226
- console.log(item.name, item.pricePaid, subTotal, 'absolute', couponDiscountMax, totalItemPercentage, discountItem);
1227
- return Object.assign(Object.assign({}, item), { discount: Number(discountItem.toFixed(2)) });
1228
- });
1229
- }
1230
- else {
1231
- lineItemsDiscount = lineItems.map((item) => {
1232
- const discountItem = item.pricePaid * (couponDiscount / 100);
1233
- console.log(item.name, item.pricePaid, 'percentage', couponDiscount, discountItem);
1234
- return Object.assign(Object.assign({}, item), { discount: Number(discountItem.toFixed(2)) });
1235
- });
1236
- }
1237
- return lineItemsDiscount;
1238
- }
1239
1218
  }
1240
1219
  CouponService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, deps: [{ token: 'CouponRepository' }, { token: DEFAULT_SHOP }, { token: 'OrderRepository' }, { token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1241
1220
  CouponService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, providedIn: 'root' });
@@ -1377,7 +1356,6 @@ class CartService {
1377
1356
  weight: weight !== null && weight !== void 0 ? weight : product.weight,
1378
1357
  quantity: (item.quantity || 0) + (quantity || 0),
1379
1358
  pricePaid,
1380
- discount: 0,
1381
1359
  categories: (_f = product.categories) !== null && _f !== void 0 ? _f : [],
1382
1360
  isGift: isGift !== null && isGift !== void 0 ? isGift : null,
1383
1361
  costPrice: (_g = product.costPrice) !== null && _g !== void 0 ? _g : 0,
@@ -1935,7 +1913,7 @@ class WishlistService {
1935
1913
  getCategoryService() {
1936
1914
  return this.categoryService;
1937
1915
  }
1938
- create({ personId, title, description, userFullName, userPhoto, theme, bannerUrl, }) {
1916
+ create({ personId, title, description, published, userFullName, userPhoto, theme, bannerUrl, }) {
1939
1917
  return __awaiter(this, void 0, void 0, function* () {
1940
1918
  const data = {
1941
1919
  slug: '',
@@ -1951,7 +1929,7 @@ class WishlistService {
1951
1929
  personName: userFullName,
1952
1930
  personPhoto: userPhoto,
1953
1931
  brandCategory: false,
1954
- published: true,
1932
+ published,
1955
1933
  theme,
1956
1934
  bannerUrl,
1957
1935
  };
@@ -1960,11 +1938,12 @@ class WishlistService {
1960
1938
  return Wishlist.toInstance(Object.assign(Object.assign({}, newWishlist.toPlain()), { slug: newWishlist.id }));
1961
1939
  });
1962
1940
  }
1963
- update({ id, title, description, userFullName, userPhoto, theme, bannerUrl, }) {
1941
+ update({ id, title, description, published, userFullName, userPhoto, theme, bannerUrl, }) {
1964
1942
  const data = {
1965
1943
  id,
1966
1944
  name: title,
1967
1945
  description,
1946
+ published,
1968
1947
  metadata: {
1969
1948
  title: `${userFullName} - ${title}`,
1970
1949
  description: `${userFullName} - ${description}`,