iptdevs-design-system 2.7.60 → 2.7.62

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.
@@ -3333,14 +3333,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImpor
3333
3333
  class CalculateQuotesService {
3334
3334
  constructor() { }
3335
3335
  calculateQuotes(params) {
3336
- console.log(params);
3337
3336
  console.log(params.date);
3338
3337
  let dataFinancing = [];
3339
3338
  let index = 1; // Indicador de cant. de cuotas
3340
- let dat = new Date(params.date);
3341
- let momentJs = moment(params.date).add(1, 'days');
3342
- console.log(momentJs);
3343
- if (this.validateSunday(momentJs.toDate())) {
3339
+ let dateJs = new Date(params.date);
3340
+ if (dateJs.getDay() === 0) {
3344
3341
  Swal.fire({
3345
3342
  title: 'Fecha inválida',
3346
3343
  text: 'Debe seleccionar un día de la semana diferente al domingo',
@@ -3355,42 +3352,37 @@ class CalculateQuotesService {
3355
3352
  currency: 'USD',
3356
3353
  minimumFractionDigits: 0
3357
3354
  }).format(Math.round(parseFloat(params.quotaValues.toString()))),
3358
- momentJs.format('dddd') + ', ' + momentJs.format('MMMM DD YYYY')
3355
+ this.getStringDate(dateJs)
3359
3356
  ];
3360
3357
  dataFinancing.push(quota);
3361
3358
  while (index < params.quotaTimes) {
3362
3359
  index = index + 1;
3363
- const momentJs = moment(params.date).add(index - 1, 'M');
3364
- if (this.validateSunday(momentJs.toDate())) {
3365
- momentJs.add(1, 'days');
3366
- Swal.fire({
3367
- title: 'Querido asesor',
3368
- text: 'Hemos ajustado las fechas para que no se asignen en Domingos',
3369
- icon: 'info'
3370
- });
3371
- }
3360
+ dateJs = this.setPlusOneMonth(dateJs);
3372
3361
  let row = [
3373
3362
  index,
3374
3363
  Intl.NumberFormat('en-US', {
3375
3364
  style: 'currency',
3376
3365
  currency: 'USD',
3377
- minimumFractionDigits: 0,
3378
- }).format(Math.round(params.quotaValues)),
3379
- momentJs.format('dddd') + ', ' + momentJs.format('MMMM DD YYYY'),
3366
+ minimumFractionDigits: 0
3367
+ }).format(Math.round(parseFloat(params.quotaValues.toString()))),
3368
+ this.getStringDate(dateJs)
3380
3369
  ];
3381
3370
  dataFinancing.push(row);
3382
3371
  }
3383
3372
  }
3384
3373
  return dataFinancing;
3385
3374
  }
3386
- validateSunday(date) {
3387
- const momentJs = moment(date);
3388
- if (momentJs.isoWeekday() === 7) {
3389
- return true;
3390
- }
3391
- else {
3392
- return false;
3375
+ setPlusOneMonth(originDate) {
3376
+ let oneDayMilis = 1000 * 3600 * 24;
3377
+ let plusMonthDate = new Date(originDate.getFullYear(), originDate.getMonth() + 1, originDate.getDate());
3378
+ while (plusMonthDate.getDay() === 0) {
3379
+ let iterationDate = originDate.getMilliseconds() + oneDayMilis;
3380
+ plusMonthDate = new Date(iterationDate);
3393
3381
  }
3382
+ return plusMonthDate;
3383
+ }
3384
+ getStringDate(originDate) {
3385
+ return originDate.getFullYear() + ' - ' + (originDate.getMonth() + 1) + ' - ' + originDate.getDate();
3394
3386
  }
3395
3387
  }
3396
3388
  CalculateQuotesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: CalculateQuotesService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });