bdpformulas 1.0.84 → 1.0.86

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,9 +1,44 @@
1
+ import { AdministracionFinancieraCalcData } from '../../models/eeff/admFinanciera';
1
2
  import { Strategy } from '../../strategy.interface';
3
+ export interface SupuestosStrategyData {
4
+ CantidadProyeccion: number;
5
+ CantidadGestiones: number;
6
+ Supuestos: any[];
7
+ EEFF: {
8
+ balance: any[];
9
+ eerr: any[];
10
+ };
11
+ BalanceProyectado: {
12
+ Balance: any[];
13
+ EERR: any[];
14
+ FlujoCaja: any[];
15
+ };
16
+ AdministracionFinancieraData: AdministracionFinancieraCalcData;
17
+ CamposCalculados: Record<string, any>;
18
+ }
2
19
  export default class SupuestosStrategy implements Strategy {
3
- cantidadGestiones: number;
4
- data: any;
20
+ data: SupuestosStrategyData | null;
21
+ private cantidadProyeccion;
22
+ private cantidadGestiones;
5
23
  constructor();
6
24
  private anadirPrecalculo;
7
25
  private cleanNumber;
8
- execute(data: any): any;
26
+ execute(data: SupuestosStrategyData): SupuestosStrategyData;
27
+ private setDepreciacion;
28
+ private setDepreciacionLeasing;
29
+ private actualizarCampo;
30
+ private esCampoCalculado;
31
+ private quitarCampoCalculado;
32
+ private agregarCampoCalculado;
33
+ private applyAdministracionFinancieraData;
34
+ private setRotacionDiasInventario;
35
+ private setMontoIncremento;
36
+ private getTotalesActivacionLeasing;
37
+ private getSumaProyeccionUntil;
38
+ private setBalanceData;
39
+ private setCostoDeVentas;
40
+ private setGastosOperativos;
41
+ private setRotacionDiasPorCobrar;
42
+ private setRotacionDiasPorPagar;
43
+ private setCoeficienteDepreciacion;
9
44
  }
