ng-easycommerce 0.0.631 → 0.0.632

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.
package/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ # version 0.0.632
2
+ - mejorar la validación de cantidad y stock en el carrito
1
3
  # version 0.0.631
2
4
  - mejorar la lógica de actualización y formato de precios en el filtro
3
5
  # version 0.0.630
@@ -4108,6 +4108,14 @@
4108
4108
  this.getChannels();
4109
4109
  this.getLocales();
4110
4110
  }
4111
+ /**
4112
+ * @description Devuelve si se deben mostrar precios con impuestos durante la navegación.
4113
+ * @returns {boolean | null} true/false si está definido, null si aún no hay configuración
4114
+ */
4115
+ ChannelConfigService$1.prototype.getShowPricesWithTaxes = function () {
4116
+ var _a, _b;
4117
+ return _b = (_a = this.channel) === null || _a === void 0 ? void 0 : _a.showPriceWithTaxesWhileBrowsing, (_b !== null && _b !== void 0 ? _b : null);
4118
+ };
4111
4119
  ChannelConfigService$1.ctorParameters = function () { return [
4112
4120
  { type: Constants },
4113
4121
  { type: undefined, decorators: [{ type: core.Inject, args: ['env',] }] },
@@ -10830,11 +10838,18 @@
10830
10838
  return min_price == max_price ? max_price.toString() : min_price + ' - ' + max_price;
10831
10839
  };
10832
10840
  this.inRange = function (quantity, min, max) { return ((quantity - min) * (quantity - max) <= 0); };
10833
- this.validateQuantity = function (quantity) {
10834
- var actualQuantity = _this.cartService.getCountFromItemInCart(_this.variants[0].code);
10841
+ this.validateQuantity = function (quantity, variantCode) {
10842
+ var _a, _b;
10843
+ var codeToCheck = variantCode || _this.variants[0].code;
10844
+ var actualQuantity = _this.cartService.getCountFromItemInCart(codeToCheck);
10835
10845
  var asociatedData = _this.asociatedDataSubject.value;
10836
10846
  var totalQuantity = actualQuantity + quantity;
10837
- console.log('La cantidad que llegó: ', quantity, ' y la cantidad actual: ', actualQuantity);
10847
+ var variant = _this.variants.find(function (v) { return v.code === codeToCheck; });
10848
+ var stock = (_b = (_a = variant) === null || _a === void 0 ? void 0 : _a.stock, (_b !== null && _b !== void 0 ? _b : 0));
10849
+ if (totalQuantity > stock) {
10850
+ _this.toastrService.show('out-of-stock-actually');
10851
+ return false;
10852
+ }
10838
10853
  if (asociatedData.maximumItemsQuantity && totalQuantity > asociatedData.maximumItemsQuantity) {
10839
10854
  _this.toastrService.show('maximum-items-quantity', { quantity: asociatedData.maximumItemsQuantity });
10840
10855
  return false;
@@ -10927,7 +10942,7 @@
10927
10942
  }
10928
10943
  if (!variant)
10929
10944
  return;
10930
- if (!this.validateQuantity(quantity))
10945
+ if (!this.validateQuantity(quantity, variant.code))
10931
10946
  return;
10932
10947
  var priceToValidate = product_selected.saleprice ? product_selected.saleprice * quantity : product_selected.price * quantity;
10933
10948
  if (!this.validatePriceAndCredits(priceToValidate))