ng-easycommerce 0.0.637 → 0.0.639

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.
@@ -7,7 +7,7 @@ import { InfiniteScrollModule } from 'ngx-infinite-scroll';
7
7
  import { ToastrService, ToastrModule } from 'ngx-toastr';
8
8
  import { ReplaySubject, of, BehaviorSubject, forkJoin, combineLatest, Observable, throwError } from 'rxjs';
9
9
  import 'rxjs/add/operator/map';
10
- import { take, map, catchError, filter, mapTo, skipWhile, concatMap } from 'rxjs/operators';
10
+ import { take, map, catchError, filter, mapTo, finalize, skipWhile, concatMap } from 'rxjs/operators';
11
11
  import 'rxjs/add/operator/catch';
12
12
  import 'rxjs/add/observable/of';
13
13
  import * as moment from 'moment';
@@ -4828,6 +4828,9 @@ var CartService = /** @class */ (function () {
4828
4828
  */
4829
4829
  this.addToCart = function (product, quantity, variant_id, comments) {
4830
4830
  var _a, _b, _c, _d;
4831
+ if (_this.requestInProcess.getValue()) {
4832
+ return;
4833
+ }
4831
4834
  var balance = _this.balanceCustomerSubject.value;
4832
4835
  var applyMaxOrders = (_b = (_a = balance) === null || _a === void 0 ? void 0 : _a.applyMaxOrders, (_b !== null && _b !== void 0 ? _b : false));
4833
4836
  var maxOrders = (_d = (_c = balance) === null || _c === void 0 ? void 0 : _c.maxOrders, (_d !== null && _d !== void 0 ? _d : Infinity));
@@ -4851,6 +4854,7 @@ var CartService = /** @class */ (function () {
4851
4854
  payload.comments = comments;
4852
4855
  }
4853
4856
  _this.connection.post(_this.addItemApi(), payload)
4857
+ .pipe(finalize(function () { return _this.requestInProcess.next(false); }))
4854
4858
  .subscribe(function (res) {
4855
4859
  // Manejar la respuesta HTTP exitosa (código 200)
4856
4860
  _this.appendToCart(res);
@@ -10802,16 +10806,18 @@ var ProductDetailService = /** @class */ (function () {
10802
10806
  options && options.forEach(function (option) { return Object.keys(option).forEach(function (key) { return _this.setOption(key, option[key]); }); });
10803
10807
  };
10804
10808
  this.generateAsociatedDataFromVariants = function () {
10805
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
10809
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
10806
10810
  var asociated = {};
10807
10811
  if (_this.isReady()) {
10808
10812
  asociated.stock = _this.variants[0].stock;
10809
- asociated.price = _this.variants[0].price.toString();
10813
+ // Precio: si viene taxLegendInfo usamos su price, si no el v.price
10814
+ var rawPrice = (_b = (_a = _this.variants[0].taxLegendInfo) === null || _a === void 0 ? void 0 : _a.price, (_b !== null && _b !== void 0 ? _b : _this.variants[0].price));
10815
+ asociated.price = rawPrice.toString();
10810
10816
  asociated.saleprice = _this.variants[0].saleprice && _this.variants[0].saleprice.toString() || undefined;
10811
- asociated.discount = ((_a = _this.variants[0]) === null || _a === void 0 ? void 0 : _a.discount) || undefined;
10817
+ asociated.discount = ((_c = _this.variants[0]) === null || _c === void 0 ? void 0 : _c.discount) || undefined;
10812
10818
  asociated.properties = _this.variants[0].properties ? _this.beautifyProperties(_this.variants[0].properties) : undefined;
10813
- asociated.uniqueExternalCode = ((_b = _this.variants[0]) === null || _b === void 0 ? void 0 : _b.uniqueExternalCode) || undefined;
10814
- asociated.multipleQuantity = ((_c = _this.variants[0]) === null || _c === void 0 ? void 0 : _c.multipleQuantity) || undefined;
10819
+ asociated.uniqueExternalCode = ((_d = _this.variants[0]) === null || _d === void 0 ? void 0 : _d.uniqueExternalCode) || undefined;
10820
+ asociated.multipleQuantity = ((_e = _this.variants[0]) === null || _e === void 0 ? void 0 : _e.multipleQuantity) || undefined;
10815
10821
  }
10816
10822
  else {
10817
10823
  asociated.price = _this.cratePrice();
@@ -10822,22 +10828,32 @@ var ProductDetailService = /** @class */ (function () {
10822
10828
  ('images' in _this.variants[0] && _this.variants[0].images.length > 0)
10823
10829
  ? asociated.picture = _this.variants[0].images[0]
10824
10830
  : asociated.picture = (_this.asociatedDataSubject.value.picture || _this.productSubject.value.picturesdefault[0]);
10825
- asociated.maximumAmount = ((_d = _this.variants[0]) === null || _d === void 0 ? void 0 : _d.maximumAmount) || 0;
10826
- asociated.minimumAmount = ((_e = _this.variants[0]) === null || _e === void 0 ? void 0 : _e.minimumAmount) || 0;
10827
- asociated.maximumItemsQuantity = ((_f = _this.variants[0]) === null || _f === void 0 ? void 0 : _f.stock) > 0 && 'maximumItemsQuantity' in _this.variants[0] ? (_g = _this.variants[0]) === null || _g === void 0 ? void 0 : _g.maximumItemsQuantity : (_h = _this.variants[0]) === null || _h === void 0 ? void 0 : _h.stock;
10828
- asociated.minimumItemsQuantity = ((_j = _this.variants[0]) === null || _j === void 0 ? void 0 : _j.stock) > 0 && 'minimumItemsQuantity' in _this.variants[0]
10829
- && ((_k = _this.variants[0]) === null || _k === void 0 ? void 0 : _k.minimumItemsQuantity) > 0 ? (_l = _this.variants[0]) === null || _l === void 0 ? void 0 : _l.minimumItemsQuantity : (((_m = _this.variants[0]) === null || _m === void 0 ? void 0 : _m.multipleQuantity) ? (_o = _this.variants[0]) === null || _o === void 0 ? void 0 : _o.multipleQuantity : 1);
10831
+ asociated.maximumAmount = ((_f = _this.variants[0]) === null || _f === void 0 ? void 0 : _f.maximumAmount) || 0;
10832
+ asociated.minimumAmount = ((_g = _this.variants[0]) === null || _g === void 0 ? void 0 : _g.minimumAmount) || 0;
10833
+ asociated.maximumItemsQuantity = ((_h = _this.variants[0]) === null || _h === void 0 ? void 0 : _h.stock) > 0 && 'maximumItemsQuantity' in _this.variants[0] ? (_j = _this.variants[0]) === null || _j === void 0 ? void 0 : _j.maximumItemsQuantity : (_k = _this.variants[0]) === null || _k === void 0 ? void 0 : _k.stock;
10834
+ asociated.minimumItemsQuantity = ((_l = _this.variants[0]) === null || _l === void 0 ? void 0 : _l.stock) > 0 && 'minimumItemsQuantity' in _this.variants[0]
10835
+ && ((_m = _this.variants[0]) === null || _m === void 0 ? void 0 : _m.minimumItemsQuantity) > 0 ? (_o = _this.variants[0]) === null || _o === void 0 ? void 0 : _o.minimumItemsQuantity : (((_p = _this.variants[0]) === null || _p === void 0 ? void 0 : _p.multipleQuantity) ? (_q = _this.variants[0]) === null || _q === void 0 ? void 0 : _q.multipleQuantity : 1);
10830
10836
  asociated.finalConsumer = {
10831
- finalConsumerPrice: (_p = _this.variants[0]) === null || _p === void 0 ? void 0 : _p.final_consumer_price,
10832
- originalFinalConsumerPrice: (_q = _this.variants[0]) === null || _q === void 0 ? void 0 : _q.original_final_consumer_price,
10837
+ finalConsumerPrice: (_r = _this.variants[0]) === null || _r === void 0 ? void 0 : _r.final_consumer_price,
10838
+ originalFinalConsumerPrice: (_s = _this.variants[0]) === null || _s === void 0 ? void 0 : _s.original_final_consumer_price,
10833
10839
  };
10834
10840
  asociated.taxes = {
10835
- taxIncluded: (_r = _this.variants[0]) === null || _r === void 0 ? void 0 : _r.taxIncluded,
10836
- taxCategory: (_s = _this.variants[0]) === null || _s === void 0 ? void 0 : _s.taxCategory,
10841
+ taxIncluded: (_t = _this.variants[0]) === null || _t === void 0 ? void 0 : _t.taxIncluded,
10842
+ taxCategory: (_u = _this.variants[0]) === null || _u === void 0 ? void 0 : _u.taxCategory,
10837
10843
  };
10838
- asociated.taxeAmount = ((_t = _this.variants[0]) === null || _t === void 0 ? void 0 : _t.taxes) || undefined;
10839
- asociated.taxRate = ((_u = _this.variants[0]) === null || _u === void 0 ? void 0 : _u.taxRate) || undefined;
10840
- asociated.priceWithoutTaxes = ((_v = _this.variants[0]) === null || _v === void 0 ? void 0 : _v.priceWithoutTaxes) || undefined;
10844
+ // Segun version del backend
10845
+ if ((_v = _this.variants[0]) === null || _v === void 0 ? void 0 : _v.taxLegendInfo) {
10846
+ // Nuevo backend
10847
+ asociated.priceWithoutTaxes = (_w = _this.variants[0]) === null || _w === void 0 ? void 0 : _w.taxLegendInfo.priceWithoutTaxes;
10848
+ asociated.taxeAmount = (_x = _this.variants[0]) === null || _x === void 0 ? void 0 : _x.taxLegendInfo.taxes;
10849
+ asociated.taxRate = (_y = _this.variants[0]) === null || _y === void 0 ? void 0 : _y.taxLegendInfo.taxRate;
10850
+ }
10851
+ else {
10852
+ // Backend antiguo
10853
+ asociated.priceWithoutTaxes = (_0 = (_z = _this.variants[0]) === null || _z === void 0 ? void 0 : _z.priceWithoutTaxes, (_0 !== null && _0 !== void 0 ? _0 : undefined));
10854
+ asociated.taxeAmount = (_2 = (_1 = _this.variants[0]) === null || _1 === void 0 ? void 0 : _1.taxes, (_2 !== null && _2 !== void 0 ? _2 : undefined));
10855
+ asociated.taxRate = (_4 = (_3 = _this.variants[0]) === null || _3 === void 0 ? void 0 : _3.taxRate, (_4 !== null && _4 !== void 0 ? _4 : undefined));
10856
+ }
10841
10857
  _this.asociatedDataSubject.next(asociated);
10842
10858
  };
10843
10859
  /**