iptdevs-design-system 2.7.116 → 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
- let newJsDate = this.setPlusOneMonth(dateJs);
3463
+ let newJsDate = this.setPlusOneMonth(dateJs, isEndMonth);
3460
3464
  let row = [
3461
3465
  index,
3462
3466
  Intl.NumberFormat('en-US', {
@@ -3472,15 +3476,18 @@ class CalculateQuotesService {
3472
3476
  }
3473
3477
  return dataFinancing;
3474
3478
  }
3475
- setPlusOneMonth(originDate) {
3479
+ setPlusOneMonth(originDate, isEndMonth) {
3476
3480
  let response = [];
3477
3481
  let oneDayMilis = 1000 * 3600 * 24;
3478
- 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);
3479
3484
  response.push(plusMonthDate);
3480
3485
  while (plusMonthDate.getDay() === 0) {
3481
3486
  plusMonthDate.setMilliseconds(originDate.getMilliseconds() - oneDayMilis);
3482
3487
  }
3483
3488
  response.push(plusMonthDate);
3489
+ console.log('date for ' + day + ' - ' + originDate.getMonth());
3490
+ console.log(response);
3484
3491
  return response;
3485
3492
  }
3486
3493
  getStringDate(originDate) {