bdpformulas 1.0.58 → 1.0.60

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.
@@ -1,98 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const balanceAux_calc_1 = require("../common/balanceCalculos/balanceAux.calc");
4
- const utils_1 = require("../utils");
5
4
  class BalanceAgrStrategy {
6
5
  actividades;
7
6
  camposCalculadosDefinidos;
8
7
  constructor() {
9
8
  this.actividades = [];
10
9
  this.camposCalculadosDefinidos = [
11
- {
12
- RubroId: 'ACT_CN_11001',
13
- Correlativos: 'ultima',
14
- Familiar: true,
15
- Empresa: true
16
- },
17
- {
18
- RubroId: 'ACT_CN_11002',
19
- Correlativos: 'ultima',
20
- Familiar: true,
21
- Empresa: true
22
- },
23
- {
24
- RubroId: 'ACT_CN_11003',
25
- Correlativos: 'ultima',
26
- Familiar: true,
27
- Empresa: true
28
- },
29
- {
30
- RubroId: 'ACT_CN_12001',
31
- Correlativos: 'ultima',
32
- Familiar: true,
33
- Empresa: true
34
- },
35
- {
36
- RubroId: 'ACT_CN_12002',
37
- Correlativos: 'ultima',
38
- Familiar: true,
39
- Empresa: true
40
- },
41
- {
42
- RubroId: 'ACT_CN_12003',
43
- Correlativos: 'ultima',
44
- Familiar: true,
45
- Empresa: true
46
- },
47
- {
48
- RubroId: 'ACT_CN_12004',
49
- Correlativos: 'ultima',
50
- Familiar: true,
51
- Empresa: true
52
- },
53
- {
54
- RubroId: 'ACT_CN_12005',
55
- Correlativos: 'ultima',
56
- Familiar: true,
57
- Empresa: true
58
- },
59
- {
60
- RubroId: 'ACT_CN_21001',
61
- Correlativos: 'ultima',
62
- Familiar: true,
63
- Empresa: true
64
- },
65
- {
66
- RubroId: 'ACT_CN_21002',
67
- Correlativos: 'ultima',
68
- Familiar: true,
69
- Empresa: true
70
- },
71
- {
72
- RubroId: 'ACT_CN_22001',
73
- Correlativos: 'ultima',
74
- Familiar: true,
75
- Empresa: true
76
- },
77
- {
78
- RubroId: 'ACT_CN_30001',
79
- Correlativos: '*',
80
- Familiar: true,
81
- Empresa: true
82
- },
83
- //eeff
84
- {
85
- RubroId: 'ACT_CN_40001',
86
- Correlativos: '*',
87
- Familiar: false,
88
- Empresa: true
89
- },
90
- {
91
- RubroId: 'ACT_CN_41001',
92
- Correlativos: 'ultima',
93
- Familiar: false,
94
- Empresa: true
95
- },
96
10
  {
97
11
  RubroId: 'ACT_CN_41002',
98
12
  Correlativos: '*',
@@ -105,18 +19,6 @@ class BalanceAgrStrategy {
105
19
  Familiar: false,
106
20
  Empresa: true
107
21
  },
108
- {
109
- RubroId: 'ACT_CN_43002',
110
- Correlativos: '*',
111
- Familiar: false,
112
- Empresa: true
113
- },
114
- {
115
- RubroId: 'ACT_CN_45001',
116
- Correlativos: 'ultima',
117
- Familiar: true,
118
- Empresa: false
119
- },
120
22
  {
121
23
  RubroId: 'ACT_CN_45003',
122
24
  Correlativos: 'ultima',
@@ -134,10 +36,7 @@ class BalanceAgrStrategy {
134
36
  acumuladoActividades = addAcumulado(acumuladoActividades, actividadCalculada);
135
37
  }
136
38
  data.eerrMap = calcularEERR(data.eerrMap, data.eerr, acumuladoActividades);
137
- data.camposCalculados = (0, utils_1.formatCamposCalculados)({
138
- cantidadGestiones: data.cantidadGestiones,
139
- definidos: this.camposCalculadosDefinidos
140
- });
39
+ data.camposCalculadosDefinidos = this.camposCalculadosDefinidos;
141
40
  return data;
142
41
  }
143
42
  }
@@ -1,4 +1,6 @@
1
1
  import { Strategy } from '../strategy.interface';
2
2
  export default class Balance implements Strategy {
3
+ private camposCalculadosDefinidos;
4
+ constructor();
3
5
  execute(data: any): any;
4
6
  }
@@ -28,7 +28,110 @@ const commmon = __importStar(require("./common/balance.calc"));
28
28
  const declaracionJurada_calc_1 = require("./common/declaracionJurada.calc");
29
29
  //import { setFlujoInEERR } from './common/balanceCalculos/flujoAux.calc'
30
30
  const utils_1 = require("./eeff/admFinanciera/utils");
31
+ const utils_2 = require("./utils");
31
32
  class Balance {
33
+ camposCalculadosDefinidos;
34
+ constructor() {
35
+ this.camposCalculadosDefinidos = [
36
+ {
37
+ RubroId: 'ACT_CN_11001',
38
+ Correlativos: 'ultima',
39
+ Familiar: true,
40
+ Empresa: true
41
+ },
42
+ {
43
+ RubroId: 'ACT_CN_11002',
44
+ Correlativos: 'ultima',
45
+ Familiar: true,
46
+ Empresa: true
47
+ },
48
+ {
49
+ RubroId: 'ACT_CN_11003',
50
+ Correlativos: 'ultima',
51
+ Familiar: true,
52
+ Empresa: true
53
+ },
54
+ {
55
+ RubroId: 'ACT_CN_12001',
56
+ Correlativos: 'ultima',
57
+ Familiar: true,
58
+ Empresa: true
59
+ },
60
+ {
61
+ RubroId: 'ACT_CN_12002',
62
+ Correlativos: 'ultima',
63
+ Familiar: true,
64
+ Empresa: true
65
+ },
66
+ {
67
+ RubroId: 'ACT_CN_12003',
68
+ Correlativos: 'ultima',
69
+ Familiar: true,
70
+ Empresa: true
71
+ },
72
+ {
73
+ RubroId: 'ACT_CN_12004',
74
+ Correlativos: 'ultima',
75
+ Familiar: true,
76
+ Empresa: true
77
+ },
78
+ {
79
+ RubroId: 'ACT_CN_21001',
80
+ Correlativos: 'ultima',
81
+ Familiar: true,
82
+ Empresa: true
83
+ },
84
+ {
85
+ RubroId: 'ACT_CN_21002',
86
+ Correlativos: 'ultima',
87
+ Familiar: true,
88
+ Empresa: true
89
+ },
90
+ {
91
+ RubroId: 'ACT_CN_22001',
92
+ Correlativos: 'ultima',
93
+ Familiar: true,
94
+ Empresa: true
95
+ },
96
+ {
97
+ RubroId: 'ACT_CN_22002',
98
+ Correlativos: 'ultima',
99
+ Familiar: true,
100
+ Empresa: true
101
+ },
102
+ {
103
+ RubroId: 'ACT_CN_30001',
104
+ Correlativos: '*',
105
+ Familiar: true,
106
+ Empresa: true
107
+ },
108
+ //eeff
109
+ {
110
+ RubroId: 'ACT_CN_40001',
111
+ Correlativos: '*',
112
+ Familiar: false,
113
+ Empresa: true
114
+ },
115
+ {
116
+ RubroId: 'ACT_CN_41001',
117
+ Correlativos: 'ultima',
118
+ Familiar: false,
119
+ Empresa: true
120
+ },
121
+ {
122
+ RubroId: 'ACT_CN_43002',
123
+ Correlativos: '*',
124
+ Familiar: false,
125
+ Empresa: true
126
+ },
127
+ {
128
+ RubroId: 'ACT_CN_45001',
129
+ Correlativos: 'ultima',
130
+ Familiar: true,
131
+ Empresa: false
132
+ }
133
+ ];
134
+ }
32
135
  execute(data) {
33
136
  const result = {};
34
137
  const balanceClone = balanceCalc.trasponer(commmon.clone(data.balance));
@@ -41,12 +144,18 @@ class Balance {
41
144
  //setFlujoInEERR(data)
42
145
  if (data.strategy != null)
43
146
  data = data.strategy.execute(data);
44
- result.camposCalculados = data.camposCalculados;
147
+ result.camposCalculados = (0, utils_2.formatCamposCalculados)({
148
+ cantidadGestiones: data.cantidadGestiones,
149
+ definidos: [
150
+ ...this.camposCalculadosDefinidos,
151
+ ...data.camposCalculadosDefinidos
152
+ ]
153
+ });
45
154
  delete data.eerrMap;
46
155
  data.balance = Array.from(balanceMap.values());
47
156
  data.eerr = Array.from(eerrMap.values());
48
157
  result.balance = calcularBalance(data.balance, data.cantidadGestiones);
49
- result.eerr = calcularEERR(data.eerr, data.cantidadGestiones);
158
+ result.eerr = calcularEERR(data.eerr, data.cantidadGestiones, data.tipoConsolidado);
50
159
  result.DataOriginal = {
51
160
  balance: balanceClone,
52
161
  eerr: eerrClone
@@ -124,23 +233,25 @@ function calcularCapital(datos, cantidadGestiones) {
124
233
  el.MontoTotal = el.MontoEmpresa + el.MontoFamiliar;
125
234
  });
126
235
  }
127
- const calcularEERR = (eerr, cantidadGestiones) => {
236
+ const calcularEERR = (eerr, cantidadGestiones, tipoConsolidado) => {
128
237
  let i = 0;
129
- //calcular porcentajes
130
- calcularPorcentajes({
131
- rubroDatos: 'ACT_CN_40001',
132
- rubroPorcentajes: 'ACT_CN_41001',
133
- rubroDestino: 'ACT_CN_41002',
134
- cantidadGestiones,
135
- datos: eerr
136
- });
137
- calcularPorcentajes({
138
- rubroDatos: 'ACT_CN_40001',
139
- rubroPorcentajes: 'ACT_CN_43001',
140
- rubroDestino: 'ACT_CN_43002',
141
- cantidadGestiones,
142
- datos: eerr
143
- });
238
+ if (tipoConsolidado !== 'GANADERIA') {
239
+ //calcular porcentajes
240
+ calcularPorcentajes({
241
+ rubroDatos: 'ACT_CN_40001',
242
+ rubroPorcentajes: 'ACT_CN_41001',
243
+ rubroDestino: 'ACT_CN_41002',
244
+ cantidadGestiones,
245
+ datos: eerr
246
+ });
247
+ calcularPorcentajes({
248
+ rubroDatos: 'ACT_CN_40001',
249
+ rubroPorcentajes: 'ACT_CN_43001',
250
+ rubroDestino: 'ACT_CN_43002',
251
+ cantidadGestiones,
252
+ datos: eerr
253
+ });
254
+ }
144
255
  let result = eerr.map((item) => {
145
256
  i++;
146
257
  const esGrupo = item.Clasificador == 'P' || item.Clasificador == 'C';
@@ -185,9 +296,30 @@ const calcularEERR = (eerr, cantidadGestiones) => {
185
296
  //Utilidad neta
186
297
  result = adicionarCuenta('ACT_CN_46000', 'ACT_CN_47000', result);
187
298
  result = adicionarCuenta('ACT_CN_46001', 'ACT_CN_47000', result, true);
299
+ if (tipoConsolidado === 'GANADERIA') {
300
+ calcularCostoVentasPecuario(result, cantidadGestiones);
301
+ }
188
302
  result = balanceCalc.trasponer(result);
189
303
  return result;
190
304
  };
305
+ function calcularCostoVentasPecuario(datos, cantidadGestiones) {
306
+ const totalIngresos = datos.find((el) => el.RubroId === 'ACT_CN_40003' &&
307
+ el.Correlativo === cantidadGestiones);
308
+ const costos = datos.find((el) => el.RubroId === 'ACT_CN_41002.1' &&
309
+ el.Correlativo === cantidadGestiones);
310
+ const costosPorcentaje = datos.find((el) => el.RubroId === 'ACT_CN_41001' &&
311
+ el.Correlativo === cantidadGestiones);
312
+ if (costosPorcentaje) {
313
+ const montoTotal = (0, utils_1.ourParseFloat)(totalIngresos?.MontoEmpresa);
314
+ if (montoTotal) {
315
+ costosPorcentaje.MontoEmpresa =
316
+ ((0, utils_1.ourParseFloat)(costos?.MontoEmpresa) / montoTotal) * 100;
317
+ costosPorcentaje.MontoTotal =
318
+ (0, utils_1.ourParseFloat)(costosPorcentaje.MontoFamiliar) +
319
+ costosPorcentaje.MontoEmpresa;
320
+ }
321
+ }
322
+ }
191
323
  function calcularPorcentajes({ rubroDatos, rubroPorcentajes, datos, cantidadGestiones, rubroDestino }) {
192
324
  const porcentajes = datos.filter((el) => el.RubroId === rubroPorcentajes);
193
325
  const montos = datos.filter((el) => el.RubroId === rubroDatos);
@@ -197,10 +329,14 @@ function calcularPorcentajes({ rubroDatos, rubroPorcentajes, datos, cantidadGest
197
329
  const monto = montos.find((el) => el.Correlativo === item.Correlativo);
198
330
  if (item.Correlativo === cantidadGestiones) {
199
331
  if (porcentaje) {
200
- porcentaje.MontoEmpresa =
201
- ((0, utils_1.ourParseFloat)(item.MontoEmpresa) /
202
- (0, utils_1.ourParseFloat)(monto?.MontoEmpresa)) *
203
- 100;
332
+ const divisor = (0, utils_1.ourParseFloat)(monto?.MontoEmpresa);
333
+ if (divisor) {
334
+ porcentaje.MontoEmpresa =
335
+ ((0, utils_1.ourParseFloat)(item.MontoEmpresa) / divisor) * 100;
336
+ }
337
+ else {
338
+ porcentaje.MontoEmpresa = 0;
339
+ }
204
340
  }
205
341
  }
206
342
  else {
@@ -243,7 +379,7 @@ const adicionarCuenta = (origen, destino, datos, isNegative = false) => {
243
379
  return datos;
244
380
  };
245
381
  const sumarizarCuenta = (rubros, datos) => {
246
- const filtrados = datos.filter((item) => rubros.includes(item.RubroPadreId));
382
+ const filtrados = datos.filter((item) => !item.Subcuenta && rubros.includes(item.RubroPadreId));
247
383
  const grupos = datos.filter((item) => rubros.includes(item.RubroId));
248
384
  const suma = filtrados.reduce((acc, item) => {
249
385
  const key = `${item.RubroPadreId}_${item.Correlativo}`;
@@ -1,4 +1,3 @@
1
1
  export declare const clone: (data: any) => any;
2
2
  export declare const getBalanceHashMap: (balance: any) => any;
3
3
  export declare const trasponer: (data: any) => any;
4
- export declare const calcularPorcentaje: (balance: any) => void;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.calcularPorcentaje = exports.trasponer = exports.getBalanceHashMap = exports.clone = void 0;
3
+ exports.trasponer = exports.getBalanceHashMap = exports.clone = void 0;
4
4
  const clone = (data) => {
5
5
  return JSON.parse(JSON.stringify(data));
6
6
  };
@@ -60,5 +60,3 @@ const trasponer = (data) => {
60
60
  return result;
61
61
  };
62
62
  exports.trasponer = trasponer;
63
- const calcularPorcentaje = (balance) => { };
64
- exports.calcularPorcentaje = calcularPorcentaje;
@@ -11,14 +11,14 @@ export default class FlujoConstructor {
11
11
  limpiarCamposCalculados: () => void;
12
12
  calcularFlujoCajaMensual(): void;
13
13
  calcularFlujoAcumuladoMensual: (data: any) => void;
14
- calcularTotal: (sumandosArray: string[], total: string) => void;
14
+ calcularTotal: (sumandosArray: string[], total: string, data?: any[]) => void;
15
15
  replicarCuenta: (cuentaOrigen: string, cuentaDestino: string) => void;
16
16
  calcularResta: (positivoRubro: string, negativoRubro: string, destinoRubro: string) => void;
17
17
  proyectarIngreso: () => void;
18
18
  proyectarCosto: () => void;
19
19
  proyectarGasto: () => void;
20
20
  agregarQuitarClones: () => void;
21
- moverDetalledesdeMensual: () => void;
21
+ moverDetalleDesdeMensual: () => void;
22
22
  calcularTotalDetalle: (sumandosArray: string[], total: string) => void;
23
23
  calcularPorcentajeIngresCostos: () => void;
24
24
  calcularOtrosIngresosAnuales: () => void;
@@ -26,26 +26,42 @@ class FlujoConstructor {
26
26
  calcularFlujo = () => {
27
27
  this.limpiarCamposCalculados();
28
28
  if (this.tipo == 'ANUAL') {
29
- this.proyectarIngreso();
30
- this.proyectarCosto();
31
- this.proyectarGasto();
29
+ if (this.data.TipoConsolidado !== 'GANADERIA') {
30
+ this.proyectarIngreso();
31
+ this.proyectarCosto();
32
+ this.proyectarGasto();
33
+ }
32
34
  this.agregarQuitarClones();
33
35
  this.setearCamposAnual();
34
36
  // this.moverDetalledesdeMensual()
35
37
  /* this.calcularTotalDetalle(['ACT_CNFL_73000'], 'ACT_CNFL_73900')
36
38
  this.calcularTotalDetalle(['ACT_CNFL_61001'], 'ACT_CNFL_61900') */
37
- this.calcularOtrosIngresosAnuales();
38
- this.calcularGastosFamiliares();
39
+ if (this.data.TipoConsolidado !== 'GANADERIA') {
40
+ this.calcularOtrosIngresosAnuales();
41
+ this.calcularGastosFamiliares();
42
+ }
39
43
  this.calcularFlujoInversiones();
40
44
  }
41
45
  this.calcularTotal(['ACT_CNFL_40001', 'ACT_CNFL_40002'], 'ACT_CNFL_49000'); //Total Ingresos
42
46
  this.calcularTotal(['ACT_CNFL_50001', 'ACT_CNFL_50002'], 'ACT_CNFL_59000'); //Total Costos
43
47
  this.calcularResta('ACT_CNFL_49000', 'ACT_CNFL_59000', 'ACT_CNFL_59999'); //Utilidad Bruta
44
- this.calcularTotal(['ACT_CNFL_61001'], 'ACT_CNFL_61900'); //subtotal Gastos Operativos
48
+ if (this.tipo === 'MENSUAL') {
49
+ //subtotal Gastos Operativos
50
+ this.calcularTotal(['ACT_CNFL_61001'], 'ACT_CNFL_61900');
51
+ }
52
+ else {
53
+ this.calcularTotal(['ACT_CNFL_61001'], 'ACT_CNFL_61900', this.array.filter((el) => el.Comprar == 'NO'));
54
+ }
45
55
  this.calcularTotal(['ACT_CNFL_60001', 'ACT_CNFL_60002', 'ACT_CNFL_61900'], 'ACT_CNFL_69000'); //Total Gastos Operativos
46
56
  this.calcularResta('ACT_CNFL_59999', 'ACT_CNFL_69000', 'ACT_CNFL_69999'); //Utilidad Operativa
47
57
  this.calcularResta('ACT_CNFL_70001', 'ACT_CNFL_70002', 'ACT_CNFL_72000'); //Total Otros Ingresos e Egresos
48
- this.calcularTotal(['ACT_CNFL_73000'], 'ACT_CNFL_73900');
58
+ if (this.tipo === 'MENSUAL') {
59
+ // subtotal gastos financieros
60
+ this.calcularTotal(['ACT_CNFL_73000'], 'ACT_CNFL_73900');
61
+ }
62
+ else {
63
+ this.calcularTotal(['ACT_CNFL_73000'], 'ACT_CNFL_73900', this.array.filter((el) => el.Comprar == 'NO'));
64
+ }
49
65
  this.calcularResta('ACT_CNFL_72000', 'ACT_CNFL_73900', 'ACT_CNFL_79000'); //Resultado Otros Ingresos e Egresos
50
66
  this.calcularTotal(['ACT_CNFL_69999', 'ACT_CNFL_79000'], 'ACT_CNFL_79999'); //Utilidad Neta
51
67
  if (this.tipo == 'MENSUAL') {
@@ -60,17 +76,21 @@ class FlujoConstructor {
60
76
  this.calcularFlujoAcumuladoMensual(this.data);
61
77
  }
62
78
  else if (this.tipo == 'ANUAL') {
79
+ //this.moverDetalleDesdeMensual()
63
80
  this.calcularExcedenteDeficit();
64
81
  this.calcularFlujoAcumuladoAnual();
65
82
  this.adicionarCapacidadPago();
66
83
  this.getFlujoEfectivo();
67
84
  }
68
- this.array.map((item) => {
69
- item.MontoTotal = 0;
70
- for (let i = 1; i <= this.rango; i++) {
71
- item.MontoTotal += parseFloat(item[`Monto${i}`]);
85
+ this.array.forEach((item) => {
86
+ const avoided = ['ACT_CNFL_82300'];
87
+ if (!avoided.includes(item.RubroId)) {
88
+ item.MontoTotal = 0;
89
+ for (let i = 1; i <= this.rango; i++) {
90
+ item.MontoTotal += parseFloat(item[`Monto${i}`]);
91
+ }
92
+ item.MontoTotal = Math.round(item.MontoTotal * 100) / 100;
72
93
  }
73
- item.MontoTotal = Math.round(item.MontoTotal * 100) / 100;
74
94
  });
75
95
  if (this.tipo == 'MENSUAL') {
76
96
  this.calcularPorcentajeIngresCostos();
@@ -143,9 +163,11 @@ class FlujoConstructor {
143
163
  rowAcumulado[`Monto${i}`] =
144
164
  Math.round(rowAcumulado[`Monto${i}`] * 100) / 100;
145
165
  }
166
+ rowAcumulado.MontoTotal = rowAcumulado[`Monto${this.rango}`];
146
167
  };
147
- calcularTotal = (sumandosArray, total) => {
148
- const rows = this.array.filter((item) => sumandosArray.includes(item.RubroId));
168
+ calcularTotal = (sumandosArray, total, data = this.array) => {
169
+ const rows = data.filter((item) => item.IndicadorABM !== 'B' &&
170
+ sumandosArray.includes(item.RubroId));
149
171
  const destino = this.mapObject.get(`${total}_0`);
150
172
  rows.map((item) => {
151
173
  for (let i = 1; i <= this.rango; i++) {
@@ -191,22 +213,11 @@ class FlujoConstructor {
191
213
  rowIngresos[`Monto${i}`] = anterior * (1 + variacion + I10);
192
214
  }
193
215
  }
194
- if (this.data.TipoConsolidad == 'GANADERIA' &&
195
- this.data.ParametrosEngorde.Conclusion == 'DESARROLLO_HATO') {
196
- for (let i = 1; i <= this.rango; i++) {
197
- rowIngresos[`Monto${i}`] =
198
- this.data.ParametrosEngorde.SumaDesarrolloAnual[`C-${i}`] *
199
- (1 + rowVariacionIngresos[`Monto${i}`] + I10);
200
- rowIngresos[`Monto${i}`] =
201
- Math.round(rowIngresos[`Monto${i}`] * 100) / 100;
202
- }
203
- }
204
216
  };
205
217
  proyectarCosto = () => {
206
218
  const rowIngresos = this.data.FlujoProyectadoAnualMap.get('ACT_CNFL_40001_0');
207
219
  const rowVariacionCostos = this.data.FlujoProyectadoAnualMap.get('ACT_CNFL_30002_0');
208
220
  const rowCosto = this.data.FlujoProyectadoAnualMap.get('ACT_CNFL_50001_0');
209
- const rowTotalIngresoM = this.data.FlujoProyectadoMensualMap.get('ACT_CNFL_49000_0');
210
221
  for (let i = 1; i <= this.rango; i++) {
211
222
  const variacion = (0, utils_1.ourParseFloat)(rowVariacionCostos[`Monto${i}`]) / 100;
212
223
  if (i == 1) {
@@ -223,25 +234,6 @@ class FlujoConstructor {
223
234
  (0, utils_1.ourParseFloat)(rowCosto[`Monto${i - 1}`]) * (1 + variacion);
224
235
  }
225
236
  }
226
- if (this.data.TipoConsolidad == 'GANADERIA' &&
227
- this.data.ParametrosEngorde.Conclusion != 'DESARROLLO_HATO') {
228
- for (let i = 1; i <= this.rango; i++) {
229
- if (i == 1) {
230
- rowCosto[`Monto1`] =
231
- ((rowTotalIngresoM[`MontoTotal`] *
232
- rowCosto.MontoCajaPercent) /
233
- 100) *
234
- (1 + rowVariacionCostos[`Monto${i}`]);
235
- }
236
- else {
237
- rowCosto[`Monto${i}`] =
238
- rowIngresos[`Monto${i - 1}`] *
239
- (1 + rowVariacionCostos[`Monto${i}`]);
240
- }
241
- rowCosto[`Monto${i}`] =
242
- Math.round(rowCosto[`Monto${i}`] * 100) / 100;
243
- }
244
- }
245
237
  };
246
238
  proyectarGasto = () => {
247
239
  const rowIngresos = this.data.FlujoProyectadoAnualMap.get('ACT_CNFL_40001_0');
@@ -265,29 +257,34 @@ class FlujoConstructor {
265
257
  }
266
258
  };
267
259
  agregarQuitarClones = () => {
268
- const filter = this.data.FlujoProyectadoMensual.filter((item) => item.Clasificador == 'DETL' || item.Clasificador == 'HABM');
260
+ const filter = this.data.FlujoProyectadoMensual.filter((item) => item.IndicadorABM !== 'B' &&
261
+ (item.Clasificador == 'DETL' || item.Clasificador == 'HABM'));
269
262
  filter.map((item) => {
270
- if (!this.mapObject.has(`${item.RubroId}_CLONE_${item.UUID}`)) {
271
- const newItem = {
272
- ActividadId: item.ActividadId,
273
- RubroId: item.RubroId,
274
- RubroPadreId: item.RubroPadreId,
275
- Descripcion: item.Descripcion,
276
- UUID: `CLONE_${item.UUID}`,
277
- Clasificador: item.Clasificador,
278
- Entidad: item.Entidad,
279
- Operacion: item.Operacion,
280
- Comprar: item.Comprar,
281
- Variable: item.Variable,
282
- IndicadorABM: item.IndicadorABM,
283
- MontoCajaPercent: item.MontoCajaPercent
284
- };
263
+ const key = `${item.RubroId}_CLONE_${item.UUID}`;
264
+ const UUID = `CLONE_${item.UUID}`;
265
+ const clone = {
266
+ ...item,
267
+ UUID
268
+ };
269
+ let total = 0;
270
+ for (let i = 1; i <= this.rango; i++) {
271
+ clone[`Monto${i}`] = 0;
272
+ total += (0, utils_1.ourParseFloat)(item[`Monto${i}`]);
273
+ }
274
+ clone['Monto1'] = total;
275
+ item.MontoTotal = total;
276
+ if (!this.mapObject.has(key)) {
285
277
  for (let i = 1; i <= this.rango; i++) {
286
- newItem[`Monto${i}`] = 0;
278
+ clone[`Monto${i}`] = 0;
287
279
  }
288
- this.array.push(newItem);
289
- this.mapObject.set(`${item.RubroId}_CLONE_${item.UUID}`, newItem);
280
+ this.array.push(clone);
281
+ }
282
+ else {
283
+ const index = this.array.findIndex((el) => el.UUID === UUID);
284
+ if (index >= 0)
285
+ this.array[index] = clone;
290
286
  }
287
+ this.mapObject.set(`${item.RubroId}_CLONE_${item.UUID}`, clone);
291
288
  });
292
289
  const anuales = this.array.filter((item) => item.Clasificador == 'DETL' || item.Clasificador == 'HABM');
293
290
  for (const anualItem of anuales) {
@@ -299,14 +296,17 @@ class FlujoConstructor {
299
296
  }
300
297
  }
301
298
  };
302
- moverDetalledesdeMensual = () => {
303
- const filter = this.data.FlujoProyectadoMensual.filter((item) => item.RubroId == 'ACT_CNFL_61001' ||
304
- item.RubroId == 'ACT_CNFL_73000');
305
- filter.map((item) => {
299
+ moverDetalleDesdeMensual = () => {
300
+ const mensuales = this.data.FlujoProyectadoMensual.filter((item) => item.IndicadorABM !== 'B' &&
301
+ (item.RubroId == 'ACT_CNFL_61001' ||
302
+ item.RubroId == 'ACT_CNFL_73000'));
303
+ mensuales.forEach((item) => {
306
304
  if (this.mapObject.has(`${item.RubroId}_CLONE_${item.UUID}`)) {
307
305
  const detalle = this.mapObject.get(`${item.RubroId}_CLONE_${item.UUID}`);
308
- if (detalle.Monto1 == 0)
309
- detalle.Monto1 = item.MontoTotal;
306
+ detalle.Descripcion = item.Descripcion;
307
+ detalle.Comprar = item.Comprar;
308
+ detalle.Operacion = item.Operacion;
309
+ detalle.Monto1 = item.MontoTotal;
310
310
  }
311
311
  });
312
312
  };
@@ -322,19 +322,21 @@ class FlujoConstructor {
322
322
  });
323
323
  };
324
324
  calcularPorcentajeIngresCostos = () => {
325
- const filaIngresos = this.array.find((el) => el.RubroId === 'ACT_CNFL_40001');
326
- const filaCostos = this.array.find((el) => el.RubroId === 'ACT_CNFL_50001');
327
- const filaGastos = this.array.find((el) => el.RubroId === 'ACT_CNFL_60001');
328
- if (filaCostos) {
329
- filaCostos.MontoCajaPercent = Math.abs(((0, utils_1.ourParseFloat)(filaCostos.MontoTotal) /
330
- (0, utils_1.ourParseFloat)(filaIngresos?.MontoTotal)) *
331
- 100);
332
- }
333
- if (filaGastos) {
334
- filaGastos.MontoCajaPercent = Math.abs(((0, utils_1.ourParseFloat)(filaGastos.MontoTotal) /
335
- (0, utils_1.ourParseFloat)(filaIngresos?.MontoTotal)) *
336
- 100);
337
- }
325
+ const filasIngresos = this.array.filter((el) => el.RubroId.includes('ACT_CNFL_40001'));
326
+ const filasCostos = this.array.filter((el) => el.RubroId.includes('ACT_CNFL_50001'));
327
+ const filasGastos = this.array.filter((el) => el.RubroId.includes('ACT_CNFL_60001'));
328
+ filasCostos.forEach((el, i) => {
329
+ const ingresoMonto = (0, utils_1.ourParseFloat)(filasIngresos.at(i)?.MontoTotal);
330
+ if (ingresoMonto > 0) {
331
+ el.MontoCajaPercent = Math.abs(((0, utils_1.ourParseFloat)(el.MontoTotal) / ingresoMonto) * 100);
332
+ }
333
+ });
334
+ filasGastos.forEach((el, i) => {
335
+ const ingresoMonto = (0, utils_1.ourParseFloat)(filasIngresos.at(i)?.MontoTotal);
336
+ if (ingresoMonto > 0) {
337
+ el.MontoCajaPercent = Math.abs(((0, utils_1.ourParseFloat)(el.MontoTotal) / ingresoMonto) * 100);
338
+ }
339
+ });
338
340
  const otrosIngresos = this.array.filter((el) => el.RubroId === 'ACT_CNFL_40002' && el.IndicadorABM !== 'B');
339
341
  const otrosCostos = this.array.filter((el) => el.RubroId === 'ACT_CNFL_50002' && el.IndicadorABM !== 'B');
340
342
  otrosCostos.forEach((el, i) => {
@@ -468,7 +470,12 @@ class FlujoConstructor {
468
470
  indiceRentabilidad += valueFlujo;
469
471
  }
470
472
  }
471
- indiceRentabilidad /= -totalFlujoInversiones[`Monto1`];
473
+ if (totalFlujoInversiones['Monto1']) {
474
+ indiceRentabilidad /= -totalFlujoInversiones[`Monto1`];
475
+ }
476
+ else {
477
+ indiceRentabilidad = 0;
478
+ }
472
479
  const VAN = calcularVAN(tasaDescuento, result
473
480
  .filter((item) => item.Anno > 0)
474
481
  .map((item) => item.FlujoDeEfectivo), totalFlujoInversiones[`Monto1`]);