bdpformulas 1.0.61 → 1.0.63
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/analisisFinancieros.strategy.js +6 -2
- package/build/strategies/common/analisisFinCalculos/analisisGrafico.calc.js +3 -4
- package/build/strategies/common/flujoCalculos/flujoConstructor.js +36 -12
- package/build/strategies/index.js +554 -328
- package/build/strategies/pecuary/flujoProyPec.strategy.js +0 -2
- package/package.json +1 -1
|
@@ -25,7 +25,9 @@ class AnalisisFinancieros {
|
|
|
25
25
|
return data;
|
|
26
26
|
}
|
|
27
27
|
generarMapBalance = (data) => {
|
|
28
|
-
return data.balance.balance
|
|
28
|
+
return data.balance.balance
|
|
29
|
+
.filter((item) => item.Clasificador != 'SBCT')
|
|
30
|
+
.reduce((acc, item) => {
|
|
29
31
|
const uuid = item.UUID ? item.UUID : '0';
|
|
30
32
|
const key = `${item.RubroId}_${item.Clasificador == 'HABM' || item.Clasificador == 'CT'
|
|
31
33
|
? uuid
|
|
@@ -37,7 +39,9 @@ class AnalisisFinancieros {
|
|
|
37
39
|
}, new Map());
|
|
38
40
|
};
|
|
39
41
|
generarMapEERR = (data) => {
|
|
40
|
-
return data.balance.eerr
|
|
42
|
+
return data.balance.eerr
|
|
43
|
+
.filter((item) => item.Clasificador != 'SBCT')
|
|
44
|
+
.reduce((acc, item) => {
|
|
41
45
|
const uuid = item.UUID ? item.UUID : '0';
|
|
42
46
|
const key = `${item.RubroId}_${item.Clasificador == 'HABM' || item.Clasificador == 'CT'
|
|
43
47
|
? uuid
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const lodash_1 = require("lodash");
|
|
4
4
|
class AnalisisGrafico {
|
|
5
|
-
//@ts-ignore
|
|
6
5
|
data;
|
|
7
6
|
cantidadGestiones;
|
|
8
7
|
constructor(data) {
|
|
@@ -58,9 +57,9 @@ class AnalisisGrafico {
|
|
|
58
57
|
const ratio4 = (0, lodash_1.clone)(this.data.Ratios.rentabilidad.find((item) => item.id === 'Ratio4'));
|
|
59
58
|
const ratio5 = (0, lodash_1.clone)(this.data.Ratios.rentabilidad.find((item) => item.id === 'Ratio5'));
|
|
60
59
|
for (let i = 1; i <= this.cantidadGestiones; i++) {
|
|
61
|
-
ratio3[`Monto${i}`] = Math.round(ratio3[`Monto${i}`]
|
|
62
|
-
ratio4[`Monto${i}`] = Math.round(ratio4[`Monto${i}`]
|
|
63
|
-
ratio5[`Monto${i}`] = Math.round(ratio5[`Monto${i}`]
|
|
60
|
+
ratio3[`Monto${i}`] = Math.round(ratio3[`Monto${i}`]);
|
|
61
|
+
ratio4[`Monto${i}`] = Math.round(ratio4[`Monto${i}`]);
|
|
62
|
+
ratio5[`Monto${i}`] = Math.round(ratio5[`Monto${i}`]);
|
|
64
63
|
}
|
|
65
64
|
array.push(ratio3);
|
|
66
65
|
array.push(ratio4);
|
|
@@ -479,7 +479,7 @@ class FlujoConstructor {
|
|
|
479
479
|
const VAN = calcularVAN(tasaDescuento, result
|
|
480
480
|
.filter((item) => item.Anno > 0)
|
|
481
481
|
.map((item) => item.FlujoDeEfectivo), totalFlujoInversiones[`Monto1`]);
|
|
482
|
-
const TIR = calcularTIR(result.map((item) => item.FlujoDeEfectivo)
|
|
482
|
+
const TIR = calcularTIR(result.map((item) => item.FlujoDeEfectivo)) * 100;
|
|
483
483
|
const vars = [
|
|
484
484
|
{ Descripcion: 'Tasa de descuento', Valor: tasaDescuento },
|
|
485
485
|
{ Descripcion: 'VAN', Valor: VAN },
|
|
@@ -498,19 +498,43 @@ const calcularVAN = (tasaDescuento, flujosDeCaja, inversionInicial) => {
|
|
|
498
498
|
}
|
|
499
499
|
return VAN;
|
|
500
500
|
};
|
|
501
|
-
const calcularTIR = (
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
501
|
+
/* const calcularTIR = (
|
|
502
|
+
flujosDeCaja: any[number],
|
|
503
|
+
inversionInicial: number,
|
|
504
|
+
precision = 1e-6
|
|
505
|
+
) => {
|
|
506
|
+
let tasaMin = 0
|
|
507
|
+
let tasaMax = 1
|
|
508
|
+
let tasaMed = (tasaMin + tasaMax) / 2
|
|
509
|
+
|
|
505
510
|
while (tasaMax - tasaMin > precision) {
|
|
506
|
-
const VAN = calcularVAN(tasaMed, flujosDeCaja, inversionInicial)
|
|
511
|
+
const VAN = calcularVAN(tasaMed, flujosDeCaja, inversionInicial)
|
|
512
|
+
|
|
507
513
|
if (VAN > 0) {
|
|
508
|
-
tasaMin = tasaMed
|
|
514
|
+
tasaMin = tasaMed
|
|
515
|
+
} else {
|
|
516
|
+
tasaMax = tasaMed
|
|
509
517
|
}
|
|
510
|
-
|
|
511
|
-
|
|
518
|
+
tasaMed = (tasaMin + tasaMax) / 2
|
|
519
|
+
}
|
|
520
|
+
return tasaMed
|
|
521
|
+
} */
|
|
522
|
+
function calcularTIR(flujos, tasaInicial = 0.1, iteracionesMax = 100, tolerancia = 1e-6) {
|
|
523
|
+
let tasa = tasaInicial;
|
|
524
|
+
for (let i = 0; i < iteracionesMax; i++) {
|
|
525
|
+
let f = 0; // Valor de la función
|
|
526
|
+
let fPrima = 0; // Derivada de la función
|
|
527
|
+
for (let t = 0; t < flujos.length; t++) {
|
|
528
|
+
f += flujos[t] / Math.pow(1 + tasa, t);
|
|
529
|
+
fPrima -= (t * flujos[t]) / Math.pow(1 + tasa, t + 1);
|
|
530
|
+
}
|
|
531
|
+
const nuevaTasa = tasa - f / fPrima;
|
|
532
|
+
// Si la diferencia entre tasas es menor a la tolerancia, hemos encontrado la solución
|
|
533
|
+
if (Math.abs(nuevaTasa - tasa) < tolerancia) {
|
|
534
|
+
return nuevaTasa;
|
|
512
535
|
}
|
|
513
|
-
|
|
536
|
+
tasa = nuevaTasa;
|
|
514
537
|
}
|
|
515
|
-
|
|
516
|
-
|
|
538
|
+
// Si no converge después de las iteraciones máximas, retorna null
|
|
539
|
+
return 0;
|
|
540
|
+
}
|