bdpformulas 1.0.36 → 1.0.38

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.
Files changed (28) hide show
  1. package/build/index.d.ts +2 -0
  2. package/build/index.js +3 -1
  3. package/build/strategies/agriculture/flujoProyAgr.strategy.js +81 -2
  4. package/build/strategies/agriculture/ventas.detail/ventas.calc.d.ts +2 -0
  5. package/build/strategies/agriculture/ventas.detail/ventas.calc.js +38 -0
  6. package/build/strategies/analisisFinancieros.strategy.d.ts +6 -0
  7. package/build/strategies/analisisFinancieros.strategy.js +46 -0
  8. package/build/strategies/balance.strategy.js +1 -1
  9. package/build/strategies/common/analisisFinCalculos/analisisDupont.calc.d.ts +1 -0
  10. package/build/strategies/common/analisisFinCalculos/analisisDupont.calc.js +29 -0
  11. package/build/strategies/common/analisisFinCalculos/analisisGrafico.calc.d.ts +11 -0
  12. package/build/strategies/common/analisisFinCalculos/analisisGrafico.calc.js +59 -0
  13. package/build/strategies/common/analisisFinCalculos/apalancamiento.calc.d.ts +1 -0
  14. package/build/strategies/common/analisisFinCalculos/apalancamiento.calc.js +41 -0
  15. package/build/strategies/common/analisisFinCalculos/puntoEquilibrio.calc.d.ts +0 -0
  16. package/build/strategies/common/analisisFinCalculos/puntoEquilibrio.calc.js +1 -0
  17. package/build/strategies/common/analisisFinCalculos/ratios.calc.d.ts +9 -0
  18. package/build/strategies/common/analisisFinCalculos/ratios.calc.js +172 -0
  19. package/build/strategies/common/declaracionJurada.calc.d.ts +2 -0
  20. package/build/strategies/common/declaracionJurada.calc.js +83 -0
  21. package/build/strategies/common/flujoCalculos/flujoConstructor.d.ts +24 -0
  22. package/build/strategies/common/flujoCalculos/flujoConstructor.js +305 -0
  23. package/build/strategies/common/flujoCalculos/supuestos.calc.d.ts +2 -0
  24. package/build/strategies/common/flujoCalculos/supuestos.calc.js +123 -0
  25. package/build/strategies/common/flujoProyectado.calc.d.ts +3 -11
  26. package/build/strategies/common/flujoProyectado.calc.js +29 -63
  27. package/build/strategies/flujoProyectado.strategy.js +53 -7
  28. package/package.json +1 -1
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.anadirDeclaracionJurada = exports.getCajaInicial = void 0;
4
+ const balanceAux_calc_1 = require("./balanceCalculos/balanceAux.calc");
5
+ const getCajaInicial = (declaracionJurada) => {
6
+ if (!declaracionJurada || !declaracionJurada.Balance || declaracionJurada.Balance.length == 0)
7
+ return 0;
8
+ const disponibilidades = declaracionJurada.Balance.find((value) => value.RubroId === 'SOL_ACT_001');
9
+ if (!disponibilidades)
10
+ throw new Error('No se encontró el rubro de Disponibilidades en el balance de la declaración jurada');
11
+ return disponibilidades.MontoFamiliar;
12
+ };
13
+ exports.getCajaInicial = getCajaInicial;
14
+ const anadirDeclaracionJurada = (balanceMap, balanceArray, declaracionJurada) => {
15
+ const rango = balanceArray[0].Rango;
16
+ if (!declaracionJurada || declaracionJurada.length == 0)
17
+ throw new Error('Debe ingresar un Declaración Jurada válida');
18
+ const declaracionMap = declaracionJurada.reduce((acc, item) => {
19
+ acc.set(item.RubroId, item);
20
+ if (!acc.has('Total')) {
21
+ acc.set('Total', { TotalActivosE: 0, TotalPasivosE: 0, TotalActivosF: 0, TotalPasivosF: 0 });
22
+ }
23
+ if (item.TipoRubroId === 'ACTIVOS') {
24
+ acc.get('Total').TotalActivosE += parseFloat(item.MontoEmpresa);
25
+ acc.get('Total').TotalActivosF += parseFloat(item.MontoFamiliar);
26
+ }
27
+ if (item.TipoRubroId === 'PASIVOS') {
28
+ acc.get('Total').TotalPasivosE += parseFloat(item.MontoEmpresa);
29
+ acc.get('Total').TotalPasivosF += parseFloat(item.MontoFamiliar);
30
+ }
31
+ return acc;
32
+ }, new Map());
33
+ let referencia = [];
34
+ referencia.push(arrayValue(['SOL_ACT_001'], 'ACT_CN_11001'));
35
+ referencia.push(arrayValue(['SOL_ACT_002'], 'ACT_CN_11002'));
36
+ referencia.push(arrayValue(['SOL_ACT_011'], 'ACT_CN_11003'));
37
+ referencia.push(arrayValue(['SOL_ACT_003'], 'ACT_CN_12001'));
38
+ referencia.push(arrayValue(['SOL_ACT_005', 'SOL_ACT_007', 'SOL_ACT_008', 'SOL_ACT_009', 'SOL_ACT_010'], 'ACT_CN_12002'));
39
+ referencia.push(arrayValue(['SOL_ACT_004'], 'ACT_CN_12003'));
40
+ referencia.push(arrayValue(['SOL_ACT_006', 'SOL_ACT_012'], 'ACT_CN_12004'));
41
+ referencia.push(arrayValue(['SOL_PAS_001'], 'ACT_CN_21001'));
42
+ referencia.push(arrayValue(['SOL_PAS_002'], 'ACT_CN_21002'));
43
+ referencia.push(arrayValue(['SOL_PAS_003'], 'ACT_CN_22001'));
44
+ referencia.push(arrayValue(['SOL_PAS_004'], 'ACT_CN_22002'));
45
+ for (const item of referencia) {
46
+ const key = `${item.key}_${rango}`;
47
+ if (balanceMap.has(key)) {
48
+ if (balanceMap.get(key).MontoEmpresa == 0 || balanceMap.get(key).MontoFamiliar == 0) {
49
+ const values = getValuesFromDj(item.array, declaracionMap);
50
+ if (balanceMap.get(key).MontoEmpresa == 0)
51
+ balanceMap.get(key).MontoEmpresa = values.montoEmpresa;
52
+ if (balanceMap.get(key).MontoFamiliar == 0)
53
+ balanceMap.get(key).MontoFamiliar = values.montoFamiliar;
54
+ }
55
+ }
56
+ else {
57
+ const some = balanceArray.find((value) => value.RubroId === item.ley);
58
+ const values = getValuesFromDj(item.array, declaracionMap);
59
+ (0, balanceAux_calc_1.anadirNuevoRubro)(some, balanceMap, values, '(Declaración Jurada)');
60
+ }
61
+ }
62
+ const keyCapital = `ACT_CN_30001_${rango}`;
63
+ balanceMap.get(keyCapital).MontoEmpresa = declaracionMap.get('Total').TotalActivosE -
64
+ declaracionMap.get('Total').TotalPasivosE;
65
+ balanceMap.get(keyCapital).MontoFamiliar = declaracionMap.get('Total').TotalActivosF -
66
+ declaracionMap.get('Total').TotalPasivosF;
67
+ };
68
+ exports.anadirDeclaracionJurada = anadirDeclaracionJurada;
69
+ const arrayValue = (array, key) => {
70
+ return {
71
+ array: array,
72
+ key: key
73
+ };
74
+ };
75
+ const getValuesFromDj = (arrayDj, declaracionMap) => {
76
+ let montoFamiliar = 0;
77
+ let montoEmpresa = 0;
78
+ for (const djItem of arrayDj) {
79
+ montoEmpresa += parseFloat(declaracionMap.get(djItem).MontoEmpresa);
80
+ montoFamiliar += parseFloat(declaracionMap.get(djItem).MontoFamiliar);
81
+ }
82
+ return { montoFamiliar, montoEmpresa };
83
+ };
@@ -0,0 +1,24 @@
1
+ export default class FlujoConstructor {
2
+ tipo: string;
3
+ rango: number;
4
+ private mapObject;
5
+ private array;
6
+ private data;
7
+ constructor(tipo: string, data: any);
8
+ calcularFlujo: () => void;
9
+ calcularFlujoAcumuladoMensual: (data: any) => void;
10
+ calcularTotal: (sumandosArray: string[], total: string) => void;
11
+ calcularResta: (positivoRubro: string, negativoRubro: string, destinoRubro: string) => void;
12
+ proyectarIngreso: () => void;
13
+ proyectarCosto: () => void;
14
+ proyectarGasto: () => void;
15
+ moverDetalledesdeMensual: () => void;
16
+ calcularTotalDetalle: (sumandosArray: string[], total: string) => void;
17
+ calcularPorcentajeIngresCostos: () => void;
18
+ calcularOtrosIngresosAnuales: () => void;
19
+ calcularGastosFamiliares: () => void;
20
+ calcularFlujoInversiones: () => void;
21
+ calcularFlujoAcumuladoAnual: () => void;
22
+ adicionarCapacidadPago: () => void;
23
+ getFlujoEfectivo: () => void;
24
+ }
@@ -0,0 +1,305 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class FlujoConstructor {
4
+ constructor(tipo, data) {
5
+ this.calcularFlujo = () => {
6
+ if (this.tipo == 'ANUAL') {
7
+ this.proyectarIngreso();
8
+ this.proyectarCosto();
9
+ this.proyectarGasto();
10
+ this.moverDetalledesdeMensual();
11
+ this.calcularTotalDetalle(['ACT_CNFL_73000'], 'ACT_CNFL_73900');
12
+ this.calcularTotalDetalle(['ACT_CNFL_61001'], 'ACT_CNFL_61900');
13
+ this.calcularOtrosIngresosAnuales();
14
+ this.calcularGastosFamiliares();
15
+ this.calcularFlujoInversiones();
16
+ }
17
+ this.calcularTotal(['ACT_CNFL_40001', 'ACT_CNFL_40002'], 'ACT_CNFL_49000'); //Total Ingresos
18
+ this.calcularTotal(['ACT_CNFL_50001', 'ACT_CNFL_50002'], 'ACT_CNFL_59000'); //Total Costos
19
+ this.calcularResta('ACT_CNFL_49000', 'ACT_CNFL_59000', 'ACT_CNFL_59999'); //Utilidad Bruta
20
+ this.calcularTotal(['ACT_CNFL_61001'], 'ACT_CNFL_61900'); //subtotal Gastos Operativos
21
+ this.calcularTotal(['ACT_CNFL_60001', 'ACT_CNFL_60002', 'ACT_CNFL_61900'], 'ACT_CNFL_69000'); //Total Gastos Operativos
22
+ this.calcularResta('ACT_CNFL_59999', 'ACT_CNFL_69000', 'ACT_CNFL_69999'); //Utilidad Operativa
23
+ this.calcularResta('ACT_CNFL_70001', 'ACT_CNFL_70002', 'ACT_CNFL_72000'); //Total Otros Ingresos e Egresos
24
+ this.calcularTotal(['ACT_CNFL_73000'], 'ACT_CNFL_73900');
25
+ this.calcularResta('ACT_CNFL_72000', 'ACT_CNFL_73900', 'ACT_CNFL_79000'); //Resultado Otros Ingresos e Egresos
26
+ this.calcularResta('ACT_CNFL_69999', 'ACT_CNFL_79000', 'ACT_CNFL_79999'); //Utilidad Neta
27
+ this.calcularTotal(['ACT_CNFL_80001', 'ACT_CNFL_80002'], 'ACT_CNFL_80900'); //Total Flujo de Inversión
28
+ this.calcularTotal(['ACT_CNFL_81001'], 'ACT_CNFL_81090'); //subtotal Ingresos de Efectivo
29
+ this.calcularTotal(['ACT_CNFL_81200'], 'ACT_CNFL_81290'); //subtotal Cuota BDP
30
+ this.calcularResta('ACT_CNFL_81090', 'ACT_CNFL_81290', 'ACT_CNFL_82100'); //Total Flujo financiero
31
+ if (this.tipo == 'MENSUAL') {
32
+ this.calcularTotal(['ACT_CNFL_79999', 'ACT_CNFL_80900', 'ACT_CNFL_82100'], 'ACT_CNFL_82200');
33
+ this.calcularFlujoAcumuladoMensual(this.data);
34
+ }
35
+ else if (this.tipo == 'ANUAL') {
36
+ this.calcularFlujoAcumuladoAnual();
37
+ this.calcularTotal(['ACT_CNFL_79999', 'ACT_CNFL_80900', 'ACT_CNFL_82100'], 'ACT_CNFL_82110');
38
+ this.adicionarCapacidadPago();
39
+ this.getFlujoEfectivo();
40
+ }
41
+ this.array.map((item) => {
42
+ item.MontoTotal = 0;
43
+ for (let i = 1; i <= this.rango; i++) {
44
+ item.MontoTotal += parseFloat(item[`Monto${i}`]);
45
+ }
46
+ item.MontoTotal = Math.round(item.MontoTotal * 100) / 100;
47
+ });
48
+ if (this.tipo == 'MENSUAL') {
49
+ this.calcularPorcentajeIngresCostos();
50
+ }
51
+ };
52
+ this.calcularFlujoAcumuladoMensual = (data) => {
53
+ let rowTotal = this.mapObject.get(`ACT_CNFL_82200_0`);
54
+ let rowAcumulado = this.mapObject.get(`ACT_CNFL_82300_0`);
55
+ for (let i = 1; i <= this.rango; i++) {
56
+ if (i == 1) {
57
+ rowAcumulado[`Monto${i}`] = parseFloat(rowTotal[`Monto${i}`]) + parseFloat(data.CajaInicial);
58
+ }
59
+ else {
60
+ rowAcumulado[`Monto${i}`] = rowTotal[`Monto${i}`] + rowAcumulado[`Monto${i - 1}`];
61
+ }
62
+ rowAcumulado[`Monto${i}`] = Math.round(rowAcumulado[`Monto${i}`] * 100) / 100;
63
+ }
64
+ };
65
+ this.calcularTotal = (sumandosArray, total) => {
66
+ const rows = this.array.filter((item) => sumandosArray.includes(item.RubroId));
67
+ let destino = this.mapObject.get(`${total}_0`);
68
+ rows.map((item) => {
69
+ for (let i = 1; i <= this.rango; i++) {
70
+ destino[`Monto${i}`] += parseFloat(item[`Monto${i}`]);
71
+ destino[`Monto${i}`] = Math.round(destino[`Monto${i}`] * 100) / 100;
72
+ }
73
+ });
74
+ };
75
+ this.calcularResta = (positivoRubro, negativoRubro, destinoRubro) => {
76
+ const positivo = this.mapObject.get(`${positivoRubro}_0`);
77
+ const negativo = this.mapObject.get(`${negativoRubro}_0`);
78
+ let destino = this.mapObject.get(`${destinoRubro}_0`);
79
+ for (let i = 1; i <= this.rango; i++) {
80
+ destino[`Monto${i}`] = positivo[`Monto${i}`] - negativo[`Monto${i}`];
81
+ destino[`Monto${i}`] = Math.round(destino[`Monto${i}`] * 100) / 100;
82
+ }
83
+ };
84
+ this.proyectarIngreso = () => {
85
+ const rowTotalIngresoM = this.data.FlujoProyectadoMensualMap.get('ACT_CNFL_49000_0');
86
+ const rowVariacionIngresos = this.data.FlujoProyectadoAnualMap.get('ACT_CNFL_30001_0');
87
+ const rowIngresos = this.data.FlujoProyectadoAnualMap.get('ACT_CNFL_40001_0');
88
+ const I10 = 0;
89
+ for (let i = 1; i <= this.rango; i++) {
90
+ if (i == 1) {
91
+ rowIngresos[`Monto${i}`] = rowTotalIngresoM[`Monto12`] * (1 + rowVariacionIngresos[`Monto${i}`] + I10);
92
+ }
93
+ else {
94
+ rowIngresos[`Monto${i}`] = rowIngresos[`Monto${i - 1}`] * (1 + rowVariacionIngresos[`Monto${i}`] + I10);
95
+ }
96
+ rowIngresos[`Monto${i}`] = Math.round(rowIngresos[`Monto${i}`] * 100) / 100;
97
+ }
98
+ };
99
+ this.proyectarCosto = () => {
100
+ const rowIngresos = this.data.FlujoProyectadoAnualMap.get('ACT_CNFL_40001_0');
101
+ const rowVariacionCostos = this.data.FlujoProyectadoAnualMap.get('ACT_CNFL_30002_0');
102
+ const rowCosto = this.data.FlujoProyectadoAnualMap.get('ACT_CNFL_50001_0');
103
+ for (let i = 1; i <= this.rango; i++) {
104
+ if (i == 1) {
105
+ rowCosto[`Monto1`] = (rowIngresos[`Monto1`] * rowCosto.MontoCajaPercent / 100) + (1 + rowVariacionCostos[`Monto${i}`]);
106
+ }
107
+ else {
108
+ rowCosto[`Monto${i}`] = rowIngresos[`Monto${i - 1}`] * (1 + rowVariacionCostos[`Monto${i}`]);
109
+ }
110
+ rowCosto[`Monto${i}`] = Math.round(rowCosto[`Monto${i}`] * 100) / 100;
111
+ }
112
+ };
113
+ this.proyectarGasto = () => {
114
+ const rowIngresos = this.data.FlujoProyectadoAnualMap.get('ACT_CNFL_40001_0');
115
+ const rowVariacionGastos = this.data.FlujoProyectadoAnualMap.get('ACT_CNFL_30003_0');
116
+ const rowGasto = this.data.FlujoProyectadoAnualMap.get('ACT_CNFL_60001_0');
117
+ for (let i = 1; i <= this.rango; i++) {
118
+ if (i == 1) {
119
+ rowGasto[`Monto1`] = (rowIngresos[`Monto1`] *
120
+ rowGasto.MontoCajaPercent / 100) + (1 + rowVariacionGastos[`Monto${i}`]);
121
+ }
122
+ else {
123
+ rowGasto[`Monto${i}`] = rowIngresos[`Monto${i - 1}`] * (1 + rowVariacionGastos[`Monto${i}`]);
124
+ }
125
+ rowGasto[`Monto${i}`] = Math.round(rowGasto[`Monto${i}`] * 100) / 100;
126
+ }
127
+ };
128
+ this.moverDetalledesdeMensual = () => {
129
+ let filter = this.data.FlujoProyectadoMensual.filter((item) => item.RubroId == 'ACT_CNFL_61001' || item.RubroId == 'ACT_CNFL_73000');
130
+ filter.map((item) => {
131
+ if (this.mapObject.has(`${item.RubroId}_CLONE_${item.UUID}`)) {
132
+ let detalle = this.mapObject.get(`${item.RubroId}_CLONE_${item.UUID}`);
133
+ if (detalle.Monto1 == 0)
134
+ detalle.Monto1 = item.MontoTotal;
135
+ }
136
+ });
137
+ };
138
+ this.calcularTotalDetalle = (sumandosArray, total) => {
139
+ const rows = this.array.filter((item) => sumandosArray.includes(item.RubroId) && item.Comprar == 'NO');
140
+ let destino = this.mapObject.get(`${total}_0`);
141
+ rows.map((item) => {
142
+ for (let i = 1; i <= this.rango; i++) {
143
+ destino[`Monto${i}`] += parseFloat(item[`Monto${i}`]);
144
+ destino[`Monto${i}`] = Math.round(destino[`Monto${i}`] * 100) / 100;
145
+ }
146
+ });
147
+ };
148
+ this.calcularPorcentajeIngresCostos = () => {
149
+ const rowTotalIngresoM = this.data.FlujoProyectadoMensualMap.get('ACT_CNFL_49000_0');
150
+ let costos = this.array.filter((item) => item.RubroId === 'ACT_CNFL_50001' || item.RubroId === 'ACT_CNFL_50002' ||
151
+ item.RubroId === 'ACT_CNFL_60001' || item.RubroId === 'ACT_CNFL_60002');
152
+ costos.map((item) => {
153
+ if (rowTotalIngresoM.MontoTotal != 0)
154
+ item.MontoCajaPercent = Math.round(parseFloat(item.MontoTotal) /
155
+ parseFloat(rowTotalIngresoM.MontoTotal) * 100);
156
+ else
157
+ item.MontoCajaPercent = 0;
158
+ if (item.RubroId == 'ACT_CNFL_50001' || item.RubroId === 'ACT_CNFL_60001') {
159
+ this.data.FlujoProyectadoAnualMap.get(`${item.RubroId}_0`).MontoCajaPercent = item.MontoCajaPercent;
160
+ }
161
+ });
162
+ this.data.FlujoProyectadoMensualMap.get('ACT_CNFL_82300_0').MontoCajaPercent = this.data.CajaInicial;
163
+ };
164
+ this.calcularOtrosIngresosAnuales = () => {
165
+ const rowOtrosIngresosM = this.data.FlujoProyectadoMensualMap.get('ACT_CNFL_70001_0');
166
+ let rowOtrosIngresosA = this.mapObject.get('ACT_CNFL_70001_0');
167
+ for (let i = 1; i <= this.rango; i++) {
168
+ rowOtrosIngresosA[`Monto${i}`] = rowOtrosIngresosM.MontoTotal;
169
+ rowOtrosIngresosA[`Monto${i}`] = Math.round(rowOtrosIngresosA[`Monto${i}`] * 100) / 100;
170
+ }
171
+ };
172
+ this.calcularGastosFamiliares = () => {
173
+ const rowOtrosIngresosM = this.data.FlujoProyectadoMensualMap.get('ACT_CNFL_70002_0');
174
+ let rowGastosFamiliares = this.mapObject.get('ACT_CNFL_70002_0');
175
+ if (!rowGastosFamiliares.MontoCajaPercent)
176
+ rowGastosFamiliares.MontoCajaPercent = 0;
177
+ for (let i = 1; i <= this.rango; i++) {
178
+ if (i == 1) {
179
+ rowGastosFamiliares[`Monto${i}`] = rowOtrosIngresosM.MontoTotal *
180
+ (1 + (rowGastosFamiliares.MontoCajaPercent / 100));
181
+ }
182
+ else {
183
+ rowGastosFamiliares[`Monto${i}`] = rowGastosFamiliares[`Monto${i - 1}`] *
184
+ (1 + (rowGastosFamiliares.MontoCajaPercent / 100));
185
+ }
186
+ rowGastosFamiliares[`Monto${i}`] = Math.round(rowGastosFamiliares[`Monto${i}`] * 100) / 100;
187
+ }
188
+ };
189
+ this.calcularFlujoInversiones = () => {
190
+ const rowInversionM = this.data.FlujoProyectadoMensualMap.get('ACT_CNFL_80001_0');
191
+ const rowAportePropioM = this.data.FlujoProyectadoMensualMap.get('ACT_CNFL_80002_0');
192
+ let rowInversion = this.mapObject.get('ACT_CNFL_80001_0');
193
+ let rowAportePropio = this.mapObject.get('ACT_CNFL_80002_0');
194
+ if (rowInversion.Monto1 > 0)
195
+ rowInversion.Monto1 = rowInversionM.MontoTotal;
196
+ if (rowAportePropio.Monto1 > 0)
197
+ rowAportePropio.Monto1 = rowAportePropioM.MontoTotal;
198
+ };
199
+ this.calcularFlujoAcumuladoAnual = () => {
200
+ let flujoAcumulado = this.mapObject.get('ACT_CNFL_82300_0');
201
+ let excedente = this.mapObject.get('ACT_CNFL_82110_0');
202
+ let saldoInicialCaja = this.mapObject.get('ACT_CNFL_82120_0');
203
+ saldoInicialCaja.Monto1 = this.data.CajaInicial;
204
+ for (let i = 1; i <= this.rango; i++) {
205
+ if (i == 1) {
206
+ flujoAcumulado[`Monto${i}`] = parseFloat(excedente[`Monto${i}`]) +
207
+ parseFloat(saldoInicialCaja[`Monto${i}`]);
208
+ }
209
+ else {
210
+ flujoAcumulado[`Monto${i}`] = parseFloat(flujoAcumulado[`Monto${i - 1}`]) +
211
+ parseFloat(excedente[`Monto${i}`]);
212
+ }
213
+ flujoAcumulado[`Monto${i}`] = Math.round(flujoAcumulado[`Monto${i}`] * 100) / 100;
214
+ }
215
+ };
216
+ this.adicionarCapacidadPago = () => {
217
+ const utilidadNeta = this.mapObject.get('ACT_CNFL_82300_0');
218
+ const cuotaBdp = this.mapObject.get('ACT_CNFL_82300_0');
219
+ let result = {};
220
+ let acumulado = 0;
221
+ for (let i = 2; i <= this.rango; i++) {
222
+ if (utilidadNeta[`Monto${i}`] && utilidadNeta[`Monto${i}`] > 0)
223
+ result[`Monto${i}`] = cuotaBdp[`Monto${i}`] / utilidadNeta[`Monto${i}`];
224
+ else
225
+ result[`Monto${i}`] = 0;
226
+ result[`Monto${i}`] = Math.round(result[`Monto${i}`] * 100) / 100;
227
+ acumulado += result[`Monto${i}`];
228
+ }
229
+ result.PorcentajePromedio = Math.round(acumulado / this.rango * 100) / 100;
230
+ result.CapacidadMaxima = (acumulado / (this.rango - 1)) > 80 ? 'VERDADERO' : 'FALSO';
231
+ this.data.Pie = result;
232
+ };
233
+ this.getFlujoEfectivo = () => {
234
+ const tasaDescuento = Math.round(parseFloat(this.data.Parametros.TasaDescuento) * 100) / 100;
235
+ const totalFlujoInversiones = this.data.FlujoProyectadoAnualMap.get('ACT_CNFL_80900_0');
236
+ const excedente = this.data.FlujoProyectadoAnualMap.get('ACT_CNFL_82110_0');
237
+ let result = [];
238
+ let resultMap = new Map();
239
+ let indiceRentabilidad = 0;
240
+ for (let i = 0; i <= this.rango; i++) {
241
+ let value = {};
242
+ if (i == 0) {
243
+ value = { Anno: i, FlujoDeEfectivo: totalFlujoInversiones[`Monto1`] * -1, FlujoEfectivoDescontado: 0 };
244
+ result.push(value);
245
+ resultMap.set(i, value);
246
+ }
247
+ else {
248
+ value = { Anno: i, FlujoDeEfectivo: excedente[`Monto${i}`], FlujoEfectivoDescontado: 0 };
249
+ result.push(value);
250
+ resultMap.set(i, value);
251
+ }
252
+ value.FlujoEfectivoDescontado = value.FlujoDeEfectivo / Math.pow(1 + tasaDescuento, i);
253
+ indiceRentabilidad += value.FlujoDeEfectivo / Math.pow(1 + tasaDescuento, i);
254
+ }
255
+ indiceRentabilidad = Math.round((indiceRentabilidad / totalFlujoInversiones[`Monto1`]) * 100) / 100;
256
+ const VAN = calcularVAN(tasaDescuento, result.filter((item => item.Anno > 0)).
257
+ map((item) => item.FlujoDeEfectivo), totalFlujoInversiones[`Monto1`]);
258
+ const TIR = calcularTIR(result.map(item => item.FlujoDeEfectivo), totalFlujoInversiones[`Monto1`]);
259
+ let vars = [{ Descripcion: 'Tasa de descuento', Valor: tasaDescuento },
260
+ { Descripcion: 'VAN', Valor: VAN },
261
+ { Descripcion: 'TIR', Valor: TIR },
262
+ { Descripcion: 'Índice de Rentabilidad', Valor: indiceRentabilidad },
263
+ ];
264
+ this.data.FlujoDeEfectivo = result;
265
+ this.data.FlujoEfectivoVars = vars;
266
+ };
267
+ this.tipo = tipo;
268
+ if (tipo == 'MENSUAL') {
269
+ this.rango = 12;
270
+ this.mapObject = data.FlujoProyectadoMensualMap;
271
+ this.array = data.FlujoProyectadoMensual;
272
+ this.data = data;
273
+ }
274
+ else {
275
+ this.rango = data.DatosEvaluacion.CantidadProyeccion;
276
+ this.mapObject = data.FlujoProyectadoAnualMap;
277
+ this.array = data.FlujoProyectadoAnual;
278
+ this.data = data;
279
+ }
280
+ }
281
+ }
282
+ exports.default = FlujoConstructor;
283
+ const calcularVAN = (tasaDescuento, flujosDeCaja, inversionInicial) => {
284
+ let VAN = -inversionInicial;
285
+ for (let t = 0; t < flujosDeCaja.length; t++) {
286
+ VAN += flujosDeCaja[t] / Math.pow(1 + tasaDescuento, t + 1);
287
+ }
288
+ return VAN;
289
+ };
290
+ const calcularTIR = (flujosDeCaja, inversionInicial, precision = 1e-6) => {
291
+ let tasaMin = 0;
292
+ let tasaMax = 1;
293
+ let tasaMed = (tasaMin + tasaMax) / 2;
294
+ while ((tasaMax - tasaMin) > precision) {
295
+ let VAN = calcularVAN(tasaMed, flujosDeCaja, inversionInicial);
296
+ if (VAN > 0) {
297
+ tasaMin = tasaMed;
298
+ }
299
+ else {
300
+ tasaMax = tasaMed;
301
+ }
302
+ tasaMed = (tasaMin + tasaMax) / 2;
303
+ }
304
+ return tasaMed;
305
+ };
@@ -0,0 +1,2 @@
1
+ export declare const getSupuestosEmpty: (data: any) => any[];
2
+ export declare const getSupuestos: (data: any) => any[];
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSupuestos = exports.getSupuestosEmpty = void 0;
4
+ const getSupuesto = (descripcion, descripcionCorta, valores) => {
5
+ let obj = {};
6
+ obj.Descripcion = descripcion;
7
+ obj.Corta = descripcionCorta;
8
+ obj.TipoValorFlujo = 'OTROS';
9
+ obj.ValorFlujo = 0;
10
+ obj.OtrosValor = 0;
11
+ obj.Valores = valores;
12
+ return obj;
13
+ };
14
+ const getValoresVacios = (rango) => {
15
+ let array = [];
16
+ for (let i = 1; i <= rango; i++) {
17
+ array.push({
18
+ Correlativo: i,
19
+ CorrelativoDesc: '-',
20
+ MontoPorcentual: 0
21
+ });
22
+ }
23
+ return array;
24
+ };
25
+ const getRango = (data) => {
26
+ let rango = 0;
27
+ if (!data.DatosEvaluacion || !data.DatosEvaluacion.Gestiones || data.DatosEvaluacion.Gestiones.length == 0)
28
+ throw new Error('No se encontraron gestiones definidas en la evaluación');
29
+ else
30
+ rango = data.DatosEvaluacion.Gestiones.length;
31
+ return rango;
32
+ };
33
+ const getSupuestosEmpty = (data) => {
34
+ let array = [];
35
+ let rango = getRango(data);
36
+ array.push(getSupuesto("% DE COSTOS", "% Costo", getValoresVacios(rango)));
37
+ array.push(getSupuesto("% GASTOS OPERATIVOS", "% G.O.", getValoresVacios(rango)));
38
+ return array;
39
+ };
40
+ exports.getSupuestosEmpty = getSupuestosEmpty;
41
+ const getSupuestos = (data) => {
42
+ let rango = getRango(data);
43
+ if (!data.balance || !data.balance.eerr)
44
+ return (0, exports.getSupuestosEmpty)(data);
45
+ let CostoVentasValuePercent = data.balance.eerr.find((item) => item.RubroId === 'ACT_CN_41001');
46
+ let GastosAdmValuePercent = data.balance.eerr.find((item) => item.RubroId === 'ACT_CN_43001');
47
+ CostoVentasValuePercent =
48
+ getSupuesto("% DE COSTOS", "% Costo", getValores(CostoVentasValuePercent, rango));
49
+ GastosAdmValuePercent =
50
+ getSupuesto("% GASTOS OPERATIVOS", "% G.O.", getValores(GastosAdmValuePercent, rango));
51
+ CostoVentasValuePercent = calcularValorOtros(CostoVentasValuePercent, data.FlujoProyectadoMensualMap, 'COSTOS');
52
+ GastosAdmValuePercent = calcularValorOtros(GastosAdmValuePercent, data.FlujoProyectadoMensualMap, 'GASTOS');
53
+ CostoVentasValuePercent = calcularValores(CostoVentasValuePercent, data.Parametros.PorcentajeCostos, rango);
54
+ GastosAdmValuePercent = calcularValores(GastosAdmValuePercent, data.Parametros.PorcentajeGastos, rango);
55
+ return [CostoVentasValuePercent, GastosAdmValuePercent];
56
+ };
57
+ exports.getSupuestos = getSupuestos;
58
+ const calcularValorOtros = (supuesto, data, tipo) => {
59
+ let rubroId = '';
60
+ if (tipo == 'COSTOS')
61
+ rubroId = 'ACT_CNFL_50001_0';
62
+ else if (tipo == 'GASTOS')
63
+ rubroId = 'ACT_CNFL_60001_0';
64
+ supuesto.OtrosValor =
65
+ data.get(rubroId).MontoCajaPercent;
66
+ return supuesto;
67
+ };
68
+ const calcularValores = (supuesto, tipoConfig, rango) => {
69
+ if (tipoConfig === 'PROMEDIO') {
70
+ let suma = supuesto.Valores.reduce((acc, item) => {
71
+ acc += item.MontoPorcentual;
72
+ return acc;
73
+ }, 0);
74
+ suma = Math.round(suma * 100) / 100;
75
+ supuesto.ValorFlujo = suma;
76
+ return supuesto;
77
+ }
78
+ else if (tipoConfig === 'PROMEDIO2') {
79
+ let suma = supuesto.Valores.reduce((acc, item) => {
80
+ if (item.Correlativo == rango - 1 || item.Correlativo == rango)
81
+ acc += item.MontoPorcentual;
82
+ return acc;
83
+ }, 0);
84
+ suma = Math.round(suma * 100) / 100;
85
+ supuesto.ValorFlujo = suma;
86
+ return;
87
+ }
88
+ else if (tipoConfig === 'MENOR') {
89
+ let menor = supuesto.Valores.reduce((acc, item) => {
90
+ if (acc > item.MontoPorcentual || acc == -1)
91
+ acc = item.MontoPorcentual;
92
+ return acc;
93
+ }, -1);
94
+ menor = Math.round(menor * 100) / 100;
95
+ supuesto.ValorFlujo = menor;
96
+ }
97
+ else if (tipoConfig === 'ULTIMA_GES') {
98
+ let ultimo = supuesto.Valores.reduce((acc, item) => {
99
+ if (item.Correlativo == rango)
100
+ acc = item.MontoPorcentual;
101
+ return acc;
102
+ }, 0);
103
+ ultimo = Math.round(ultimo * 100) / 100;
104
+ supuesto.ValorFlujo = ultimo;
105
+ }
106
+ else if (tipoConfig === 'OTROS') {
107
+ supuesto.ValorFlujo = supuesto.OtrosValor;
108
+ }
109
+ return supuesto;
110
+ };
111
+ const getValores = (rowEERR, rango) => {
112
+ if (!rowEERR)
113
+ return getValoresVacios(rango);
114
+ let array = [];
115
+ for (let i = 1; i <= rango; i++) {
116
+ array.push({
117
+ Correlativo: i,
118
+ CorrelativoDesc: rowEERR[`Fecha_${i}`],
119
+ MontoPorcentual: parseFloat(rowEERR[`MontoEmpresa_${i}`])
120
+ });
121
+ }
122
+ return array;
123
+ };
@@ -1,12 +1,4 @@
1
- export declare const getSupuestosEmpty: (data: any) => any[];
1
+ export declare const getFlujoMap: (data: any, rango: number) => any;
2
+ export declare const calcularFlujoMensual: (data: any) => void;
3
+ export declare const calcularFlujoAnual: (data: any) => void;
2
4
  export declare const getHistoricoFlujoCaja: (data: any) => any[];
