bdpformulas 1.0.123 → 1.0.125
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/common/flujoCalculos/flujoConstructor.js +15 -5
- package/build/strategies/common/flujoCalculos/supuestos.calc.js +34 -12
- package/build/strategies/eeff/deudas.strategy.d.ts +11 -0
- package/build/strategies/eeff/deudas.strategy.js +109 -0
- package/build/strategies/production/flujoProyPrd.strategy.js +1 -1
- package/build/strategies/production/ventas.detail/estacionalidadCalc.d.ts +1 -1
- package/build/strategies/production/ventas.detail/estacionalidadCalc.js +20 -27
- package/package.json +1 -1
|
@@ -91,7 +91,9 @@ class FlujoConstructor {
|
|
|
91
91
|
item.MontoTotal += parseFloat(item[`Monto${i}`]);
|
|
92
92
|
}
|
|
93
93
|
// item.MontoTotal = Math.round(item.MontoTotal * 100) / 100
|
|
94
|
-
item.MontoTotal =
|
|
94
|
+
item.MontoTotal = this.data.TipoConsolidado === 'PRODUCCION'
|
|
95
|
+
? Math.round(item.MontoTotal * 100) / 100
|
|
96
|
+
: Math.round(item.MontoTotal);
|
|
95
97
|
}
|
|
96
98
|
});
|
|
97
99
|
if (this.tipo == 'MENSUAL') {
|
|
@@ -214,7 +216,9 @@ class FlujoConstructor {
|
|
|
214
216
|
});
|
|
215
217
|
// Redondear al final
|
|
216
218
|
for (let i = 1; i <= this.rango; i++) {
|
|
217
|
-
destino[`Monto${i}`] =
|
|
219
|
+
destino[`Monto${i}`] = this.data.TipoConsolidado === 'PRODUCCION'
|
|
220
|
+
? Math.round(destino[`Monto${i}`] * 100) / 100
|
|
221
|
+
: Math.round(destino[`Monto${i}`]);
|
|
218
222
|
}
|
|
219
223
|
};
|
|
220
224
|
replicarCuenta = (cuentaOrigen, cuentaDestino) => {
|
|
@@ -225,7 +229,9 @@ class FlujoConstructor {
|
|
|
225
229
|
destino[`Monto${i}`] = parseFloat(item[`Monto${i}`]);
|
|
226
230
|
// destino[`Monto${i}`] =
|
|
227
231
|
// Math.round(destino[`Monto${i}`] * 100) / 100
|
|
228
|
-
destino[`Monto${i}`] =
|
|
232
|
+
destino[`Monto${i}`] = this.data.TipoConsolidado === 'PRODUCCION'
|
|
233
|
+
? Math.round(destino[`Monto${i}`] * 100) / 100
|
|
234
|
+
: Math.round(destino[`Monto${i}`]);
|
|
229
235
|
}
|
|
230
236
|
});
|
|
231
237
|
};
|
|
@@ -236,7 +242,9 @@ class FlujoConstructor {
|
|
|
236
242
|
for (let i = 1; i <= this.rango; i++) {
|
|
237
243
|
destino[`Monto${i}`] = positivo[`Monto${i}`] - negativo[`Monto${i}`];
|
|
238
244
|
// destino[`Monto${i}`] = Math.round(destino[`Monto${i}`] * 100) / 100
|
|
239
|
-
destino[`Monto${i}`] =
|
|
245
|
+
destino[`Monto${i}`] = this.data.TipoConsolidado === 'PRODUCCION'
|
|
246
|
+
? Math.round(destino[`Monto${i}`] * 100) / 100
|
|
247
|
+
: Math.round(destino[`Monto${i}`]);
|
|
240
248
|
}
|
|
241
249
|
};
|
|
242
250
|
proyectarIngreso = () => {
|
|
@@ -441,7 +449,9 @@ class FlujoConstructor {
|
|
|
441
449
|
destino[`Monto${i}`] += parseFloat(item[`Monto${i}`]);
|
|
442
450
|
// destino[`Monto${i}`] =
|
|
443
451
|
// Math.round(destino[`Monto${i}`] * 100) / 100
|
|
444
|
-
destino[`Monto${i}`] =
|
|
452
|
+
destino[`Monto${i}`] = this.data.TipoConsolidado === 'PRODUCCION'
|
|
453
|
+
? Math.round(destino[`Monto${i}`] * 100) / 100
|
|
454
|
+
: Math.round(destino[`Monto${i}`]);
|
|
445
455
|
}
|
|
446
456
|
});
|
|
447
457
|
};
|
|
@@ -47,13 +47,15 @@ const getSupuestos = (data) => {
|
|
|
47
47
|
let CostoVentasValuePercent = data.balance.eerr.find((item) => item.RubroId === 'ACT_CN_41001');
|
|
48
48
|
let GastosAdmValuePercent = data.balance.eerr.find((item) => item.RubroId === 'ACT_CN_43001');
|
|
49
49
|
CostoVentasValuePercent = getSupuesto('% DE COSTOS', '% Costo', getValores(CostoVentasValuePercent, rango));
|
|
50
|
-
GastosAdmValuePercent = getSupuesto('% GASTOS OPERATIVOS', '% G.O.',
|
|
50
|
+
GastosAdmValuePercent = getSupuesto('% GASTOS OPERATIVOS', '% G.O.', data.TipoConsolidado === 'PRODUCCION'
|
|
51
|
+
? getValoresGastosProduccion(data.balance.eerr, rango)
|
|
52
|
+
: getValores(GastosAdmValuePercent, rango));
|
|
51
53
|
if (data.FlujoProyectadoMensualMap.size > 0)
|
|
52
54
|
CostoVentasValuePercent = calcularValorOtros(CostoVentasValuePercent, data.FlujoProyectadoMensualMap, 'COSTOS');
|
|
53
55
|
if (data.FlujoProyectadoMensualMap.size > 0)
|
|
54
56
|
GastosAdmValuePercent = calcularValorOtros(GastosAdmValuePercent, data.FlujoProyectadoMensualMap, 'GASTOS');
|
|
55
57
|
CostoVentasValuePercent = calcularValores(CostoVentasValuePercent, data.Parametros.PorcentajeCostos, rango);
|
|
56
|
-
GastosAdmValuePercent = calcularValores(GastosAdmValuePercent, data.Parametros.PorcentajeGastos, rango);
|
|
58
|
+
GastosAdmValuePercent = calcularValores(GastosAdmValuePercent, data.Parametros.PorcentajeGastos, rango, data.TipoConsolidado === 'PRODUCCION');
|
|
57
59
|
return [CostoVentasValuePercent, GastosAdmValuePercent];
|
|
58
60
|
};
|
|
59
61
|
exports.getSupuestos = getSupuestos;
|
|
@@ -66,22 +68,25 @@ const calcularValorOtros = (supuesto, data, tipo) => {
|
|
|
66
68
|
supuesto.OtrosValor = data.get(rubroId).MontoCajaPercent;
|
|
67
69
|
return supuesto;
|
|
68
70
|
};
|
|
69
|
-
const calcularValores = (supuesto, tipoConfig, rango) => {
|
|
71
|
+
const calcularValores = (supuesto, tipoConfig, rango, excluirCeros = false) => {
|
|
70
72
|
supuesto.TipoValorFlujo = tipoConfig;
|
|
71
73
|
if (tipoConfig === 'PROMEDIO') {
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
const valores = excluirCeros
|
|
75
|
+
? supuesto.Valores.filter((item) => item.MontoPorcentual > 0)
|
|
76
|
+
: supuesto.Valores;
|
|
77
|
+
const suma = valores.reduce((acc, item) => {
|
|
78
|
+
return acc + item.MontoPorcentual;
|
|
75
79
|
}, 0);
|
|
76
|
-
supuesto.ValorFlujo = suma /
|
|
80
|
+
supuesto.ValorFlujo = valores.length ? suma / valores.length : 0;
|
|
77
81
|
}
|
|
78
82
|
else if (tipoConfig === 'PROMEDIO2') {
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return acc;
|
|
83
|
+
const valores = supuesto.Valores.filter((item) => (item.Correlativo == rango - 1 || item.Correlativo == rango) &&
|
|
84
|
+
(!excluirCeros || item.MontoPorcentual > 0));
|
|
85
|
+
const suma = valores.reduce((acc, item) => {
|
|
86
|
+
return acc + item.MontoPorcentual;
|
|
83
87
|
}, 0);
|
|
84
|
-
|
|
88
|
+
const divisor = excluirCeros ? valores.length : 2;
|
|
89
|
+
supuesto.ValorFlujo = divisor ? suma / divisor : 0;
|
|
85
90
|
}
|
|
86
91
|
else if (tipoConfig === 'MENOR') {
|
|
87
92
|
const menor = supuesto.Valores.reduce((acc, item) => {
|
|
@@ -117,3 +122,20 @@ const getValores = (rowEERR, rango) => {
|
|
|
117
122
|
}
|
|
118
123
|
return array;
|
|
119
124
|
};
|
|
125
|
+
// El flujo de Produccion utiliza todos los gastos operativos del estado de resultados.
|
|
126
|
+
const getValoresGastosProduccion = (eerr, rango) => {
|
|
127
|
+
const gastos = eerr.find((item) => item.RubroId === 'ACT_CN_43900');
|
|
128
|
+
const ingresos = eerr.find((item) => item.RubroId === 'ACT_CN_40003');
|
|
129
|
+
const valores = getValoresVacios(rango);
|
|
130
|
+
for (const valor of valores) {
|
|
131
|
+
const gestion = valor.Correlativo;
|
|
132
|
+
const gasto = parseFloat(gastos?.[`MontoTotal_${gestion}`]);
|
|
133
|
+
const ingreso = parseFloat(ingresos?.[`MontoTotal_${gestion}`]);
|
|
134
|
+
valor.CorrelativoDesc = ingresos?.[`Fecha_${gestion}`] ?? '-';
|
|
135
|
+
valor.MontoPorcentual =
|
|
136
|
+
Number.isFinite(gasto) && Number.isFinite(ingreso) && ingreso !== 0
|
|
137
|
+
? (gasto / ingreso) * 100
|
|
138
|
+
: 0;
|
|
139
|
+
}
|
|
140
|
+
return valores;
|
|
141
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Strategy } from "../../strategy.interface";
|
|
2
|
+
export default class DeudasStrategy implements Strategy {
|
|
3
|
+
data: any;
|
|
4
|
+
constructor();
|
|
5
|
+
cleanNumber: (data: any) => number;
|
|
6
|
+
calcularDeuda(params: any): void;
|
|
7
|
+
calcularDeudaFilaPorcentaje(params: any): void;
|
|
8
|
+
calcularDeudaGridLinea(params: any): void;
|
|
9
|
+
sumarizador(params: any): any;
|
|
10
|
+
execute(data: any): any;
|
|
11
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class DeudasStrategy {
|
|
4
|
+
data;
|
|
5
|
+
constructor() {
|
|
6
|
+
this.data = {};
|
|
7
|
+
}
|
|
8
|
+
cleanNumber = (data) => {
|
|
9
|
+
if (!data)
|
|
10
|
+
return 0;
|
|
11
|
+
else
|
|
12
|
+
return Math.round(parseFloat(data) * 100) / 100;
|
|
13
|
+
};
|
|
14
|
+
calcularDeuda(params) {
|
|
15
|
+
let i = 1;
|
|
16
|
+
do {
|
|
17
|
+
let row1 = this.data.Deudas.find((item) => item.RubroId == params.rubro1 && item.Secuencia == i);
|
|
18
|
+
let row2 = this.data.Deudas.find((item) => item.RubroId == params.rubro2 && item.Secuencia == i);
|
|
19
|
+
let row3 = this.data.Deudas.find((item) => item.RubroId == params.rubro3 && item.Secuencia == i);
|
|
20
|
+
for (let j = 1; j <= this.data.CantidadProyeccion; j++) {
|
|
21
|
+
if (row3[`Monto${j}`] == 0) {
|
|
22
|
+
row3[`Monto${j}`] = (this.cleanNumber(row1[`Monto${j}`]) + this.cleanNumber(row2[`Monto${j}`])) * this.cleanNumber(row3.Variable) / 100;
|
|
23
|
+
row3[`Monto${j}`] = Math.round(row3[`Monto${j}`] * 100) / 100;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
i++;
|
|
27
|
+
} while (this.data.Deudas.find((item) => item.RubroId == params.rubro1 && item.Secuencia == i));
|
|
28
|
+
}
|
|
29
|
+
calcularDeudaFilaPorcentaje(params) {
|
|
30
|
+
let i = 1;
|
|
31
|
+
do {
|
|
32
|
+
let row1 = this.data.Deudas.find((item) => item.RubroId == params.rubro1 && item.Secuencia == i);
|
|
33
|
+
let row2 = this.data.Deudas.find((item) => item.RubroId == params.rubro2 && item.Secuencia == i);
|
|
34
|
+
let row3 = this.data.Deudas.find((item) => item.RubroId == params.rubro3 && item.Secuencia == i);
|
|
35
|
+
for (let j = 1; j <= this.data.CantidadProyeccion; j++) {
|
|
36
|
+
if (row3[`Monto${j}`] == 0) {
|
|
37
|
+
row3[`Monto${j}`] = (this.cleanNumber(row1[`Monto${j}`]) * this.cleanNumber(row2[`Monto${j}`]) / 100);
|
|
38
|
+
row3[`Monto${j}`] = Math.round(row3[`Monto${j}`] * 100) / 100;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
i++;
|
|
42
|
+
} while (this.data.Deudas.find((item) => item.RubroId == params.rubro1 && item.Secuencia == i));
|
|
43
|
+
}
|
|
44
|
+
calcularDeudaGridLinea(params) {
|
|
45
|
+
let i = 1;
|
|
46
|
+
do {
|
|
47
|
+
let rows1 = this.data.Deudas.filter((item) => item.RubroId == params.rubro1 && item.Secuencia == i);
|
|
48
|
+
let row2 = this.data.Deudas.find((item) => item.RubroId == params.rubro2 && item.Secuencia == i);
|
|
49
|
+
let row3 = this.data.Deudas.find((item) => item.RubroId == params.rubro3 && item.Secuencia == i);
|
|
50
|
+
//sumarizando
|
|
51
|
+
let row1 = rows1.reduce((sum, item) => {
|
|
52
|
+
if (!sum)
|
|
53
|
+
sum = { ...item };
|
|
54
|
+
else {
|
|
55
|
+
for (let i = 1; i <= this.data.CantidadProyeccion; i++) {
|
|
56
|
+
sum[`Monto${i}`] = this.cleanNumber(sum[`Monto${i}`]) + this.cleanNumber(item[`Monto${i}`]);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return sum;
|
|
60
|
+
}, null);
|
|
61
|
+
for (let j = 1; j <= this.data.CantidadProyeccion; j++) {
|
|
62
|
+
if (row3[`Monto${j}`] == 0) {
|
|
63
|
+
row3[`Monto${j}`] = (this.cleanNumber(row1[`Monto${j}`]) * this.cleanNumber(row2[`Monto${j}`]) / 100);
|
|
64
|
+
row3[`Monto${j}`] = Math.round(row3[`Monto${j}`] * 100) / 100;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
i++;
|
|
68
|
+
} while (this.data.Deudas.find((item) => item.RubroId == params.rubro1 && item.Secuencia == i));
|
|
69
|
+
}
|
|
70
|
+
sumarizador(params) {
|
|
71
|
+
let destino = this.data.Deudas.find((item) => item.RubroId == params.rubro2);
|
|
72
|
+
this.data.Deudas.filter((item) => item.RubroId == params.rubro1).reduce((sum, item) => {
|
|
73
|
+
if (!sum)
|
|
74
|
+
sum = { ...item };
|
|
75
|
+
else {
|
|
76
|
+
for (let i = 1; i <= this.data.CantidadProyeccion; i++) {
|
|
77
|
+
sum[`Monto${i}`] = this.cleanNumber(sum[`Monto${i}`]) + this.cleanNumber(item[`Monto${i}`]);
|
|
78
|
+
destino[`Monto${i}`] = sum[`Monto${i}`];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return sum;
|
|
82
|
+
}, null);
|
|
83
|
+
return destino;
|
|
84
|
+
}
|
|
85
|
+
execute(data) {
|
|
86
|
+
this.data = data;
|
|
87
|
+
this.calcularDeuda({ rubro1: 'ACT_DEU_10001', rubro2: 'ACT_DEU_10002', rubro3: 'ACT_DEU_10003' });
|
|
88
|
+
this.sumarizador({ rubro1: 'ACT_DEU_10001', rubro2: 'ACT_DEU_10100' });
|
|
89
|
+
this.sumarizador({ rubro1: 'ACT_DEU_10002', rubro2: 'ACT_DEU_10200' });
|
|
90
|
+
this.sumarizador({ rubro1: 'ACT_DEU_10003', rubro2: 'ACT_DEU_10300' });
|
|
91
|
+
this.calcularDeuda({ rubro1: 'ACT_DEU_20001', rubro2: 'ACT_DEU_20002', rubro3: 'ACT_DEU_20003' });
|
|
92
|
+
this.sumarizador({ rubro1: 'ACT_DEU_20001', rubro2: 'ACT_DEU_20100' });
|
|
93
|
+
this.sumarizador({ rubro1: 'ACT_DEU_20002', rubro2: 'ACT_DEU_20200' });
|
|
94
|
+
this.sumarizador({ rubro1: 'ACT_DEU_20003', rubro2: 'ACT_DEU_20300' });
|
|
95
|
+
this.calcularDeuda({ rubro1: 'ACT_DEU_30001', rubro2: 'ACT_DEU_30002', rubro3: 'ACT_DEU_30003' });
|
|
96
|
+
this.sumarizador({ rubro1: 'ACT_DEU_30001', rubro2: 'ACT_DEU_30100' });
|
|
97
|
+
this.sumarizador({ rubro1: 'ACT_DEU_30002', rubro2: 'ACT_DEU_30200' });
|
|
98
|
+
this.sumarizador({ rubro1: 'ACT_DEU_30003', rubro2: 'ACT_DEU_30300' });
|
|
99
|
+
this.calcularDeuda({ rubro1: 'ACT_DEU_40001', rubro2: 'ACT_DEU_40002', rubro3: 'ACT_DEU_40003' });
|
|
100
|
+
this.sumarizador({ rubro1: 'ACT_DEU_40001', rubro2: 'ACT_DEU_40100' });
|
|
101
|
+
this.sumarizador({ rubro1: 'ACT_DEU_40002', rubro2: 'ACT_DEU_40200' });
|
|
102
|
+
this.sumarizador({ rubro1: 'ACT_DEU_40003', rubro2: 'ACT_DEU_40300' });
|
|
103
|
+
this.calcularDeuda({ rubro1: 'ACT_DEU_41001', rubro2: 'ACT_DEU_41002', rubro3: 'ACT_DEU_41003' });
|
|
104
|
+
this.calcularDeudaGridLinea({ rubro1: 'ACT_DEU_50001', rubro2: 'ACT_DEU_50002', rubro3: 'ACT_DEU_50003' });
|
|
105
|
+
this.calcularDeudaFilaPorcentaje({ rubro1: 'ACT_DEU_60001', rubro2: 'ACT_DEU_60002', rubro3: 'ACT_DEU_60003' });
|
|
106
|
+
return this.data.Deudas;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
exports.default = DeudasStrategy;
|
|
@@ -65,7 +65,7 @@ const addIngresosM = (actividad, data) => {
|
|
|
65
65
|
for (let i = 1; i <= 12; i++) {
|
|
66
66
|
// row[`Monto${i}`] =
|
|
67
67
|
// Math.round(parseFloat(ingresos[`C-${i}`]) * 100) / 100;
|
|
68
|
-
row[`Monto${i}`] = Math.round(parseFloat(ingresos[`C-${i}`]));
|
|
68
|
+
row[`Monto${i}`] = Math.round(parseFloat(ingresos[`C-${i}`]) * 100) / 100;
|
|
69
69
|
}
|
|
70
70
|
const existente = data.FlujoProyectadoMensual.findIndex((el) => el.UUID === row.UUID);
|
|
71
71
|
if (existente >= 0) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const calcularPorcentaje: (productos: any, ingresosCalc: any, estacionalidad: any) => unknown[];
|
|
2
|
-
export declare const calcularEstacionalidad: (data: any) =>
|
|
2
|
+
export declare const calcularEstacionalidad: (data: any) => any[];
|
|
@@ -22,7 +22,7 @@ const getIngreso = (productoId, ingresosCalc, rango, criterio) => {
|
|
|
22
22
|
result += subtotal[`C-${i}`];
|
|
23
23
|
}
|
|
24
24
|
// result = Math.round(result/rango*100)/100
|
|
25
|
-
result =
|
|
25
|
+
result = result / rango;
|
|
26
26
|
}
|
|
27
27
|
else if (criterio == 'ULT') {
|
|
28
28
|
result = subtotal[`C-${rango}`];
|
|
@@ -54,32 +54,25 @@ const calcularPorcentaje = (productos, ingresosCalc, estacionalidad) => {
|
|
|
54
54
|
};
|
|
55
55
|
exports.calcularPorcentaje = calcularPorcentaje;
|
|
56
56
|
const calcularEstacionalidad = (data) => {
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
});
|
|
71
|
-
for (const key in item) {
|
|
72
|
-
if (key.startsWith('C-')) {
|
|
73
|
-
// const monto= Math.round(item[key] * item.Ingreso * 100)/100
|
|
74
|
-
const monto = Math.round(item[key] * item.Ingreso);
|
|
75
|
-
acc.get(item.ProductoId)[key] = monto;
|
|
76
|
-
acc.get(item.ProductoId).Total += monto;
|
|
77
|
-
acc.get(0)[key] += monto;
|
|
78
|
-
acc.get(0).Total += monto;
|
|
79
|
-
}
|
|
57
|
+
const filas = new Map();
|
|
58
|
+
filas.set(0, { ProductoId: 0, Descripcion: 'TOTAL', Total: 0 });
|
|
59
|
+
for (const item of data) {
|
|
60
|
+
const fila = { ProductoId: item.ProductoId, Descripcion: item.Descripcion, Total: 0 };
|
|
61
|
+
for (const key of Object.keys(item)) {
|
|
62
|
+
if (!key.startsWith('C-'))
|
|
63
|
+
continue;
|
|
64
|
+
const monto = Math.round((parseFloat(item[key]) / 100) * item.Ingreso * 100) / 100;
|
|
65
|
+
fila[key] = monto;
|
|
66
|
+
fila.Total += monto;
|
|
67
|
+
const total = filas.get(0);
|
|
68
|
+
total[key] = (total[key] ?? 0) + monto;
|
|
69
|
+
total.Total += monto;
|
|
80
70
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
71
|
+
fila.Total = Math.round(fila.Total * 100) / 100;
|
|
72
|
+
filas.set(item.ProductoId, fila);
|
|
73
|
+
}
|
|
74
|
+
const total = filas.get(0);
|
|
75
|
+
total.Total = Math.round(total.Total * 100) / 100;
|
|
76
|
+
return Array.from(filas.values());
|
|
84
77
|
};
|
|
85
78
|
exports.calcularEstacionalidad = calcularEstacionalidad;
|