ng-easycommerce 0.0.638 → 0.0.640

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.
@@ -9128,7 +9128,7 @@ var SuccessEcComponent = /** @class */ (function (_super) {
9128
9128
  SuccessEcComponent.prototype.ngOnInit = function () {
9129
9129
  var _this = this;
9130
9130
  this.checkoutService.order$.subscribe(function (res) {
9131
- var _a, _b, _c, _d, _e, _f, _g, _h;
9131
+ var _a, _b, _c, _d, _e;
9132
9132
  //console.log('LO QUE LLEGA EN ORDEN', res);
9133
9133
  ((_a = res) === null || _a === void 0 ? void 0 : _a.number) ? _this.params = {
9134
9134
  external_reference: res.number,
@@ -9136,7 +9136,11 @@ var SuccessEcComponent = /** @class */ (function (_super) {
9136
9136
  //this.payments = [{method:{code:'bank_transsfer'}}]
9137
9137
  _this.payments = ((_b = res) === null || _b === void 0 ? void 0 : _b.payments) ? res.payments : null;
9138
9138
  if (((_e = (_d = (_c = _this.payments) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.method) === null || _e === void 0 ? void 0 : _e.code) && _this.isPlaceToPay(_this.payments[0].method.code)) {
9139
- _this.totalAmount = (_h = (_g = (_f = res) === null || _f === void 0 ? void 0 : _f.totals) === null || _g === void 0 ? void 0 : _g.total, (_h !== null && _h !== void 0 ? _h : null));
9139
+ var stored = localStorage.getItem('total_amount');
9140
+ if (stored !== null) {
9141
+ _this.totalAmount = parseFloat(stored);
9142
+ localStorage.removeItem('total_amount');
9143
+ }
9140
9144
  var now = new Date();
9141
9145
  _this.paymentDate = now.toLocaleDateString('es-AR', {
9142
9146
  day: '2-digit',
@@ -10806,16 +10810,19 @@ var ProductDetailService = /** @class */ (function () {
10806
10810
  options && options.forEach(function (option) { return Object.keys(option).forEach(function (key) { return _this.setOption(key, option[key]); }); });
10807
10811
  };
10808
10812
  this.generateAsociatedDataFromVariants = function () {
10809
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
10813
+ 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, _5, _6;
10810
10814
  var asociated = {};
10811
10815
  if (_this.isReady()) {
10812
10816
  asociated.stock = _this.variants[0].stock;
10813
- asociated.price = _this.variants[0].price.toString();
10814
- asociated.saleprice = _this.variants[0].saleprice && _this.variants[0].saleprice.toString() || undefined;
10815
- asociated.discount = ((_a = _this.variants[0]) === null || _a === void 0 ? void 0 : _a.discount) || undefined;
10817
+ // Precio: si viene taxLegendInfo usamos su price, si no el v.price
10818
+ 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));
10819
+ asociated.price = rawPrice.toString();
10820
+ var rawSalePrice = (_d = (_c = _this.variants[0].taxLegendInfo) === null || _c === void 0 ? void 0 : _c.saleprice, (_d !== null && _d !== void 0 ? _d : _this.variants[0].saleprice));
10821
+ asociated.saleprice = rawSalePrice ? rawSalePrice.toString() : undefined;
10822
+ asociated.discount = ((_e = _this.variants[0]) === null || _e === void 0 ? void 0 : _e.discount) || undefined;
10816
10823
  asociated.properties = _this.variants[0].properties ? _this.beautifyProperties(_this.variants[0].properties) : undefined;
10817
- asociated.uniqueExternalCode = ((_b = _this.variants[0]) === null || _b === void 0 ? void 0 : _b.uniqueExternalCode) || undefined;
10818
- asociated.multipleQuantity = ((_c = _this.variants[0]) === null || _c === void 0 ? void 0 : _c.multipleQuantity) || undefined;
10824
+ asociated.uniqueExternalCode = ((_f = _this.variants[0]) === null || _f === void 0 ? void 0 : _f.uniqueExternalCode) || undefined;
10825
+ asociated.multipleQuantity = ((_g = _this.variants[0]) === null || _g === void 0 ? void 0 : _g.multipleQuantity) || undefined;
10819
10826
  }
10820
10827
  else {
10821
10828
  asociated.price = _this.cratePrice();
@@ -10826,22 +10833,32 @@ var ProductDetailService = /** @class */ (function () {
10826
10833
  ('images' in _this.variants[0] && _this.variants[0].images.length > 0)
10827
10834
  ? asociated.picture = _this.variants[0].images[0]
10828
10835
  : asociated.picture = (_this.asociatedDataSubject.value.picture || _this.productSubject.value.picturesdefault[0]);
10829
- asociated.maximumAmount = ((_d = _this.variants[0]) === null || _d === void 0 ? void 0 : _d.maximumAmount) || 0;
10830
- asociated.minimumAmount = ((_e = _this.variants[0]) === null || _e === void 0 ? void 0 : _e.minimumAmount) || 0;
10831
- 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;
10832
- asociated.minimumItemsQuantity = ((_j = _this.variants[0]) === null || _j === void 0 ? void 0 : _j.stock) > 0 && 'minimumItemsQuantity' in _this.variants[0]
10833
- && ((_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);
10836
+ asociated.maximumAmount = ((_h = _this.variants[0]) === null || _h === void 0 ? void 0 : _h.maximumAmount) || 0;
10837
+ asociated.minimumAmount = ((_j = _this.variants[0]) === null || _j === void 0 ? void 0 : _j.minimumAmount) || 0;
10838
+ asociated.maximumItemsQuantity = ((_k = _this.variants[0]) === null || _k === void 0 ? void 0 : _k.stock) > 0 && 'maximumItemsQuantity' in _this.variants[0] ? (_l = _this.variants[0]) === null || _l === void 0 ? void 0 : _l.maximumItemsQuantity : (_m = _this.variants[0]) === null || _m === void 0 ? void 0 : _m.stock;
10839
+ asociated.minimumItemsQuantity = ((_o = _this.variants[0]) === null || _o === void 0 ? void 0 : _o.stock) > 0 && 'minimumItemsQuantity' in _this.variants[0]
10840
+ && ((_p = _this.variants[0]) === null || _p === void 0 ? void 0 : _p.minimumItemsQuantity) > 0 ? (_q = _this.variants[0]) === null || _q === void 0 ? void 0 : _q.minimumItemsQuantity : (((_r = _this.variants[0]) === null || _r === void 0 ? void 0 : _r.multipleQuantity) ? (_s = _this.variants[0]) === null || _s === void 0 ? void 0 : _s.multipleQuantity : 1);
10834
10841
  asociated.finalConsumer = {
10835
- finalConsumerPrice: (_p = _this.variants[0]) === null || _p === void 0 ? void 0 : _p.final_consumer_price,
10836
- originalFinalConsumerPrice: (_q = _this.variants[0]) === null || _q === void 0 ? void 0 : _q.original_final_consumer_price,
10842
+ finalConsumerPrice: (_t = _this.variants[0]) === null || _t === void 0 ? void 0 : _t.final_consumer_price,
10843
+ originalFinalConsumerPrice: (_u = _this.variants[0]) === null || _u === void 0 ? void 0 : _u.original_final_consumer_price,
10837
10844
  };
10838
10845
  asociated.taxes = {
10839
- taxIncluded: (_r = _this.variants[0]) === null || _r === void 0 ? void 0 : _r.taxIncluded,
10840
- taxCategory: (_s = _this.variants[0]) === null || _s === void 0 ? void 0 : _s.taxCategory,
10846
+ taxIncluded: (_v = _this.variants[0]) === null || _v === void 0 ? void 0 : _v.taxIncluded,
10847
+ taxCategory: (_w = _this.variants[0]) === null || _w === void 0 ? void 0 : _w.taxCategory,
10841
10848
  };
10842
- asociated.taxeAmount = ((_t = _this.variants[0]) === null || _t === void 0 ? void 0 : _t.taxes) || undefined;
10843
- asociated.taxRate = ((_u = _this.variants[0]) === null || _u === void 0 ? void 0 : _u.taxRate) || undefined;
10844
- asociated.priceWithoutTaxes = ((_v = _this.variants[0]) === null || _v === void 0 ? void 0 : _v.priceWithoutTaxes) || undefined;
10849
+ // Segun version del backend
10850
+ if ((_x = _this.variants[0]) === null || _x === void 0 ? void 0 : _x.taxLegendInfo) {
10851
+ // Nuevo backend
10852
+ asociated.priceWithoutTaxes = (_y = _this.variants[0]) === null || _y === void 0 ? void 0 : _y.taxLegendInfo.priceWithoutTaxes;
10853
+ asociated.taxeAmount = (_z = _this.variants[0]) === null || _z === void 0 ? void 0 : _z.taxLegendInfo.taxes;
10854
+ asociated.taxRate = (_0 = _this.variants[0]) === null || _0 === void 0 ? void 0 : _0.taxLegendInfo.taxRate;
10855
+ }
10856
+ else {
10857
+ // Backend antiguo
10858
+ asociated.priceWithoutTaxes = (_2 = (_1 = _this.variants[0]) === null || _1 === void 0 ? void 0 : _1.priceWithoutTaxes, (_2 !== null && _2 !== void 0 ? _2 : undefined));
10859
+ asociated.taxeAmount = (_4 = (_3 = _this.variants[0]) === null || _3 === void 0 ? void 0 : _3.taxes, (_4 !== null && _4 !== void 0 ? _4 : undefined));
10860
+ asociated.taxRate = (_6 = (_5 = _this.variants[0]) === null || _5 === void 0 ? void 0 : _5.taxRate, (_6 !== null && _6 !== void 0 ? _6 : undefined));
10861
+ }
10845
10862
  _this.asociatedDataSubject.next(asociated);
10846
10863
  };
10847
10864
  /**
@@ -12745,15 +12762,24 @@ var RedsysCatchEcComponent = /** @class */ (function (_super) {
12745
12762
  case '200':
12746
12763
  state = 'success';
12747
12764
  _this.setStateInLocal('Su pago fue procesado con éxito.', state);
12765
+ if (queryParams.total_amount) {
12766
+ localStorage.setItem('total_amount', queryParams.total_amount);
12767
+ }
12748
12768
  break;
12749
12769
  case 'success':
12750
12770
  _this.setStateInLocal('Su pago fue procesado con éxito.', state);
12771
+ if (queryParams.total_amount) {
12772
+ localStorage.setItem('total_amount', queryParams.total_amount);
12773
+ }
12751
12774
  break;
12752
12775
  case 'pending':
12753
12776
  _this.setStateInLocal('Su pago fue procesado con éxito.', state);
12754
12777
  break;
12755
12778
  case 'failure':
12756
12779
  _this.setStateInLocal('Se ha cancelado el proceso de pago.', state);
12780
+ if (queryParams.total_amount) {
12781
+ localStorage.setItem('total_amount', queryParams.total_amount);
12782
+ }
12757
12783
  break;
12758
12784
  case 'cancel':
12759
12785
  _this.setStateInLocal('Se ha cancelado el proceso de pago.', state);
@@ -19280,6 +19306,10 @@ var PlaceToPayEcComponent = /** @class */ (function (_super) {
19280
19306
  _this.ready = new EventEmitter();
19281
19307
  _this.loading = false;
19282
19308
  _this.closeModal = '';
19309
+ _this.hasPreviousFailure = false;
19310
+ _this.previousFailureAmount = null;
19311
+ _this.previousFailureDate = null;
19312
+ _this.buttonText = 'Pagar';
19283
19313
  _this.dataRedirect = function () {
19284
19314
  return _this.consts.getUrlBase() + 'shop-api/' + _this.consts.getChannel() + '/place-to-pay/' + _this.cartService.cart_token + '/process-payment';
19285
19315
  };
@@ -19302,17 +19332,33 @@ var PlaceToPayEcComponent = /** @class */ (function (_super) {
19302
19332
  var _a, _b, _c, _d;
19303
19333
  var state = _this.closeModal !== '' ? _this.closeModal : localStorage.getItem('state');
19304
19334
  !state && ((_a = _this.ventana) === null || _a === void 0 ? void 0 : _a.closed) && (state = 'cancel');
19335
+ _this.hasPreviousFailure = false;
19305
19336
  _this.loading = true;
19306
19337
  if (state) {
19307
- _this.loading = false;
19308
19338
  localStorage.removeItem('state');
19309
19339
  if (state === 'success' || state === 'pending') {
19310
19340
  (_b = _this.ventana) === null || _b === void 0 ? void 0 : _b.close();
19311
19341
  _this.ready.emit(true);
19312
19342
  return;
19313
19343
  }
19344
+ _this.loading = false;
19314
19345
  if (state === 'failure' || state === 'cancel') {
19315
19346
  (_c = _this.ventana) === null || _c === void 0 ? void 0 : _c.close();
19347
+ if (state === 'failure') {
19348
+ var amt = localStorage.getItem('total_amount');
19349
+ if (amt) {
19350
+ _this.hasPreviousFailure = true;
19351
+ _this.previousFailureAmount = parseFloat(amt);
19352
+ _this.previousFailureDate = new Date().toLocaleDateString('es-AR', {
19353
+ day: '2-digit',
19354
+ month: '2-digit',
19355
+ year: 'numeric',
19356
+ });
19357
+ _this.buttonText = 'Reintentar pago';
19358
+ localStorage.removeItem('total_amount');
19359
+ localStorage.removeItem('payment_date');
19360
+ }
19361
+ }
19316
19362
  _this.getPreference();
19317
19363
  _this.processError(state === 'cancel' ? 'Se canceló el pago con Place to Pay' : '');
19318
19364
  return;
@@ -19375,7 +19421,7 @@ var PlaceToPayEcComponent = /** @class */ (function (_super) {
19375
19421
  PlaceToPayEcComponent = __decorate$20([
19376
19422
  Component({
19377
19423
  selector: 'app-place-to-pay-ec',
19378
- template: "<div class=\"text-center\">\n <ng-container *ngIf=\"url; else loadingUrl\">\n <ng-container *ngIf=\"!loading; else loadingTemp\">\n <button (click)=\"iniciar()\" class=\"btn btn-outline-secondary rounded-0 comprar mt-3\">Pagar</button>\n </ng-container>\n </ng-container>\n</div>\n\n<ng-template #loadingUrl>\n <div class=\"d-flex flex-column justify-content-center align-items-center mt-2\">\n <app-loading-full-ec></app-loading-full-ec>\n </div>\n</ng-template>\n\n<ng-template #loadingTemp>\n <div class=\"d-flex flex-column justify-content-center align-items-center mt-2\">\n <h3>Procesando el pago por Place to Pay</h3>\n <h5>Recuerde hacer click en \"Volver al sitio\" desde Place to Pay para finalizar la compra.</h5>\n <app-loading-full-ec></app-loading-full-ec>\n </div>\n <div class=\"container-fluid\">\n <div class=\"row\">\n <div class=\"col-5\">\n <hr>\n </div>\n <div class=\"col-2 text-center\">\n <label>o</label>\n </div>\n <div class=\"col-5\">\n <hr>\n </div>\n </div>\n </div>\n <div class=\"d-flex flex-column justify-content-center align-items-center mt-2\">\n <button (click)=\"clickClose()\" class=\"btn btn-outline-secondary rounded-0 comprar\">Cancelar pago</button>\n </div>\n</ng-template>",
19424
+ template: "<div class=\"text-center\">\n <ng-container *ngIf=\"url; else loadingUrl\">\n <ng-container *ngIf=\"!loading; else loadingTemp\">\n <button (click)=\"iniciar()\" class=\"btn btn-outline-secondary rounded-0 comprar mt-3\">\n {{ buttonText }}\n </button>\n\n <!-- Mensaje de intento previo fallido -->\n <div *ngIf=\"hasPreviousFailure\" class=\"alert alert-danger mt-3\">\n El pago no se pudo realizar el {{ previousFailureDate }}\n por un monto de {{ previousFailureAmount | ecCurrencySymbol }}.\n </div>\n </ng-container>\n </ng-container>\n</div>\n\n<ng-template #loadingUrl>\n <div class=\"d-flex flex-column justify-content-center align-items-center mt-2\">\n <app-loading-full-ec></app-loading-full-ec>\n </div>\n</ng-template>\n\n<ng-template #loadingTemp>\n <div class=\"d-flex flex-column justify-content-center align-items-center mt-2\">\n <h3>Procesando el pago por Place to Pay</h3>\n <h5>Recuerde hacer click en \"Volver al sitio\" desde Place to Pay para finalizar la compra.</h5>\n <app-loading-full-ec></app-loading-full-ec>\n </div>\n <div class=\"container-fluid\">\n <div class=\"row\">\n <div class=\"col-5\">\n <hr>\n </div>\n <div class=\"col-2 text-center\">\n <label>o</label>\n </div>\n <div class=\"col-5\">\n <hr>\n </div>\n </div>\n </div>\n <div class=\"d-flex flex-column justify-content-center align-items-center mt-2\">\n <button (click)=\"clickClose()\" class=\"btn btn-outline-secondary rounded-0 comprar\">Cancelar pago</button>\n </div>\n</ng-template>",
19379
19425
  styles: [""]
19380
19426
  })
19381
19427
  ], PlaceToPayEcComponent);