3
- export declare const getFlujoEfectivo: (data: any) => {
4
- Anno: number;
5
- FlujoDeEfectivo: number;
6
- FlujoEfectivoDescontado: number;
7
- }[];
8
- export declare const getFlujoEfectivoExtra: (data: any) => {
9
- Descripcion: string;
10
- Valor: number;
11
- }[];
12
- export declare const getPieFlujo: (data: any) => any;
@@ -1,73 +1,39 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPieFlujo = exports.getFlujoEfectivoExtra = exports.getFlujoEfectivo = exports.getHistoricoFlujoCaja = exports.getSupuestosEmpty = void 0;
4
- const getSupuestos = (descripcion, descripcionCorta) => {
5
- let obj = {};
6
- obj.Descripcion = descripcion;
7
- obj.Corta = descripcionCorta;
8
- obj.TipoValorFlujo = 'OTROS';
9
- obj.ValorFlujo = 0;
10
- obj.OtrosValor = 0;
11
- obj.Valores = [
12
- {
13
- Correlativo: 1,
14
- CorrelativoDesc: '01-20XX',
15
- MontoPorcentual: 0
6
+ exports.getHistoricoFlujoCaja = exports.calcularFlujoAnual = exports.calcularFlujoMensual = exports.getFlujoMap = void 0;
7
+ const flujoConstructor_1 = __importDefault(require("./flujoCalculos/flujoConstructor"));
8
+ const getFlujoMap = (data, rango) => {
9
+ return data.reduce((acc, item) => {
10
+ let key = `${item.RubroId}_0`;
11
+ if (item.Clasificador == 'HABM' || item.Clasificador == 'DETL')
12
+ key = `${item.RubroId}_${item.UUID ? item.UUID : '0'}`;
13
+ for (let i = 1; i <= rango; i++) {
14
+ item[`Monto${i}`] = parseFloat(item[`Monto${i}`]);
16
15
  }
17
- ];
18
- return obj;
16
+ acc.set(key, item);
17
+ return acc;
18
+ }, new Map());
19
+ };
20
+ exports.getFlujoMap = getFlujoMap;
21
+ const calcularFlujoMensual = (data) => {
22
+ const flujoConstructor = new flujoConstructor_1.default('MENSUAL', data);
23
+ flujoConstructor.calcularFlujo();
19
24
  };
20
- const getSupuestosEmpty = (data) => {
21
- let array = [];
22
- array.push(getSupuestos("% DE COSTOS", "% Costo"));
23
- array.push(getSupuestos("% GASTOS OPERATIVOS", "% G.O."));
24
- return array;
25
+ exports.calcularFlujoMensual = calcularFlujoMensual;
26
+ const calcularFlujoAnual = (data) => {
27
+ const flujoConstructor = new flujoConstructor_1.default('ANUAL', data);
28
+ flujoConstructor.calcularFlujo();
25
29
  };
26
- exports.getSupuestosEmpty = getSupuestosEmpty;
30
+ exports.calcularFlujoAnual = calcularFlujoAnual;
27
31
  const getHistoricoFlujoCaja = (data) => {
28
- const meses = ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"];
29
- const anoActual = new Date().getFullYear(); // Obtiene el año actual
30
32
  const datos = [];
31
- meses.forEach((mes, index) => {
32
- datos.push([`${mes}-${anoActual}`, 0]);
33
- });
33
+ const totalIngresos = data.FlujoProyectadoMensualMap.get('ACT_CNFL_49000_0');
34
+ for (let i = 1; i <= 12; i++) {
35
+ datos.push({ Fecha: totalIngresos[`Fecha${i}`], Monto: totalIngresos[`Monto${i}`] });
36
+ }
34
37
  return datos;
35
38
  };
36
39
  exports.getHistoricoFlujoCaja = getHistoricoFlujoCaja;
37
- const getFlujoEfectivo = (data) => {
38
- const value = [{ Anno: 0, FlujoDeEfectivo: 0, FlujoEfectivoDescontado: 0 },
39
- { Anno: 1, FlujoDeEfectivo: 0, FlujoEfectivoDescontado: 0 }];
40
- return value;
41
- };
42
- exports.getFlujoEfectivo = getFlujoEfectivo;
43
- const getFlujoEfectivoExtra = (data) => {
44
- const value = [{ Descripcion: 'Tasa de descuento', Valor: 0 },
45
- { Descripcion: 'VAN', Valor: 0 },
46
- { Descripcion: 'TIR', Valor: 0 },
47
- { Descripcion: 'Índice de Rentabilidad', Valor: 0 },
48
- ];
49
- return value;
50
- };
51
- exports.getFlujoEfectivoExtra = getFlujoEfectivoExtra;
52
- const getPieFlujo = (data) => {
53
- let result = {};
54
- result.PlazoAnnos = 0;
55
- result.CapacidadPago = 0;
56
- result.DescripcionResulta = "VERDADERO";
57
- result.PorcentajePagoPromedio = [
58
- { Correlativo: 1, MontoPorcentual: 0 },
59
- { Correlativo: 2, MontoPorcentual: 0 },
60
- { Correlativo: 3, MontoPorcentual: 0 },
61
- { Correlativo: 4, MontoPorcentual: 0 },
62
- { Correlativo: 5, MontoPorcentual: 0 },
63
- { Correlativo: 6, MontoPorcentual: 0 },
64
- { Correlativo: 7, MontoPorcentual: 0 },
65
- { Correlativo: 8, MontoPorcentual: 0 },
66
- { Correlativo: 9, MontoPorcentual: 0 },
67
- { Correlativo: 10, MontoPorcentual: 0 },
68
- { Correlativo: 11, MontoPorcentual: 0 },
69
- { Correlativo: 12, MontoPorcentual: 0 },
70
- ];
71
- return result;
72
- };
73
- exports.getPieFlujo = getPieFlujo;