@@ -1,25 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const lodash_1 = require("lodash");
4
+ const admFinanciera_1 = require("../../models/eeff/admFinanciera");
5
+ const supuestos_1 = require("../../models/eeff/supuestos");
6
+ const utils_1 = require("./admFinanciera/utils");
7
+ const balance_1 = require("../../models/eeff/balance");
3
8
  class SupuestosStrategy {
4
- cantidadGestiones;
5
9
  data;
10
+ cantidadProyeccion;
11
+ cantidadGestiones;
6
12
  constructor() {
7
- this.cantidadGestiones = 0;
8
- this.data = {};
13
+ this.data = null;
14
+ this.cantidadGestiones = -1;
15
+ this.cantidadProyeccion = -1;
9
16
  }
10
17
  //@ts-ignore
11
18
  anadirPrecalculo(origen, rubroOrigen, rubroDestino, percent = false) {
12
- if (this.cantidadGestiones != 0) {
19
+ if (this.data?.CantidadGestiones != 0) {
13
20
  //@ts-ignore
14
21
  const origenRow = origen.find((item) => item.RubroId == rubroOrigen);
15
22
  //@ts-ignore
16
23
  const destinoRow = this.data.find((item) => item.RubroId == rubroDestino);
17
24
  if (!percent)
18
- destinoRow.Gestion1 = this.cleanNumber(origenRow[`Gestion${this.cantidadGestiones}`]);
25
+ destinoRow.Gestion1 = this.cleanNumber(origenRow[`Gestion${this.data?.CantidadGestiones}`]);
19
26
  else {
20
- destinoRow.Gestion1 = this.cleanNumber(origenRow[`Gestion${this.cantidadGestiones}%`] / 100);
21
- destinoRow.Gestion1 =
22
- Math.round(destinoRow.Gestion1 * 100) / 100;
27
+ destinoRow.Gestion1 = this.cleanNumber(origenRow[`Gestion${this.data?.CantidadGestiones}%`] / 100);
23
28
  }
24
29
  }
25
30
  }
@@ -29,49 +34,227 @@ class SupuestosStrategy {
29
34
  else {
30
35
  if (data.toString().includes(','))
31
36
  data = data.toString().replace(/,/g, '');
32
- return Math.round(parseFloat(data) * 100) / 100;
37
+ return (0, utils_1.ourParseFloat)(data);
33
38
  }
34
39
  };
35
40
  execute(data) {
36
- this.data = data.Supuestos;
37
- this.cantidadGestiones = data.CantidadGestiones;
38
- const rowDeprecCoef = data.Supuestos.find((item) => item.RubroId == 'ACT_SUP_10402');
39
- const rowDeprecValue = data.Supuestos.find((item) => item.RubroId == 'ACT_SUP_10403');
40
- const rowDeprecCoefLeasing = data.Supuestos.find((item) => item.RubroId == 'ACT_SUP_10404');
41
- const rowDeprecValueLeasing = data.Supuestos.find((item) => item.RubroId == 'ACT_SUP_10405');
42
- for (let i = 1; i <= data.CantidadProyeccion; i++) {
43
- const activosFijosNetos = data.BalanceProyectado.find((item) => item.Correlativo == i && item.RubroId == 'BP_ACT_EF_12003');
44
- const activosPorArrendamiento = data.BalanceProyectado.find((item) => item.Correlativo == i && item.RubroId == 'BP_ACT_EF_12004');
45
- if (rowDeprecValue != null)
46
- rowDeprecValue[`Gestion${i}`] =
47
- this.cleanNumber(rowDeprecCoef[`Gestion${i}`]) *
48
- this.cleanNumber(activosFijosNetos.Monto);
49
- if (rowDeprecValueLeasing != null)
50
- rowDeprecValueLeasing[`Gestion${i}`] =
51
- this.cleanNumber(rowDeprecCoefLeasing[`Gestion${i}`]) *
52
- this.cleanNumber(activosPorArrendamiento.Monto);
53
- }
54
- // this.anadirPrecalculo(data.EEFF.eerr, 'ACT_EF_42000', 'ACT_SUP_10101')
55
- //this.anadirPrecalculo(data.EEFF.eerr, 'ACT_EF_44003', 'ACT_SUP_10104')
56
- // this.anadirPrecalculo(
57
- // data.EEFF.eerr,
58
- // 'ACT_EF_42001',
59
- // 'ACT_SUP_10201',
60
- // true
61
- // )
62
- // this.anadirPrecalculo(
63
- // data.EEFF.eerr,
64
- // 'ACT_EF_43001',
65
- // 'ACT_SUP_10202',
66
- // true
67
- // )
68
- // this.anadirPrecalculo(data.EEFF.eerr, 'ACT_EF_44004', 'ACT_SUP_10203')
69
- // this.anadirPrecalculo(
70
- // data.EEFF.balance,
71
- // 'ACT_EF_11008',
72
- // 'ACT_SUP_20102'
73
- // )
41
+ this.data = data;
42
+ if (data.CantidadGestiones)
43
+ this.cantidadGestiones = data.CantidadGestiones;
44
+ if (data.CantidadProyeccion)
45
+ this.cantidadProyeccion = data.CantidadProyeccion;
46
+ this.setBalanceData();
47
+ this.setDepreciacion();
48
+ this.setDepreciacionLeasing();
49
+ this.applyAdministracionFinancieraData();
74
50
  return this.data;
75
51
  }
52
+ setDepreciacion() {
53
+ const rowDeprecCoef = this.data?.Supuestos.find((item) => item.RubroId == 'ACT_SUP_10402');
54
+ for (let i = 1; i <= this.cantidadProyeccion; i++) {
55
+ const activosFijosNetos = this.data?.BalanceProyectado.Balance.find((item) => item.RubroId == 'BP_ACT_EF_12003');
56
+ this.actualizarCampo(supuestos_1.SupuestosRubro.Depreciación, i, this.cleanNumber(rowDeprecCoef[`Gestion${i}`]) *
57
+ this.cleanNumber(activosFijosNetos?.[`Gestion${i}`]));
58
+ }
59
+ }
60
+ setDepreciacionLeasing() {
61
+ const rowDeprecCoefLeasing = this.data?.Supuestos.find((item) => item.RubroId ==
62
+ supuestos_1.SupuestosRubro.Coeficiente_de_Depreciación_Operaciones_de_Leasing);
63
+ const totalesActivacionLeasing = this.getTotalesActivacionLeasing();
64
+ const activosPorArrendamiento = this.data?.BalanceProyectado.Balance.find((item) => item.RubroId == 'BP_ACT_EF_12004');
65
+ for (let i = 1; i <= this.cantidadProyeccion; i++) {
66
+ this.actualizarCampo(supuestos_1.SupuestosRubro.Depreciación_Operaciones_Leasing, i, this.cleanNumber(rowDeprecCoefLeasing[`Gestion${i}`]) *
67
+ (this.cleanNumber(activosPorArrendamiento?.[`Gestion${i}`]) +
68
+ this.getSumaProyeccionUntil(totalesActivacionLeasing, i)));
69
+ }
70
+ }
71
+ actualizarCampo(rubroId, correlativo, valor) {
72
+ const row = this.data?.Supuestos.find((el) => el.RubroId == rubroId);
73
+ if (row) {
74
+ const value = (0, utils_1.ourParseFloat)(row[`Gestion${correlativo}`]);
75
+ if (!value ||
76
+ (value && this.esCampoCalculado(rubroId, correlativo))) {
77
+ row[`Gestion${correlativo}`] = valor;
78
+ this.agregarCampoCalculado(rubroId, correlativo, valor);
79
+ }
80
+ else {
81
+ this.quitarCampoCalculado(rubroId, correlativo);
82
+ }
83
+ }
84
+ }
85
+ esCampoCalculado(rubroId, correlativo) {
86
+ return !!this.data?.CamposCalculados[rubroId]?.[`Gestion${correlativo}`];
87
+ }
88
+ quitarCampoCalculado(rubroId, correlativo) {
89
+ if (this.data?.CamposCalculados[rubroId]?.[`Gestion${correlativo}`]) {
90
+ delete this.data.CamposCalculados[rubroId][`Gestion${correlativo}`];
91
+ if ((0, lodash_1.isEmpty)(this.data.CamposCalculados[rubroId])) {
92
+ delete this.data.CamposCalculados[rubroId];
93
+ }
94
+ }
95
+ }
96
+ agregarCampoCalculado(rubroId, correlativo, valor) {
97
+ (0, lodash_1.merge)(this.data?.CamposCalculados, {
98
+ [rubroId]: { [`Gestion${correlativo}`]: valor }
99
+ });
100
+ }
101
+ applyAdministracionFinancieraData() {
102
+ this.setMontoIncremento();
103
+ }
104
+ setRotacionDiasInventario() {
105
+ const realizables = this.data?.EEFF.balance.find((el) => el.RubroId == balance_1.EEFFBalanceRubro.Realizables_Inventarios);
106
+ const aplicaciones = this.data?.AdministracionFinancieraData.ProyeccionAplicaciones;
107
+ const koLineaCredito = aplicaciones?.find((el) => el.RubroId ==
108
+ admFinanciera_1.AplicacionesRubroEnum['KO - Línea de Crédito 100% KO']);
109
+ const koPrestamoDirecto = aplicaciones?.find((el) => el.RubroId == admFinanciera_1.AplicacionesRubroEnum['KO - Prestamo Directo']);
110
+ const kiKoMixta = aplicaciones?.find((el) => el.RubroId ==
111
+ admFinanciera_1.AplicacionesRubroEnum['KI - KO - Línea de Crédito Mixta']);
112
+ const rotacionDiasInventario = this.data?.Supuestos.find((el) => el.RubroId == supuestos_1.SupuestosRubro.Rotación_Días_Inventario);
113
+ for (let i = 1; i <= this.cantidadProyeccion; i++) {
114
+ let val = 0;
115
+ if (i === 1) {
116
+ val =
117
+ (0, utils_1.ourParseFloat)(realizables?.[`Gestion${this.cantidadGestiones}`]) +
118
+ (0, utils_1.ourParseFloat)(koLineaCredito?.[`Gestion${i}`]) +
119
+ (0, utils_1.ourParseFloat)(koPrestamoDirecto?.[`Gestion${i}`]);
120
+ }
121
+ else {
122
+ val =
123
+ (0, utils_1.ourParseFloat)(rotacionDiasInventario?.[`Gestion${i - 1}`]) +
124
+ (0, utils_1.ourParseFloat)(koLineaCredito?.[`Gestion${i}`]) +
125
+ (0, utils_1.ourParseFloat)(koPrestamoDirecto?.[`Gestion${i}`]) +
126
+ (0, utils_1.ourParseFloat)(kiKoMixta?.[`Gestion${i}`]);
127
+ }
128
+ this.actualizarCampo(supuestos_1.SupuestosRubro.Rotación_Días_Inventario, i, val);
129
+ }
130
+ }
131
+ setMontoIncremento() {
132
+ const aplicaciones = this.data?.AdministracionFinancieraData.ProyeccionAplicaciones;
133
+ const kiPrestamoDirecto = aplicaciones?.find((el) => el.RubroId == admFinanciera_1.AplicacionesRubroEnum['KI - Prestamo Directo']);
134
+ const kiKoMixta = aplicaciones?.find((el) => el.RubroId ==
135
+ admFinanciera_1.AplicacionesRubroEnum['KI - KO - Línea de Crédito Mixta']);
136
+ this.actualizarCampo(supuestos_1.SupuestosRubro.Monto_de_Incremento_decir_en_Inversiones_en_Activos_Fijos, 1, (0, utils_1.ourParseFloat)(kiPrestamoDirecto?.[`Gestion1`]) +
137
+ (0, utils_1.ourParseFloat)(kiKoMixta?.[`Gestion1`]));
138
+ }
139
+ getTotalesActivacionLeasing() {
140
+ return (this.data?.AdministracionFinancieraData.PrestamoLeasing.filter((el) => el.IndicadorABM !== 'B' && el.Clasificador !== 'T').reduce((acc, el) => {
141
+ for (let i = 1; i <= this.cantidadProyeccion; i++) {
142
+ acc[`Gestion${i}`] =
143
+ (0, utils_1.ourParseFloat)(acc[`Gestion${i}`]) +
144
+ (0, utils_1.ourParseFloat)(el.ActivacionesOperacion?.[`Gestion${i}`]);
145
+ }
146
+ return acc;
147
+ }, {}) ?? {});
148
+ }
149
+ getSumaProyeccionUntil(proyeccion, until) {
150
+ let sum = 0;
151
+ for (let i = 1; i <= until; i++) {
152
+ sum += (0, utils_1.ourParseFloat)(proyeccion[`Gestion${i}`]);
153
+ }
154
+ return sum;
155
+ }
156
+ setBalanceData() {
157
+ //costo de ventas/ventas
158
+ this.setCostoDeVentas();
159
+ //gastos operativos/ventas
160
+ this.setGastosOperativos();
161
+ //rotacion dias cuentas por cobrar
162
+ this.setRotacionDiasPorCobrar();
163
+ //rotacion dias inventario
164
+ this.setRotacionDiasInventario();
165
+ //rotacion dias cuentas por pagar
166
+ this.setRotacionDiasPorPagar();
167
+ //coef depreciacion
168
+ this.setCoeficienteDepreciacion();
169
+ }
170
+ setCostoDeVentas() {
171
+ const costoMercaderia = this.data?.EEFF.eerr.find((el) => el.RubroId ==
172
+ balance_1.EEFFEstadoResultadosRubro.Costo_de_Mercadería_Vendida);
173
+ const costoVentas = this.data?.Supuestos.find((el) => el.RubroId == supuestos_1.SupuestosRubro.Costo_de_VentasVentas);
174
+ if (costoMercaderia) {
175
+ for (let i = 1; i <= this.cantidadProyeccion; i++) {
176
+ let val = 0;
177
+ if (i > 1) {
178
+ val = (0, utils_1.ourParseFloat)(costoVentas?.[`Gestion${i - 1}`]);
179
+ }
180
+ else {
181
+ val =
182
+ (0, utils_1.ourParseFloat)(costoMercaderia[`Gestion${this.cantidadGestiones}%`]) / 100;
183
+ }
184
+ this.actualizarCampo(supuestos_1.SupuestosRubro.Costo_de_VentasVentas, i, val);
185
+ }
186
+ }
187
+ }
188
+ setGastosOperativos() {
189
+ const gastosOperativos = this.data?.EEFF.eerr.find((el) => el.RubroId ==
190
+ balance_1.EEFFEstadoResultadosRubro.Gastos_Operativos_Excluyendo_Depreciaciones);
191
+ const gastosOperativosVentas = this.data?.Supuestos.find((el) => el.RubroId == supuestos_1.SupuestosRubro.Gastos_OperativosVentas);
192
+ if (gastosOperativos) {
193
+ for (let i = 1; i <= this.cantidadProyeccion; i++) {
194
+ let val = 0;
195
+ if (i > 1) {
196
+ val = (0, utils_1.ourParseFloat)(gastosOperativosVentas?.[`Gestion${i - 1}`]);
197
+ }
198
+ else {
199
+ val =
200
+ (0, utils_1.ourParseFloat)(gastosOperativos[`Gestion${this.cantidadGestiones}%`]) / 100;
201
+ }
202
+ this.actualizarCampo(supuestos_1.SupuestosRubro.Gastos_OperativosVentas, i, val);
203
+ }
204
+ }
205
+ }
206
+ setRotacionDiasPorCobrar() {
207
+ const cuentasPorCobrar = this.data?.EEFF.balance.find((el) => el.RubroId ==
208
+ balance_1.EEFFBalanceRubro.Cuentas_por_Cobrar_Comerciales_Netas_de_Incobrables);
209
+ const rotacionDiasPorCobrar = this.data?.Supuestos.find((el) => el.RubroId == supuestos_1.SupuestosRubro.Rotación_Días_Cuentas_por_Cobrar);
210
+ if (cuentasPorCobrar) {
211
+ for (let i = 1; i <= this.cantidadProyeccion; i++) {
212
+ let val = 0;
213
+ if (i > 1) {
214
+ val = (0, utils_1.ourParseFloat)(rotacionDiasPorCobrar?.[`Gestion${i - 1}`]);
215
+ }
216
+ else {
217
+ val = (0, utils_1.ourParseFloat)(cuentasPorCobrar[`Gestion${this.cantidadGestiones}`]);
218
+ }
219
+ this.actualizarCampo(supuestos_1.SupuestosRubro.Rotación_Días_Cuentas_por_Cobrar, i, val);
220
+ }
221
+ }
222
+ }
223
+ setRotacionDiasPorPagar() {
224
+ const cuentasComerciales = this.data?.EEFF.balance.find((el) => el.RubroId ==
225
+ balance_1.EEFFBalanceRubro.Cuentas_Comerciales_por_Pagar_Proveedores);
226
+ const rotacionDiasPorPagar = this.data?.Supuestos.find((el) => el.RubroId == supuestos_1.SupuestosRubro.Rotación_Días_Cuentas_por_Pagar);
227
+ if (cuentasComerciales) {
228
+ for (let i = 1; i <= this.cantidadProyeccion; i++) {
229
+ let val = 0;
230
+ if (i > 1) {
231
+ val = (0, utils_1.ourParseFloat)(rotacionDiasPorPagar?.[`Gestion${i - 1}`]);
232
+ }
233
+ else {
234
+ val = (0, utils_1.ourParseFloat)(cuentasComerciales[`Gestion${this.cantidadGestiones}`]);
235
+ }
236
+ this.actualizarCampo(supuestos_1.SupuestosRubro.Rotación_Días_Cuentas_por_Pagar, i, val);
237
+ }
238
+ }
239
+ }
240
+ setCoeficienteDepreciacion() {
241
+ const depreciaciones = this.data?.EEFF.eerr.find((el) => el.RubroId == balance_1.EEFFEstadoResultadosRubro.Depreciaciones);
242
+ const activosFijosNetos = this.data?.EEFF.balance.find((el) => el.RubroId == balance_1.EEFFBalanceRubro.Activos_Fijos_Netos);
243
+ const coeficienteDepreciacion = this.data?.Supuestos.find((el) => el.RubroId == supuestos_1.SupuestosRubro.Coeficiente_de_Depreciación);
244
+ if (depreciaciones && activosFijosNetos) {
245
+ for (let i = 1; i <= this.cantidadProyeccion; i++) {
246
+ let val = 0;
247
+ if (i > 1) {
248
+ val = (0, utils_1.ourParseFloat)(coeficienteDepreciacion?.[`Gestion${i - 1}`]);
249
+ }
250
+ else {
251
+ const valDepreciaciones = (0, utils_1.ourParseFloat)(depreciaciones[`Gestion${this.cantidadGestiones}`]);
252
+ const valActivos = (0, utils_1.ourParseFloat)(activosFijosNetos[`Gestion${this.cantidadGestiones}`]);
253
+ val = valActivos ? valDepreciaciones / valActivos : 0;
254
+ }
255
+ this.actualizarCampo(supuestos_1.SupuestosRubro.Coeficiente_de_Depreciación, i, val);
256
+ }
257
+ }
258
+ }
76
259
  }
77
260
  exports.default = SupuestosStrategy;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bdpformulas",
3
- "version": "1.0.84",
3
+ "version": "1.0.86",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
package/tsconfig.json CHANGED
@@ -90,7 +90,7 @@
90
90
  // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
91
91
  // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
92
92
  // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
93
- "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
93
+ "noUnusedLocals": false, /* Enable error reporting when local variables aren't read. */
94
94
  // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
95
95
  // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
96
96
  // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */