@infrab4a/connect-angular 2.0.11 → 2.0.12

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.
@@ -852,7 +852,7 @@
852
852
  this.buildLineItem = function (_h) {
853
853
  var checkout = _h.checkout, item = _h.item, quantity = _h.quantity;
854
854
  return __awaiter(_this, void 0, void 0, function () {
855
- var _a, _b, _c, _d, _e, _f, _g, product, image, id, name, EAN, brand, slug, stock, price, weight, categories, sku, isGift, pricePaid;
855
+ var _a, _b, _c, _d, _e, _f, _g, product, image, id, name, EAN, brand, slug, stock, price, weight, categories, sku, type, isGift, pricePaid;
856
856
  return __generator(this, function (_h) {
857
857
  switch (_h.label) {
858
858
  case 0: return [4 /*yield*/, this.productRepository.get({ id: item.id })];
@@ -862,7 +862,7 @@
862
862
  if (this.checkMaxStock(item, quantity || 0))
863
863
  throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
864
864
  image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
865
- id = item.id, name = item.name, EAN = item.EAN, brand = item.brand, slug = item.slug, stock = item.stock, price = item.price, weight = item.weight, categories = item.categories, sku = item.sku;
865
+ id = item.id, name = item.name, EAN = item.EAN, brand = item.brand, slug = item.slug, stock = item.stock, price = item.price, weight = item.weight, categories = item.categories, sku = item.sku, type = item.type;
866
866
  isGift = item.isGift || null;
867
867
  pricePaid = this.getProductPrice({
868
868
  product: item,
@@ -887,6 +887,7 @@
887
887
  categories: (_f = product.categories) !== null && _f !== void 0 ? _f : [],
888
888
  isGift: isGift !== null && isGift !== void 0 ? isGift : null,
889
889
  costPrice: (_g = product.costPrice) !== null && _g !== void 0 ? _g : 0,
890
+ type: type,
890
891
  }),
891
892
  }];
892
893
  }
@@ -894,8 +895,8 @@
894
895
  });
895
896
  };
896
897
  this.getProductPrice = function (_h) {
897
- var product = _h.product, isSubscriber = _h.isSubscriber;
898
- var info = product.price;
898
+ var product = _h.product, shop = _h.shop, isSubscriber = _h.isSubscriber;
899
+ var info = product.getInfoByShop(shop);
899
900
  if (product.isGift)
900
901
  return 0;
901
902
  return isSubscriber && info.subscriberPrice > 0 ? info.subscriberPrice : info.price;
@@ -938,8 +939,8 @@
938
939
  /**
939
940
  * @deprecated The method should not be used
940
941
  */
941
- CartService.prototype.getVariantPriceDiscount = function (item) {
942
- return this.authService.getUser().pipe(operators.concatMap(function (user) { return rxjs.iif(function () { return user.isSubscriber && !!item.price.subscriberPrice; }, rxjs.of(item.price.subscriberPrice), rxjs.of(item.price.price)); }), operators.catchError(function () { return rxjs.of(item.price.price); }));
942
+ CartService.prototype.getVariantPriceDiscount = function (item, shop) {
943
+ return this.authService.getUser().pipe(operators.concatMap(function (user) { return rxjs.iif(function () { return user.isSubscriber && !!item.getInfoByShop(shop).subscriberPrice; }, rxjs.of(item.getInfoByShop(shop).subscriberPrice), rxjs.of(item.getInfoByShop(shop).price)); }), operators.catchError(function () { return rxjs.of(item.getInfoByShop(shop).price); }));
943
944
  };
944
945
  CartService.prototype.removeItem = function (item) {
945
946
  var _this = this;
@@ -992,6 +993,16 @@
992
993
  var _this = this;
993
994
  return this.checkoutService.getCheckout(checkoutData).pipe(operators.map(function (checkout) { return checkout.lineItems; }), operators.concatMap(function (lineItems) { return rxjs.of(_this.generateCartObject(lineItems)); }));
994
995
  };
996
+ CartService.prototype.getSubTotalDiscount = function (coupon) {
997
+ return function (subTotalPrice) {
998
+ switch (coupon.type) {
999
+ case i2.CouponTypes.ABSOLUTE:
1000
+ return subTotalPrice - coupon.discount;
1001
+ case i2.CouponTypes.PERCENTAGE:
1002
+ return subTotalPrice * (1 - coupon.discount / 100);
1003
+ }
1004
+ };
1005
+ };
995
1006
  return CartService;
996
1007
  }());
997
1008
  CartService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
@@ -1112,6 +1123,7 @@
1112
1123
  'name',
1113
1124
  'weight',
1114
1125
  'rate',
1126
+ 'type'
1115
1127
  ])); }),
1116
1128
  }); };
1117
1129
  }