iptdevs-design-system 2.7.115 → 2.7.117

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.
@@ -3430,12 +3430,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.7", ngImpor
3430
3430
  }] } });
3431
3431
 
3432
3432
  class CalculateQuotesService {
3433
- constructor() { }
3433
+ constructor() {
3434
+ this.monthsDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
3435
+ }
3434
3436
  calculateQuotes(params) {
3435
3437
  let dataFinancing = [];
3436
3438
  let index = 1; // Indicador de cant. de cuotas
3437
3439
  let dateJs = new Date(params.date);
3440
+ let isEndMonth = false;
3438
3441
  dateJs.setMilliseconds(dateJs.getMilliseconds() + (1000 * 3600 * 24));
3442
+ isEndMonth = this.monthsDays[dateJs.getMonth()] === dateJs.getDate();
3439
3443
  if (dateJs.getDay() === 0) {
3440
3444
  Swal.fire({
3441
3445
  title: 'Fecha inválida',
@@ -3456,7 +3460,7 @@ class CalculateQuotesService {
3456
3460
  dataFinancing.push(quota);
3457
3461
  while (index < params.quotaTimes) {
3458
3462
  index = index + 1;
3459
- dateJs = this.setPlusOneMonth(dateJs);
3463
+ let newJsDate = this.setPlusOneMonth(dateJs, isEndMonth);
3460
3464
  let row = [
3461
3465
  index,
3462
3466
  Intl.NumberFormat('en-US', {
@@ -3464,20 +3468,27 @@ class CalculateQuotesService {
3464
3468
  currency: 'USD',
3465
3469
  minimumFractionDigits: 0
3466
3470
  }).format(Math.round(parseFloat(params.quotaValues.toString()))),
3467
- this.getStringDate(dateJs)
3471
+ this.getStringDate(newJsDate[newJsDate.length - 1])
3468
3472
  ];
3469
3473
  dataFinancing.push(row);
3474
+ dateJs = newJsDate[0];
3470
3475
  }
3471
3476
  }
3472
3477
  return dataFinancing;
3473
3478
  }
3474
- setPlusOneMonth(originDate) {
3479
+ setPlusOneMonth(originDate, isEndMonth) {
3480
+ let response = [];
3475
3481
  let oneDayMilis = 1000 * 3600 * 24;
3476
- let plusMonthDate = new Date(originDate.getFullYear(), originDate.getMonth() + 1, originDate.getDate());
3482
+ let day = isEndMonth || (originDate.getMonth() === 1 && originDate.getDate() > 28) ? this.monthsDays[originDate.getMonth()] : originDate.getDate();
3483
+ let plusMonthDate = new Date(originDate.getFullYear(), originDate.getMonth() + 1, day);
3484
+ response.push(plusMonthDate);
3477
3485
  while (plusMonthDate.getDay() === 0) {
3478
- plusMonthDate.setMilliseconds(originDate.getMilliseconds() + oneDayMilis);
3486
+ plusMonthDate.setMilliseconds(originDate.getMilliseconds() - oneDayMilis);
3479
3487
  }
3480
- return plusMonthDate;
3488
+ response.push(plusMonthDate);
3489
+ console.log('date for ' + day + ' - ' + originDate.getMonth());
3490
+ console.log(response);
3491
+ return response;
3481
3492
  }
3482
3493
  getStringDate(originDate) {
3483
3494
  let month = originDate.getMonth() + 1;