bdpformulas 1.0.51 → 1.0.53
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/build/strategies/eeff/admFinanciera/prestamoBajoLineaHandler.js +1 -1
- package/build/strategies/eeff/admFinanciera/prestamoDirectoHandler.js +15 -6
- package/build/strategies/eeff/admFinanciera/utils.d.ts +0 -1
- package/build/strategies/eeff/admFinanciera/utils.js +30 -21
- package/build/strategies/eeff/index.js +289 -1212
- package/package.json +1 -1
|
@@ -24,7 +24,7 @@ class PrestamoBajoLineaHandler {
|
|
|
24
24
|
this.prestamo.VencimientoLinea) {
|
|
25
25
|
const fechaInicio = (0, utils_1.getDateTime)(this.data.InicioProyeccion).endOf('month');
|
|
26
26
|
const fechaVencimiento = (0, utils_1.getDateTime)(this.prestamo.VencimientoLinea).endOf('month');
|
|
27
|
-
const diferenciaAños = Math.
|
|
27
|
+
const diferenciaAños = Math.floor(fechaVencimiento.diff(fechaInicio, 'years').years);
|
|
28
28
|
if (diferenciaAños > 0) {
|
|
29
29
|
cantidadAños = diferenciaAños;
|
|
30
30
|
}
|
|
@@ -35,11 +35,16 @@ class PrestamoDirectoHandler {
|
|
|
35
35
|
return this.prestamo;
|
|
36
36
|
}
|
|
37
37
|
setMesesPorcionPagada() {
|
|
38
|
+
let value;
|
|
38
39
|
if (this.prestamo.FechaDesembolso) {
|
|
39
40
|
const inicial = (0, utils_1.getDateTime)(this.data.InicioProyeccion).endOf('month');
|
|
40
41
|
const desembolso = (0, utils_1.getDateTime)(this.prestamo.FechaDesembolso).endOf('month');
|
|
41
|
-
|
|
42
|
+
const diferencia = Math.floor(inicial.diff(desembolso, 'months').months);
|
|
43
|
+
if (diferencia > 0) {
|
|
44
|
+
value = diferencia;
|
|
45
|
+
}
|
|
42
46
|
}
|
|
47
|
+
this.prestamo.MesesPorcionPagada = value;
|
|
43
48
|
}
|
|
44
49
|
setProyecciones() {
|
|
45
50
|
for (let i = 1; i <= this.data.CantidadProyeccion; i++) {
|
|
@@ -113,6 +118,7 @@ class PrestamoDirectoHandler {
|
|
|
113
118
|
(0, utils_1.ourParseFloat)(this.prestamo.AmortizacionesCapitalCuotaFinal?.[`Gestion${gestion}`]);
|
|
114
119
|
}
|
|
115
120
|
setPorcionCuotasPagadas() {
|
|
121
|
+
let porcion, cuotas;
|
|
116
122
|
if (this.prestamo.FechaDesembolso) {
|
|
117
123
|
const pagado = (0, utils_1.calcularPorcionCorrientePagada)({
|
|
118
124
|
fechaInicial: this.data.InicioProyeccion,
|
|
@@ -120,8 +126,8 @@ class PrestamoDirectoHandler {
|
|
|
120
126
|
frecuencia: this.prestamo.TipoPeriodicidadId ?? 'MENSUAL',
|
|
121
127
|
simulador: this.simulador.simulador
|
|
122
128
|
});
|
|
123
|
-
|
|
124
|
-
|
|
129
|
+
porcion = (0, utils_1.ourParseFloat)(pagado.porcionCorrientePagada);
|
|
130
|
+
cuotas = pagado.cuotasPagadas;
|
|
125
131
|
if (this.prestamo.TipoFacilidad === 'FIJA') {
|
|
126
132
|
const dif = (0, utils_1.ourParseFloat)(this.prestamo.Gracia) -
|
|
127
133
|
(0, utils_1.ourParseFloat)(this.prestamo.CuotasPagadas);
|
|
@@ -139,6 +145,8 @@ class PrestamoDirectoHandler {
|
|
|
139
145
|
});
|
|
140
146
|
}
|
|
141
147
|
}
|
|
148
|
+
this.prestamo.PorcionPagada = porcion;
|
|
149
|
+
this.prestamo.CuotasPagadas = cuotas;
|
|
142
150
|
}
|
|
143
151
|
setAmortizacionesCapital() {
|
|
144
152
|
const añoProyectadoInicio = this.prestamo.AnnoProyectadoInicio;
|
|
@@ -153,8 +161,9 @@ class PrestamoDirectoHandler {
|
|
|
153
161
|
this.prestamo.AmortizacionesCapital = amortizacion;
|
|
154
162
|
}
|
|
155
163
|
setPlazoRemanente() {
|
|
156
|
-
this.prestamo.PlazoRemanenteAños =
|
|
157
|
-
(0, utils_1.ourParseFloat)(this.prestamo.
|
|
164
|
+
this.prestamo.PlazoRemanenteAños =
|
|
165
|
+
(0, utils_1.ourParseFloat)(this.prestamo.Plazo) -
|
|
166
|
+
(0, utils_1.ourParseFloat)(this.prestamo.Gracia) / 12;
|
|
158
167
|
}
|
|
159
168
|
setPlazos() {
|
|
160
169
|
this.prestamo.Plazos = (0, utils_1.generatePlazos)({
|
|
@@ -196,7 +205,7 @@ class PrestamoDirectoHandler {
|
|
|
196
205
|
if (i === 1) {
|
|
197
206
|
if (plazo && this.prestamo.AnnoProyectadoInicio === 1) {
|
|
198
207
|
if ((0, utils_1.ourParseFloat)(this.prestamo.PlazoRemanenteAños) < plazo) {
|
|
199
|
-
value = 0;
|
|
208
|
+
value = (0, utils_1.ourParseFloat)(this.prestamo.MontoOriginal);
|
|
200
209
|
}
|
|
201
210
|
else {
|
|
202
211
|
value =
|
|
@@ -13,7 +13,7 @@ exports.frecuenciaMeses = {
|
|
|
13
13
|
function simuladorCuotas({ monto, plazo, frecuencia, tipoCuota, periodoGracia = 0, tasaInteres = 0, polizaSD = 0, plazoMeses = false }) {
|
|
14
14
|
const mesesPorFrecuencia = exports.frecuenciaMeses[frecuencia];
|
|
15
15
|
const plazoEnMeses = !plazoMeses ? plazo * 12 : plazo;
|
|
16
|
-
const cuotasTotales =
|
|
16
|
+
const cuotasTotales = plazoEnMeses / mesesPorFrecuencia;
|
|
17
17
|
const tasaPorPeriodo = tasaInteres / (12 / mesesPorFrecuencia) / 100;
|
|
18
18
|
let saldoCapital = monto;
|
|
19
19
|
const cuotas = [];
|
|
@@ -22,29 +22,40 @@ function simuladorCuotas({ monto, plazo, frecuencia, tipoCuota, periodoGracia =
|
|
|
22
22
|
let interesAnual = 0;
|
|
23
23
|
let cuotaAnual = 0;
|
|
24
24
|
let anioActual = 1;
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
? (monto * tasaPorPeriodo) /
|
|
28
|
-
(1 - Math.pow(1 + tasaPorPeriodo, -cuotasTotales))
|
|
29
|
-
: 0;
|
|
25
|
+
const diasFrecuencia = 360 / (mesesPorFrecuencia * 30);
|
|
26
|
+
const diasGracia = periodoGracia / 12;
|
|
30
27
|
for (let i = 1; i <= cuotasTotales; i++) {
|
|
28
|
+
if (i > 1) {
|
|
29
|
+
const anteriorCuota = cuotas.at(-1);
|
|
30
|
+
saldoCapital =
|
|
31
|
+
ourParseFloat(anteriorCuota?.saldoCapital) -
|
|
32
|
+
ourParseFloat(anteriorCuota?.amortizacion);
|
|
33
|
+
}
|
|
34
|
+
const interes = saldoCapital * tasaPorPeriodo;
|
|
31
35
|
let amortizacion = 0;
|
|
32
|
-
let
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
cuotaCredito = cuotaFija;
|
|
39
|
-
amortizacion = cuotaCredito - interes;
|
|
36
|
+
let cuotaCredito;
|
|
37
|
+
if (tipoCuota === 'FIJA') {
|
|
38
|
+
const tasaInteresFrecuencia = tasaInteres / 100 / diasFrecuencia;
|
|
39
|
+
if (i > 1) {
|
|
40
|
+
const anteriorCuota = cuotas.at(-1);
|
|
41
|
+
cuotaCredito = anteriorCuota?.cuotaCredito ?? 0;
|
|
40
42
|
}
|
|
41
43
|
else {
|
|
44
|
+
cuotaCredito =
|
|
45
|
+
monto *
|
|
46
|
+
(tasaInteresFrecuencia /
|
|
47
|
+
(1 -
|
|
48
|
+
Math.pow(1 + tasaInteresFrecuencia, -(diasFrecuencia *
|
|
49
|
+
((plazoEnMeses - periodoGracia) / 12)))));
|
|
50
|
+
}
|
|
51
|
+
amortizacion = cuotaCredito - interes;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
if (i > diasFrecuencia * diasGracia) {
|
|
42
55
|
amortizacion =
|
|
43
|
-
monto /
|
|
44
|
-
(cuotasTotales -
|
|
45
|
-
Math.ceil(periodoGracia / mesesPorFrecuencia));
|
|
46
|
-
cuotaCredito = amortizacion + interes;
|
|
56
|
+
monto / (diasFrecuencia * (plazoEnMeses / 12 - diasGracia));
|
|
47
57
|
}
|
|
58
|
+
cuotaCredito = amortizacion + interes;
|
|
48
59
|
}
|
|
49
60
|
const cuotaTotal = cuotaCredito + polizaSD;
|
|
50
61
|
cuotas.push({
|
|
@@ -54,10 +65,8 @@ function simuladorCuotas({ monto, plazo, frecuencia, tipoCuota, periodoGracia =
|
|
|
54
65
|
cuotaCredito,
|
|
55
66
|
poliza: polizaSD,
|
|
56
67
|
cuotaTotal,
|
|
57
|
-
saldoCapital
|
|
58
|
-
tiempoDias
|
|
68
|
+
saldoCapital
|
|
59
69
|
});
|
|
60
|
-
saldoCapital -= amortizacion;
|
|
61
70
|
// Acumular valores anuales
|
|
62
71
|
capitalAnual += amortizacion;
|
|
63
72
|
interesAnual += interes;
|