bdpformulas 1.0.41 → 1.0.43
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/index.d.ts +8 -0
- package/build/index.js +10 -2
- package/build/strategies/agriculture/balanceAgr.strategy.js +1 -1
- package/build/strategies/agriculture/flujoProyAgr.strategy.js +1 -1
- package/build/strategies/common/flujoCalculos/flujoConstructor.js +22 -1
- package/build/strategies/pecuary/balancePec.strategy.d.ts +6 -0
- package/build/strategies/pecuary/balancePec.strategy.js +177 -0
- package/build/strategies/pecuary/flujoProyPec.strategy.d.ts +6 -0
- package/build/strategies/pecuary/flujoProyPec.strategy.js +207 -0
- package/build/strategies/production/balancePrd.strategy.d.ts +6 -0
- package/build/strategies/production/balancePrd.strategy.js +192 -0
- package/build/strategies/production/flujoProyPrd.strategy.d.ts +6 -0
- package/build/strategies/production/flujoProyPrd.strategy.js +162 -0
- package/build/strategies/production/ventas.detail/ingresosCalc.js +0 -2
- package/package.json +1 -1
package/build/index.d.ts
CHANGED
|
@@ -8,6 +8,10 @@ import CostosPrd from "./strategies/production/costos.strategy";
|
|
|
8
8
|
import CostosAgr from "./strategies/agriculture/costos.strategy";
|
|
9
9
|
import BalanceAgrStrategy from "./strategies/agriculture/balanceAgr.strategy";
|
|
10
10
|
import FlujoProyectadoAgrStrategy from "./strategies/agriculture/flujoProyAgr.strategy";
|
|
11
|
+
import BalancePecStrategy from "./strategies/pecuary/balancePec.strategy";
|
|
12
|
+
import FlujoProyectadoPecStrategy from "./strategies/pecuary/flujoProyPec.strategy";
|
|
13
|
+
import BalancePrdStrategy from "./strategies/production/balancePrd.strategy";
|
|
14
|
+
import FlujoProyectadoPrdStrategy from "./strategies/production/flujoProyPrd.strategy";
|
|
11
15
|
import Balance from "./strategies/balance.strategy";
|
|
12
16
|
import FlujoProyectado from "./strategies/flujoProyectado.strategy";
|
|
13
17
|
import AnalisisFinancieros from "./strategies/analisisFinancieros.strategy";
|
|
@@ -16,10 +20,14 @@ declare const Pecuario: {
|
|
|
16
20
|
Desarrollo: typeof Desarrollo;
|
|
17
21
|
VentasPec: typeof VentasPec;
|
|
18
22
|
CostosPec: typeof CostosPec;
|
|
23
|
+
BalancePecStrategy: typeof BalancePecStrategy;
|
|
24
|
+
FlujoProyectadoPecStrategy: typeof FlujoProyectadoPecStrategy;
|
|
19
25
|
};
|
|
20
26
|
declare const Produccion: {
|
|
21
27
|
VentasPrd: typeof VentasPrd;
|
|
22
28
|
CostosPrd: typeof CostosPrd;
|
|
29
|
+
BalancePrdStrategy: typeof BalancePrdStrategy;
|
|
30
|
+
FlujoProyectadoPrdStrategy: typeof FlujoProyectadoPrdStrategy;
|
|
23
31
|
};
|
|
24
32
|
declare const Agricola: {
|
|
25
33
|
CostosAgr: typeof CostosAgr;
|
package/build/index.js
CHANGED
|
@@ -15,6 +15,10 @@ const costos_strategy_2 = __importDefault(require("./strategies/production/costo
|
|
|
15
15
|
const costos_strategy_3 = __importDefault(require("./strategies/agriculture/costos.strategy"));
|
|
16
16
|
const balanceAgr_strategy_1 = __importDefault(require("./strategies/agriculture/balanceAgr.strategy"));
|
|
17
17
|
const flujoProyAgr_strategy_1 = __importDefault(require("./strategies/agriculture/flujoProyAgr.strategy"));
|
|
18
|
+
const balancePec_strategy_1 = __importDefault(require("./strategies/pecuary/balancePec.strategy"));
|
|
19
|
+
const flujoProyPec_strategy_1 = __importDefault(require("./strategies/pecuary/flujoProyPec.strategy"));
|
|
20
|
+
const balancePrd_strategy_1 = __importDefault(require("./strategies/production/balancePrd.strategy"));
|
|
21
|
+
const flujoProyPrd_strategy_1 = __importDefault(require("./strategies/production/flujoProyPrd.strategy"));
|
|
18
22
|
const balance_strategy_1 = __importDefault(require("./strategies/balance.strategy"));
|
|
19
23
|
const flujoProyectado_strategy_1 = __importDefault(require("./strategies/flujoProyectado.strategy"));
|
|
20
24
|
const analisisFinancieros_strategy_1 = __importDefault(require("./strategies/analisisFinancieros.strategy"));
|
|
@@ -22,12 +26,16 @@ const Pecuario = {
|
|
|
22
26
|
Auxiliar: anexo_strategy_1.default,
|
|
23
27
|
Desarrollo: desarrollo_strategy_1.default,
|
|
24
28
|
VentasPec: ventas_strategy_1.default,
|
|
25
|
-
CostosPec: costos_strategy_1.default
|
|
29
|
+
CostosPec: costos_strategy_1.default,
|
|
30
|
+
BalancePecStrategy: balancePec_strategy_1.default,
|
|
31
|
+
FlujoProyectadoPecStrategy: flujoProyPec_strategy_1.default
|
|
26
32
|
};
|
|
27
33
|
exports.Pecuario = Pecuario;
|
|
28
34
|
const Produccion = {
|
|
29
35
|
VentasPrd: ventas_strategy_2.default,
|
|
30
|
-
CostosPrd: costos_strategy_2.default
|
|
36
|
+
CostosPrd: costos_strategy_2.default,
|
|
37
|
+
BalancePrdStrategy: balancePrd_strategy_1.default,
|
|
38
|
+
FlujoProyectadoPrdStrategy: flujoProyPrd_strategy_1.default
|
|
31
39
|
};
|
|
32
40
|
exports.Produccion = Produccion;
|
|
33
41
|
const Agricola = {
|
|
@@ -7,7 +7,7 @@ class BalanceAgrStrategy {
|
|
|
7
7
|
}
|
|
8
8
|
execute(data) {
|
|
9
9
|
if (!this.actividades || this.actividades.length == 0)
|
|
10
|
-
|
|
10
|
+
return data;
|
|
11
11
|
let acumuladoActividades = null;
|
|
12
12
|
for (let actividad of this.actividades) {
|
|
13
13
|
let actividadCalculada = calcularActividad(actividad);
|
|
@@ -98,18 +98,27 @@ class FlujoConstructor {
|
|
|
98
98
|
const I10 = 0;
|
|
99
99
|
for (let i = 1; i <= this.rango; i++) {
|
|
100
100
|
if (i == 1) {
|
|
101
|
-
rowIngresos[`Monto${i}`] = rowTotalIngresoM[`
|
|
101
|
+
rowIngresos[`Monto${i}`] = rowTotalIngresoM[`MontoTotal`] * (1 + rowVariacionIngresos[`Monto${i}`] + I10);
|
|
102
102
|
}
|
|
103
103
|
else {
|
|
104
104
|
rowIngresos[`Monto${i}`] = rowIngresos[`Monto${i - 1}`] * (1 + rowVariacionIngresos[`Monto${i}`] + I10);
|
|
105
105
|
}
|
|
106
106
|
rowIngresos[`Monto${i}`] = Math.round(rowIngresos[`Monto${i}`] * 100) / 100;
|
|
107
107
|
}
|
|
108
|
+
if (this.data.TipoConsolidad == 'GANADERIA' &&
|
|
109
|
+
this.data.ParametrosEngorde.Conclusion == 'DESARROLLO_HATO') {
|
|
110
|
+
for (let i = 1; i <= this.rango; i++) {
|
|
111
|
+
rowIngresos[`Monto${i}`] = this.data.ParametrosEngorde.SumaDesarrolloAnual[`C-${i}`] *
|
|
112
|
+
(1 + rowVariacionIngresos[`Monto${i}`] + I10);
|
|
113
|
+
rowIngresos[`Monto${i}`] = Math.round(rowIngresos[`Monto${i}`] * 100) / 100;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
108
116
|
};
|
|
109
117
|
this.proyectarCosto = () => {
|
|
110
118
|
const rowIngresos = this.data.FlujoProyectadoAnualMap.get('ACT_CNFL_40001_0');
|
|
111
119
|
const rowVariacionCostos = this.data.FlujoProyectadoAnualMap.get('ACT_CNFL_30002_0');
|
|
112
120
|
const rowCosto = this.data.FlujoProyectadoAnualMap.get('ACT_CNFL_50001_0');
|
|
121
|
+
const rowTotalIngresoM = this.data.FlujoProyectadoMensualMap.get('ACT_CNFL_49000_0');
|
|
113
122
|
for (let i = 1; i <= this.rango; i++) {
|
|
114
123
|
if (i == 1) {
|
|
115
124
|
rowCosto[`Monto1`] = (rowIngresos[`Monto1`] * rowCosto.MontoCajaPercent / 100) + (1 + rowVariacionCostos[`Monto${i}`]);
|
|
@@ -119,6 +128,18 @@ class FlujoConstructor {
|
|
|
119
128
|
}
|
|
120
129
|
rowCosto[`Monto${i}`] = Math.round(rowCosto[`Monto${i}`] * 100) / 100;
|
|
121
130
|
}
|
|
131
|
+
if (this.data.TipoConsolidad == 'GANADERIA' &&
|
|
132
|
+
this.data.ParametrosEngorde.Conclusion != 'DESARROLLO_HATO') {
|
|
133
|
+
for (let i = 1; i <= this.rango; i++) {
|
|
134
|
+
if (i == 1) {
|
|
135
|
+
rowCosto[`Monto1`] = (rowTotalIngresoM[`MontoTotal`] * rowCosto.MontoCajaPercent / 100) * (1 + rowVariacionCostos[`Monto${i}`]);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
rowCosto[`Monto${i}`] = rowIngresos[`Monto${i - 1}`] * (1 + rowVariacionCostos[`Monto${i}`]);
|
|
139
|
+
}
|
|
140
|
+
rowCosto[`Monto${i}`] = Math.round(rowCosto[`Monto${i}`] * 100) / 100;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
122
143
|
};
|
|
123
144
|
this.proyectarGasto = () => {
|
|
124
145
|
const rowIngresos = this.data.FlujoProyectadoAnualMap.get('ACT_CNFL_40001_0');
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const gCuentaIngreso = 'ACT_CN_40001';
|
|
4
|
+
const gCuentaCosto = 'ACT_CN_41002';
|
|
5
|
+
const gCuentaGasto = 'ACT_CN_43002';
|
|
6
|
+
const gCuentaOtrosIngresosDet = 'ACT_CN_45001';
|
|
7
|
+
class BalancePecStrategy {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.actividades = [];
|
|
10
|
+
}
|
|
11
|
+
execute(data) {
|
|
12
|
+
if (!this.actividades || this.actividades.length == 0)
|
|
13
|
+
return data;
|
|
14
|
+
const cuentasIngresosCopy = getCuentasCopy(data, gCuentaIngreso);
|
|
15
|
+
const cuentasCostoCopy = getCuentasCopy(data, gCuentaCosto);
|
|
16
|
+
const cuentaGastoCopy = getCuentasCopy(data, gCuentaGasto);
|
|
17
|
+
for (let actividad of this.actividades) {
|
|
18
|
+
anadirIngresosAuxPec(actividad, data);
|
|
19
|
+
anadirIngresoVenta(actividad, data);
|
|
20
|
+
anadirCosto(actividad, data);
|
|
21
|
+
anadirGasto(actividad, data);
|
|
22
|
+
anadirOtrosIngresos(actividad, data);
|
|
23
|
+
}
|
|
24
|
+
sumarizarCuentas(`${gCuentaIngreso}.1`, gCuentaIngreso, data, cuentasIngresosCopy);
|
|
25
|
+
sumarizarCuentas(`${gCuentaCosto}.1`, gCuentaCosto, data, cuentasCostoCopy);
|
|
26
|
+
sumarizarCuentas(`${gCuentaGasto}.1`, gCuentaGasto, data, cuentaGastoCopy);
|
|
27
|
+
return data;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.default = BalancePecStrategy;
|
|
31
|
+
const getCuentasCopy = (data, rubroId) => {
|
|
32
|
+
if (!data.eerr || data.eerr.length == 0)
|
|
33
|
+
throw new Error('Debe ingresar cuentas EERR');
|
|
34
|
+
let originalData = new Map();
|
|
35
|
+
const rango = data.eerr[0].Rango;
|
|
36
|
+
for (let i = 1; i <= rango; i++) {
|
|
37
|
+
let cuentaIngreso = data.eerrMap.get(`${rubroId}_${i}`);
|
|
38
|
+
cuentaIngreso.MontoEmpresa = Math.round(parseFloat(cuentaIngreso.MontoEmpresa) * 100) / 100;
|
|
39
|
+
cuentaIngreso.MontoFamiliar = Math.round(parseFloat(cuentaIngreso.MontoFamiliar) * 100) / 100;
|
|
40
|
+
originalData.set(`${rubroId}_${i}`, Object.assign({}, cuentaIngreso));
|
|
41
|
+
}
|
|
42
|
+
//console.log('originalData '+rubroId,Array.from(originalData.keys()) )
|
|
43
|
+
return originalData;
|
|
44
|
+
};
|
|
45
|
+
const anadirIngresosAuxPec = (actividad, data) => {
|
|
46
|
+
const rango = data.eerr[0].Rango;
|
|
47
|
+
for (let i = 1; i <= rango - 1; i++) {
|
|
48
|
+
const cuentaIngreso = data.eerrMap.get(`${gCuentaIngreso}_${i}`);
|
|
49
|
+
let copy = Object.assign({}, cuentaIngreso);
|
|
50
|
+
copy.RubroId = `${gCuentaIngreso}.1`;
|
|
51
|
+
copy.Descripcion = `Ingresos por Ventas ${actividad.Desarrollo.ActividadGanadera}`;
|
|
52
|
+
copy.UUID = `${gCuentaIngreso}_${actividad.AuxPec.ActividadEconomicaId}_${i}`;
|
|
53
|
+
copy.MontoEmpresa = 0;
|
|
54
|
+
copy.MontoFamiliar = 0;
|
|
55
|
+
copy.Correlativo = i;
|
|
56
|
+
copy.Clasificador = 'CT';
|
|
57
|
+
if (actividad.AuxPec && actividad.AuxPec.HistoricoHato && actividad.AuxPec.HistoricoHato.length > 0) {
|
|
58
|
+
const historico = actividad.AuxPec.HistoricoHato.find((value) => value.Gestion === i && value.key == 'TOTALES');
|
|
59
|
+
if (historico)
|
|
60
|
+
copy.MontoEmpresa = Math.round(parseFloat(historico.Total) * 100) / 100;
|
|
61
|
+
}
|
|
62
|
+
data.eerr.push(copy);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const anadirIngresoVenta = (actividad, data) => {
|
|
66
|
+
const rango = data.eerr[0].Rango;
|
|
67
|
+
const cuentaIngreso = data.eerrMap.get(`${gCuentaIngreso}${rango}`);
|
|
68
|
+
let copy = Object.assign({}, cuentaIngreso);
|
|
69
|
+
copy.RubroId = `${gCuentaIngreso}.1`;
|
|
70
|
+
copy.Descripcion = `Ingresos por Ventas ${actividad.Desarrollo.ActividadGanadera}`;
|
|
71
|
+
copy.UUID = `${gCuentaIngreso}_${actividad.AuxPec.ActividadEconomicaId}_${rango}`;
|
|
72
|
+
copy.MontoEmpresa = 0;
|
|
73
|
+
copy.MontoFamiliar = 0;
|
|
74
|
+
copy.Correlativo = rango;
|
|
75
|
+
copy.Clasificador = 'CT';
|
|
76
|
+
if (actividad.Ventas.Ventas && actividad.Ventas.Ventas.length > 0) {
|
|
77
|
+
copy.MontoEmpresa = actividad.Ventas.Ventas.reduce((acc, item) => {
|
|
78
|
+
acc += parseFloat(item.IngresoTotal);
|
|
79
|
+
return acc;
|
|
80
|
+
}, 0);
|
|
81
|
+
}
|
|
82
|
+
data.eerr.push(copy);
|
|
83
|
+
};
|
|
84
|
+
const anadirCosto = (actividad, data) => {
|
|
85
|
+
const rango = data.eerr[0].Rango;
|
|
86
|
+
const cuentaCosto = data.eerrMap.get(`${gCuentaCosto}_${rango}`);
|
|
87
|
+
for (let i = 1; i <= rango; i++) {
|
|
88
|
+
let copy = Object.assign({}, cuentaCosto);
|
|
89
|
+
copy.RubroId = `${gCuentaCosto}.1`;
|
|
90
|
+
copy.Descripcion = `Costos de Ventas ${actividad.Desarrollo.ActividadGanadera}`;
|
|
91
|
+
copy.UUID = `${gCuentaCosto}_${actividad.AuxPec.ActividadEconomicaId}_${i}`;
|
|
92
|
+
copy.MontoEmpresa = 0;
|
|
93
|
+
copy.MontoFamiliar = 0;
|
|
94
|
+
copy.Correlativo = i;
|
|
95
|
+
copy.Clasificador = 'CT';
|
|
96
|
+
if (rango == i && actividad.Costos.Calculo && actividad.Costos.Calculo.length > 0) {
|
|
97
|
+
const monto = actividad.Costos.Calculo.find((value) => value.RubroId === 'TOT01');
|
|
98
|
+
if (!monto)
|
|
99
|
+
throw new Error('No existe el rubro TOT01 en los costos');
|
|
100
|
+
copy.MontoEmpresa = Math.round(parseFloat(monto.Total) * 100) / 100;
|
|
101
|
+
}
|
|
102
|
+
data.eerr.push(copy);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
const anadirGasto = (actividad, data) => {
|
|
106
|
+
const rango = data.eerr[0].Rango;
|
|
107
|
+
const cuentaGasto = data.eerrMap.get(`${gCuentaGasto}_${rango}`);
|
|
108
|
+
for (let i = 1; i <= rango; i++) {
|
|
109
|
+
let copy = Object.assign({}, cuentaGasto);
|
|
110
|
+
copy.RubroId = `${gCuentaGasto}.1`;
|
|
111
|
+
copy.UUID = `${gCuentaGasto}_${actividad.AuxPec.ActividadEconomicaId}_${i}`;
|
|
112
|
+
copy.Descripcion = `Gastos Administrativos Operativos ${actividad.Desarrollo.ActividadGanadera}`;
|
|
113
|
+
copy.MontoEmpresa = 0;
|
|
114
|
+
copy.MontoFamiliar = 0;
|
|
115
|
+
copy.Correlativo = i;
|
|
116
|
+
copy.Clasificador = 'CT';
|
|
117
|
+
if (rango == i) {
|
|
118
|
+
const otrosGastos = calcularOtrosGastos(actividad.OtrosGastos);
|
|
119
|
+
copy.MontoEmpresa = Math.round(parseFloat(otrosGastos.GastosOperativos) * 100) / 100;
|
|
120
|
+
}
|
|
121
|
+
data.eerr.push(copy);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
const calcularOtrosGastos = (gastos) => {
|
|
125
|
+
const gastosOperativos = gastos.Operativos.reduce((acc, item) => {
|
|
126
|
+
acc += parseFloat(item.ImporteAnual);
|
|
127
|
+
return acc;
|
|
128
|
+
}, 0);
|
|
129
|
+
const gastosFamiliares = gastos.Familiares.reduce((acc, item) => {
|
|
130
|
+
acc += parseFloat(item.ImporteAnual);
|
|
131
|
+
return acc;
|
|
132
|
+
}, 0);
|
|
133
|
+
return {
|
|
134
|
+
GastosOperativos: Math.round(gastosOperativos * 100) / 100,
|
|
135
|
+
GastosFamiliares: Math.round(gastosFamiliares * 100) / 100
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
const anadirOtrosIngresos = (actividad, data) => {
|
|
139
|
+
const rango = data.eerr[0].Rango;
|
|
140
|
+
const cuentaOtrosIngresos = data.eerr.find((item) => item.RubroId == gCuentaOtrosIngresosDet);
|
|
141
|
+
for (let i = 1; i <= rango; i++) {
|
|
142
|
+
let copy = Object.assign({}, cuentaOtrosIngresos);
|
|
143
|
+
copy.UUID = `${gCuentaOtrosIngresosDet}_${actividad.AuxPec.ActividadEconomicaId}_${rango}`;
|
|
144
|
+
copy.Descripcion = `Otros Ingresos ${actividad.Desarrollo.ActividadGanadera}`;
|
|
145
|
+
copy.MontoEmpresa = 0;
|
|
146
|
+
copy.MontoFamiliar = 0;
|
|
147
|
+
copy.Correlativo = i;
|
|
148
|
+
copy.Clasificador = 'CT';
|
|
149
|
+
if (rango == i && actividad.Ventas && actividad.Ventas.OtrosIngresos &&
|
|
150
|
+
actividad.Ventas.OtrosIngresos.length > 0) {
|
|
151
|
+
copy.MontoFamiliar = actividad.Ventas.OtrosIngresos.reduce((acc, item) => {
|
|
152
|
+
acc += parseFloat(item.Monto);
|
|
153
|
+
return acc;
|
|
154
|
+
}, 0);
|
|
155
|
+
copy.MontoFamiliar = Math.round(copy.MontoFamiliar * 100) / 100;
|
|
156
|
+
}
|
|
157
|
+
data.eerr.push(copy);
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
const sumarizarCuentas = (rubroOrigen, rubroDestino, data, dataOriginal) => {
|
|
161
|
+
const rango = data.eerr[0].Rango;
|
|
162
|
+
for (let i = 1; i <= rango; i++) {
|
|
163
|
+
const cuentaOrigen = data.eerr.find((item) => item.RubroId == rubroOrigen && item.Correlativo == i);
|
|
164
|
+
if (!cuentaOrigen)
|
|
165
|
+
throw new Error(`No existe el rubro Calculado ${rubroOrigen}_${i} en el EERR`);
|
|
166
|
+
const original = dataOriginal.get(`${rubroDestino}_${i}`);
|
|
167
|
+
if (original.MontoEmpresa == 0 || original.MontoFamiliar == 0) {
|
|
168
|
+
const cuentaDestino = data.eerrMap.get(`${rubroDestino}_${i}`);
|
|
169
|
+
if (original.MontoEmpresa == 0)
|
|
170
|
+
cuentaDestino.MontoEmpresa += cuentaOrigen.MontoEmpresa;
|
|
171
|
+
if (original.MontoFamiliar == 0)
|
|
172
|
+
cuentaDestino.MontoFamiliar += cuentaOrigen.MontoFamiliar;
|
|
173
|
+
cuentaDestino.MontoEmpresa = Math.round(cuentaDestino.MontoEmpresa * 100) / 100;
|
|
174
|
+
cuentaDestino.MontoFamiliar = Math.round(cuentaDestino.MontoFamiliar * 100) / 100;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
};
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const RUBRO_INGRESO = 'ACT_CNFL_40001';
|
|
4
|
+
const RUBRO_COSTOS = 'ACT_CNFL_50001';
|
|
5
|
+
const RUBRO_GASTOS = 'ACT_CNFL_60001';
|
|
6
|
+
const RUBRO_OTROS_INGRESOS = 'ACT_CNFL_70001';
|
|
7
|
+
const RUBRO_GASTOS_FAMILIARES = 'ACT_CNFL_70002';
|
|
8
|
+
class FlujoProyectadoPecStrategy {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.actividades = [];
|
|
11
|
+
}
|
|
12
|
+
execute(data) {
|
|
13
|
+
if (!this.actividades || this.actividades.length == 0)
|
|
14
|
+
return data;
|
|
15
|
+
const copiaIngreso = getCuentaCopy(RUBRO_INGRESO, data);
|
|
16
|
+
const copiaCostos = getCuentaCopy(RUBRO_COSTOS, data);
|
|
17
|
+
const copiaGastos = getCuentaCopy(RUBRO_GASTOS, data);
|
|
18
|
+
const copiaOtrosIngresos = getCuentaCopy(RUBRO_OTROS_INGRESOS, data);
|
|
19
|
+
const copiaGastosFamiliares = getCuentaCopy(RUBRO_GASTOS_FAMILIARES, data);
|
|
20
|
+
let sumaDesarrollo = [];
|
|
21
|
+
//@ts-ignore
|
|
22
|
+
let sumaDesarrolloAnual = null;
|
|
23
|
+
for (let actividad of this.actividades) {
|
|
24
|
+
addIngresosM(actividad, data);
|
|
25
|
+
addCostosM(actividad, data);
|
|
26
|
+
addGastosM(actividad, data);
|
|
27
|
+
otrosIngresoM(actividad, data);
|
|
28
|
+
gastosFamiliaresM(actividad, data);
|
|
29
|
+
sumaDesarrollo.push(getDesarrolloSuma(actividad));
|
|
30
|
+
sumaDesarrolloAnual = getSumaDesarrolloAnualByAnno(actividad, data, sumaDesarrolloAnual);
|
|
31
|
+
}
|
|
32
|
+
sumarizarCuenta(RUBRO_INGRESO, data, copiaIngreso);
|
|
33
|
+
sumarizarCuenta(RUBRO_COSTOS, data, copiaCostos);
|
|
34
|
+
sumarizarCuenta(RUBRO_GASTOS, data, copiaGastos);
|
|
35
|
+
sumarizarCuenta(RUBRO_OTROS_INGRESOS, data, copiaOtrosIngresos);
|
|
36
|
+
sumarizarCuenta(RUBRO_GASTOS_FAMILIARES, data, copiaGastosFamiliares);
|
|
37
|
+
addCalculosBase(data, sumaDesarrollo, sumaDesarrolloAnual);
|
|
38
|
+
return data;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.default = FlujoProyectadoPecStrategy;
|
|
42
|
+
const getCuentaCopy = (rubroId, data) => {
|
|
43
|
+
const cuenta = data.FlujoProyectadoMensualMap.get(`${rubroId}_0`);
|
|
44
|
+
return Object.assign({}, cuenta);
|
|
45
|
+
};
|
|
46
|
+
const sumarizarCuenta = (rubroId, data, copia) => {
|
|
47
|
+
const cuenta = data.FlujoProyectadoMensualMap.get(`${rubroId}_0`);
|
|
48
|
+
const detalles = data.FlujoProyectadoMensual.filter((item) => item.RubroId == `${rubroId}.1`);
|
|
49
|
+
for (let detalle of detalles) {
|
|
50
|
+
for (let i = 1; i <= 12; i++) {
|
|
51
|
+
if (copia[`Monto${i}`] == 0)
|
|
52
|
+
cuenta[`Monto${i}`] += parseFloat(detalle[`Monto${i}`]);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const getSumaDesarrolloAnualByAnno = (actividad, data, suma) => {
|
|
57
|
+
const CantidadProyeccion = data.DatosEvaluacion.CantidadProyeccion;
|
|
58
|
+
const ventasCantidad = actividad.Desarrollo.VentasCantidad.find((item) => item.RubroId == 'TOT01');
|
|
59
|
+
if (!suma) {
|
|
60
|
+
suma = {};
|
|
61
|
+
for (let i = 1; i <= CantidadProyeccion; i++) {
|
|
62
|
+
suma[`C-${i}`] = ventasCantidad[`C-${i}`];
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return suma;
|
|
66
|
+
};
|
|
67
|
+
const getDesarrolloSuma = (actividad) => {
|
|
68
|
+
const ventasCantidad = actividad.Desarrollo.VentasCantidad.find((item) => item.RubroId == 'TOT01');
|
|
69
|
+
if (!ventasCantidad)
|
|
70
|
+
throw new Error('No se econtró el Monto de desarrollo');
|
|
71
|
+
let result = 0;
|
|
72
|
+
for (let i = 1; i <= actividad.Desarrollo.CantidadProyeccion; i++) {
|
|
73
|
+
result += parseFloat(ventasCantidad[`C-${i}`]);
|
|
74
|
+
}
|
|
75
|
+
return result;
|
|
76
|
+
};
|
|
77
|
+
const addIngresosM = (actividad, data) => {
|
|
78
|
+
const rubro = data.FlujoProyectadoMensualMap.get(`${RUBRO_INGRESO}_0`);
|
|
79
|
+
const ingresos = actividad.Ventas.EstacionalidadCalc.find((item) => item.RubroId == 'TOT01');
|
|
80
|
+
if (!ingresos)
|
|
81
|
+
throw new Error('No se encontro la estacionalidad Calc de la actividad');
|
|
82
|
+
let row = Object.assign({}, rubro);
|
|
83
|
+
row.Descripcion = `Ingresos ${actividad.Desarrollo.ActividadGanadera}`;
|
|
84
|
+
row.Clasificador = 'CT';
|
|
85
|
+
row.Editable = false;
|
|
86
|
+
row.UUID = `${RUBRO_INGRESO}_${actividad.Desarrollo.ActividadEconomicaId}`;
|
|
87
|
+
row.RubroId = `${RUBRO_INGRESO}.1`;
|
|
88
|
+
for (let i = 1; i <= 12; i++) {
|
|
89
|
+
row[`Monto${i}`] = Math.round(parseFloat(ingresos[`C${i}`]) * 100) / 100;
|
|
90
|
+
}
|
|
91
|
+
data.FlujoProyectadoMensual.push(row);
|
|
92
|
+
};
|
|
93
|
+
const addCostosM = (actividad, data) => {
|
|
94
|
+
const rubro = data.FlujoProyectadoMensualMap.get(`${RUBRO_COSTOS}_0`);
|
|
95
|
+
const costos = actividad.Costos.Calculo.find((item) => item.RubroId == 'TOT01');
|
|
96
|
+
if (!costos)
|
|
97
|
+
throw new Error('No se encontro el costo cálculo de la actividad');
|
|
98
|
+
let row = Object.assign({}, rubro);
|
|
99
|
+
row.Descripcion = `(-) Costos de Ventas ${actividad.Desarrollo.ActividadGanadera}`;
|
|
100
|
+
row.Clasificador = 'CT';
|
|
101
|
+
row.Editable = false;
|
|
102
|
+
row.UUID = `${RUBRO_COSTOS}_${actividad.Desarrollo.ActividadEconomicaId}`;
|
|
103
|
+
row.RubroId = `${RUBRO_COSTOS}.1`;
|
|
104
|
+
for (let i = 1; i <= 12; i++) {
|
|
105
|
+
row[`Monto${i}`] = Math.round(parseFloat(costos[`C-${i}`]) * 100) / 100;
|
|
106
|
+
}
|
|
107
|
+
data.FlujoProyectadoMensual.push(row);
|
|
108
|
+
};
|
|
109
|
+
const addGastosM = (actividad, data) => {
|
|
110
|
+
const rubro = data.FlujoProyectadoMensualMap.get(`${RUBRO_GASTOS}_0`);
|
|
111
|
+
const otrosGastos = calcularOtrosGastos(actividad.OtrosGastos);
|
|
112
|
+
if (!otrosGastos)
|
|
113
|
+
throw new Error('No se encontro los gastos de la actividad');
|
|
114
|
+
let row = Object.assign({}, rubro);
|
|
115
|
+
row.Descripcion = `(-) Gastos Operativo ${actividad.Desarrollo.ActividadGanadera}`;
|
|
116
|
+
row.Clasificador = 'CT';
|
|
117
|
+
row.Editable = false;
|
|
118
|
+
row.UUID = `${RUBRO_GASTOS}_${actividad.Desarrollo.ActividadEconomicaId}`;
|
|
119
|
+
row.RubroId = `${RUBRO_GASTOS}.1`;
|
|
120
|
+
for (let i = 1; i <= 12; i++) {
|
|
121
|
+
row[`Monto${i}`] = Math.round(parseFloat(otrosGastos.GastosOperativos) * 100) / 100;
|
|
122
|
+
}
|
|
123
|
+
data.FlujoProyectadoMensual.push(row);
|
|
124
|
+
};
|
|
125
|
+
const otrosIngresoM = (actividad, data) => {
|
|
126
|
+
const rubro = data.FlujoProyectadoMensualMap.get(`${RUBRO_OTROS_INGRESOS}_0`);
|
|
127
|
+
const otrosIngresos = actividad.Ventas.OtrosIngresos;
|
|
128
|
+
if (!otrosIngresos)
|
|
129
|
+
throw new Error('No se encontro la estacionalidad Calc de la actividad');
|
|
130
|
+
let row = Object.assign({}, rubro);
|
|
131
|
+
row.Descripcion = `Otros Ingresos Familiares ${actividad.Desarrollo.ActividadGanadera}`;
|
|
132
|
+
row.Clasificador = 'CT';
|
|
133
|
+
row.Editable = false;
|
|
134
|
+
row.UUID = `${RUBRO_OTROS_INGRESOS}_${actividad.Desarrollo.ActividadEconomicaId}`;
|
|
135
|
+
row.RubroId = `${RUBRO_OTROS_INGRESOS}.1`;
|
|
136
|
+
if (otrosIngresos.length == 0) {
|
|
137
|
+
const suma = otrosIngresos.reduce((acc, item) => {
|
|
138
|
+
acc += parseFloat(item.Monto);
|
|
139
|
+
return acc;
|
|
140
|
+
}, 0);
|
|
141
|
+
for (let i = 1; i <= 12; i++) {
|
|
142
|
+
row[`Monto${i}`] = suma;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
for (let i = 1; i <= 12; i++) {
|
|
147
|
+
row[`Monto${i}`] = Math.round(parseFloat(otrosIngresos[`C${i}`]) * 100) / 100;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
data.FlujoProyectadoMensual.push(row);
|
|
151
|
+
};
|
|
152
|
+
const gastosFamiliaresM = (actividad, data) => {
|
|
153
|
+
const rubro = data.FlujoProyectadoMensualMap.get(`$${RUBRO_GASTOS_FAMILIARES}_0`);
|
|
154
|
+
const otrosGastos = calcularOtrosGastos(actividad.OtrosGastos);
|
|
155
|
+
if (!otrosGastos)
|
|
156
|
+
throw new Error('No se encontro los gastos de la actividad');
|
|
157
|
+
let row = Object.assign({}, rubro);
|
|
158
|
+
row.Descripcion = `(-) Gastos Familiares ${actividad.Desarrollo.ActividadGanadera}`;
|
|
159
|
+
row.Clasificador = 'CT';
|
|
160
|
+
row.Editable = false;
|
|
161
|
+
row.UUID = `${RUBRO_GASTOS_FAMILIARES}_${actividad.Desarrollo.ActividadEconomicaId}`;
|
|
162
|
+
row.RubroId = `${RUBRO_GASTOS_FAMILIARES}.1`;
|
|
163
|
+
for (let i = 1; i <= 12; i++) {
|
|
164
|
+
row[`Monto${i}`] = Math.round(parseFloat(otrosGastos.gastosFamiliares) * 100) / 100;
|
|
165
|
+
}
|
|
166
|
+
data.FlujoProyectadoMensual.push(row);
|
|
167
|
+
};
|
|
168
|
+
const addCalculosBase = (data, sumaDesarrollo, sumaDesarrolloAnual) => {
|
|
169
|
+
const ingresos = data.FlujoProyectadoMensualMap.get(`${RUBRO_INGRESO}_0`);
|
|
170
|
+
let sumaIngresos = 0;
|
|
171
|
+
for (let i = 1; i <= 12; i++) {
|
|
172
|
+
sumaIngresos += parseFloat(ingresos[`Monto${i}`]);
|
|
173
|
+
}
|
|
174
|
+
let sumaHato = sumaDesarrollo.reduce((acc, item) => {
|
|
175
|
+
acc += item;
|
|
176
|
+
return acc;
|
|
177
|
+
}, 0);
|
|
178
|
+
const sumaProyectada = Math.round((sumaIngresos * data.DatosEvaluacion.CantidadProyeccion) * 100) / 100;
|
|
179
|
+
let result = {
|
|
180
|
+
EsEngorde: data.Parametros.EsEngorde,
|
|
181
|
+
SumaAnnoBase: sumaProyectada,
|
|
182
|
+
SumaHato: sumaHato,
|
|
183
|
+
Conclusion: 'NA'
|
|
184
|
+
};
|
|
185
|
+
result.SumaDesarrolloAnual = sumaDesarrolloAnual;
|
|
186
|
+
if (result.EsEngorde == 'SI' || result.SumaAnnoBase < result.SumaHato)
|
|
187
|
+
result.Conclusion = 'FLUJO_HISTORICO';
|
|
188
|
+
else {
|
|
189
|
+
if (result.SumaHato < result.SumaAnnoBase)
|
|
190
|
+
result.Conclusion = 'DESARROLLO_HATO';
|
|
191
|
+
}
|
|
192
|
+
data.ParametrosEngorde = result;
|
|
193
|
+
};
|
|
194
|
+
const calcularOtrosGastos = (gastos) => {
|
|
195
|
+
const gastosOperativos = gastos.Operativos.reduce((acc, item) => {
|
|
196
|
+
acc += parseFloat(item.ImporteMensual);
|
|
197
|
+
return acc;
|
|
198
|
+
}, 0);
|
|
199
|
+
const gastosFamiliares = gastos.Familiares.reduce((acc, item) => {
|
|
200
|
+
acc += parseFloat(item.ImporteMensual);
|
|
201
|
+
return acc;
|
|
202
|
+
}, 0);
|
|
203
|
+
return {
|
|
204
|
+
GastosOperativos: Math.round(gastosOperativos * 100) / 100,
|
|
205
|
+
GastosFamiliares: Math.round(gastosFamiliares * 100) / 100
|
|
206
|
+
};
|
|
207
|
+
};
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const gCuentaIngreso = 'ACT_CN_40001';
|
|
4
|
+
const gCuentaCosto = 'ACT_CN_41002';
|
|
5
|
+
const gCuentaGasto = 'ACT_CN_43002';
|
|
6
|
+
const gCuentaGastoFamiliares = 'ACT_CN_45003';
|
|
7
|
+
const gCuentaOtrosIngresosDet = 'ACT_CN_45001';
|
|
8
|
+
class BalancePrdStrategy {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.actividades = [];
|
|
11
|
+
}
|
|
12
|
+
execute(data) {
|
|
13
|
+
if (!this.actividades || this.actividades.length == 0)
|
|
14
|
+
return data;
|
|
15
|
+
//@ts-ignore
|
|
16
|
+
const cuentasIngresosCopy = getCuentasCopy(data, gCuentaIngreso);
|
|
17
|
+
//@ts-ignore
|
|
18
|
+
const cuentasCostoCopy = getCuentasCopy(data, gCuentaCosto);
|
|
19
|
+
//@ts-ignore
|
|
20
|
+
const cuentaGastoCopy = getCuentasCopy(data, gCuentaGasto);
|
|
21
|
+
const cuentaGastoFamiliarCopy = getCuentasCopy(data, gCuentaGastoFamiliares);
|
|
22
|
+
for (let actividad of this.actividades) {
|
|
23
|
+
anadirIngreso(actividad, data);
|
|
24
|
+
anadirCosto(actividad, data);
|
|
25
|
+
anadirGasto(actividad, data);
|
|
26
|
+
anadirOtrosIngresos(actividad, data);
|
|
27
|
+
anadirGastoFamiliares(actividad, data);
|
|
28
|
+
}
|
|
29
|
+
sumarizarCuentas(`${gCuentaIngreso}.1`, gCuentaIngreso, data, cuentasIngresosCopy);
|
|
30
|
+
sumarizarCuentas(`${gCuentaCosto}.1`, gCuentaCosto, data, cuentasCostoCopy);
|
|
31
|
+
sumarizarCuentas(`${gCuentaGasto}.1`, gCuentaGasto, data, cuentaGastoCopy);
|
|
32
|
+
sumarizarCuentas(`${gCuentaGastoFamiliares}.1`, gCuentaGastoFamiliares, data, cuentaGastoFamiliarCopy);
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.default = BalancePrdStrategy;
|
|
37
|
+
const getCuentasCopy = (data, rubroId) => {
|
|
38
|
+
if (!data.eerr || data.eerr.length == 0)
|
|
39
|
+
throw new Error('Debe ingresar cuentas EERR');
|
|
40
|
+
let originalData = new Map();
|
|
41
|
+
const rango = data.eerr[0].Rango;
|
|
42
|
+
for (let i = 1; i <= rango; i++) {
|
|
43
|
+
let cuentaIngreso = data.eerrMap.get(`${rubroId}_${i}`);
|
|
44
|
+
cuentaIngreso.MontoEmpresa = Math.round(parseFloat(cuentaIngreso.MontoEmpresa) * 100) / 100;
|
|
45
|
+
cuentaIngreso.MontoFamiliar = Math.round(parseFloat(cuentaIngreso.MontoFamiliar) * 100) / 100;
|
|
46
|
+
originalData.set(`${rubroId}_${i}`, Object.assign({}, cuentaIngreso));
|
|
47
|
+
}
|
|
48
|
+
//console.log('originalData '+rubroId,Array.from(originalData.keys()) )
|
|
49
|
+
return originalData;
|
|
50
|
+
};
|
|
51
|
+
const anadirIngreso = (actividad, data) => {
|
|
52
|
+
const rango = data.eerr[0].Rango;
|
|
53
|
+
const productos = actividad.Ventas.Productos;
|
|
54
|
+
if (productos && productos.length > 0) {
|
|
55
|
+
for (const producto of productos) {
|
|
56
|
+
const subtotal = actividad.Ventas.
|
|
57
|
+
Ingresos.find((item) => item.Id == 'SUBTOTAL' && item.ProductoId == producto.ProductoId);
|
|
58
|
+
for (let i = 1; i <= rango; i++) {
|
|
59
|
+
const cuentaIngreso = data.eerrMap.get(`${gCuentaIngreso}_${i}`);
|
|
60
|
+
let copy = Object.assign({}, cuentaIngreso);
|
|
61
|
+
copy.RubroId = `${gCuentaIngreso}.1`;
|
|
62
|
+
copy.Descripcion = `Ingresos por Ventas ${producto.ProductoId} ${producto.Descripcion}`;
|
|
63
|
+
copy.UUID = `${gCuentaIngreso}_${actividad.ActividadEconomicaId}_${producto.ProductoId}_${i}`;
|
|
64
|
+
copy.MontoEmpresa = 0;
|
|
65
|
+
copy.MontoFamiliar = 0;
|
|
66
|
+
copy.Correlativo = i;
|
|
67
|
+
copy.Clasificador = 'CT';
|
|
68
|
+
if (subtotal && subtotal[`C-${i}`]) {
|
|
69
|
+
copy.MontoEmpresa = Math.round(parseFloat(subtotal[`C-${i}`]) * 100) / 100;
|
|
70
|
+
}
|
|
71
|
+
data.eerr.push(copy);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
const anadirCosto = (actividad, data) => {
|
|
77
|
+
const rango = data.eerr[0].Rango;
|
|
78
|
+
const productos = actividad.Ventas.Productos;
|
|
79
|
+
if (productos && productos.length > 0) {
|
|
80
|
+
for (const producto of productos) {
|
|
81
|
+
const subtotal = actividad.
|
|
82
|
+
Costos.Meses.find((item) => item.ProductoId == producto.ProductoId);
|
|
83
|
+
for (let i = 1; i <= rango; i++) {
|
|
84
|
+
const cuentaIngreso = data.eerrMap.get(`${gCuentaCosto}_${i}`);
|
|
85
|
+
let copy = Object.assign({}, cuentaIngreso);
|
|
86
|
+
copy.RubroId = `${gCuentaCosto}.1`;
|
|
87
|
+
copy.Descripcion = `Ingresos por Ventas ${producto.ProductoId} ${producto.Descripcion}`;
|
|
88
|
+
copy.UUID = `${gCuentaCosto}_${actividad.ActividadEconomicaId}_${producto.ProductoId}_${i}`;
|
|
89
|
+
copy.MontoEmpresa = 0;
|
|
90
|
+
copy.MontoFamiliar = 0;
|
|
91
|
+
copy.Correlativo = i;
|
|
92
|
+
copy.Clasificador = 'CT';
|
|
93
|
+
if (i == rango && subtotal) {
|
|
94
|
+
copy.MontoEmpresa = Math.round(parseFloat(subtotal.Total) * 100) / 100;
|
|
95
|
+
}
|
|
96
|
+
data.eerr.push(copy);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
const anadirGasto = (actividad, data) => {
|
|
102
|
+
const rango = data.eerr[0].Rango;
|
|
103
|
+
const cuentaGasto = data.eerrMap.get(`${gCuentaGasto}_${rango}`);
|
|
104
|
+
for (let i = 1; i <= rango; i++) {
|
|
105
|
+
let copy = Object.assign({}, cuentaGasto);
|
|
106
|
+
copy.RubroId = `${gCuentaGasto}.1`;
|
|
107
|
+
copy.UUID = `${gCuentaGasto}_${actividad.ActividadEconomicaId}_${i}`;
|
|
108
|
+
copy.Descripcion = `Gastos Administrativos Operativos Actividad: ${actividad.ActividadEconomicaId}`;
|
|
109
|
+
copy.MontoEmpresa = 0;
|
|
110
|
+
copy.MontoFamiliar = 0;
|
|
111
|
+
copy.Correlativo = i;
|
|
112
|
+
copy.Clasificador = 'CT';
|
|
113
|
+
if (rango == i) {
|
|
114
|
+
const otrosGastos = calcularOtrosGastos(actividad.OtrosGastos);
|
|
115
|
+
copy.MontoEmpresa = Math.round(parseFloat(otrosGastos.GastosOperativos) * 100) / 100;
|
|
116
|
+
}
|
|
117
|
+
data.eerr.push(copy);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
const anadirGastoFamiliares = (actividad, data) => {
|
|
121
|
+
const rango = data.eerr[0].Rango;
|
|
122
|
+
const cuentaGasto = data.eerrMap.get(`${gCuentaGastoFamiliares}_${rango}`);
|
|
123
|
+
for (let i = 1; i <= rango; i++) {
|
|
124
|
+
let copy = Object.assign({}, cuentaGasto);
|
|
125
|
+
copy.RubroId = `${gCuentaGastoFamiliares}.1`;
|
|
126
|
+
copy.UUID = `${gCuentaGastoFamiliares}_${actividad.ActividadEconomicaId}_${i}`;
|
|
127
|
+
copy.Descripcion = `Gastos Familiares Actividad: ${actividad.ActividadEconomicaId}`;
|
|
128
|
+
copy.MontoEmpresa = 0;
|
|
129
|
+
copy.MontoFamiliar = 0;
|
|
130
|
+
copy.Correlativo = i;
|
|
131
|
+
copy.Clasificador = 'CT';
|
|
132
|
+
if (rango == i) {
|
|
133
|
+
const otrosGastos = calcularOtrosGastos(actividad.OtrosGastos);
|
|
134
|
+
copy.MontoFamiliar = Math.round(parseFloat(otrosGastos.GastosFamiliares) * 100) / 100;
|
|
135
|
+
}
|
|
136
|
+
data.eerr.push(copy);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
const calcularOtrosGastos = (gastos) => {
|
|
140
|
+
const gastosOperativos = gastos.Operativos.reduce((acc, item) => {
|
|
141
|
+
acc += parseFloat(item.ImporteAnual);
|
|
142
|
+
return acc;
|
|
143
|
+
}, 0);
|
|
144
|
+
const gastosFamiliares = gastos.Familiares.reduce((acc, item) => {
|
|
145
|
+
acc += parseFloat(item.ImporteAnual);
|
|
146
|
+
return acc;
|
|
147
|
+
}, 0);
|
|
148
|
+
return {
|
|
149
|
+
GastosOperativos: Math.round(gastosOperativos * 100) / 100,
|
|
150
|
+
GastosFamiliares: Math.round(gastosFamiliares * 100) / 100
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
const anadirOtrosIngresos = (actividad, data) => {
|
|
154
|
+
const rango = data.eerr[0].Rango;
|
|
155
|
+
const cuentaOtrosIngresos = data.eerr.find((item) => item.RubroId == gCuentaOtrosIngresosDet);
|
|
156
|
+
for (let i = 1; i <= rango; i++) {
|
|
157
|
+
let copy = Object.assign({}, cuentaOtrosIngresos);
|
|
158
|
+
copy.UUID = `${gCuentaOtrosIngresosDet}_${actividad.ActividadEconomicaId}_${rango}`;
|
|
159
|
+
copy.Descripcion = `Otros Ingresos ${actividad.ActividadEconomicaId}`;
|
|
160
|
+
copy.MontoEmpresa = 0;
|
|
161
|
+
copy.MontoFamiliar = 0;
|
|
162
|
+
copy.Correlativo = i;
|
|
163
|
+
copy.Clasificador = 'CT';
|
|
164
|
+
if (rango == i && actividad.Ventas && actividad.Ventas.OtrosIngresos &&
|
|
165
|
+
actividad.Ventas.OtrosIngresos.length > 0) {
|
|
166
|
+
copy.MontoFamiliar = actividad.Ventas.OtrosIngresos.reduce((acc, item) => {
|
|
167
|
+
acc += parseFloat(item.Monto);
|
|
168
|
+
return acc;
|
|
169
|
+
}, 0);
|
|
170
|
+
copy.MontoFamiliar = Math.round(copy.MontoFamiliar * 100) / 100;
|
|
171
|
+
}
|
|
172
|
+
data.eerr.push(copy);
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
const sumarizarCuentas = (rubroOrigen, rubroDestino, data, dataOriginal) => {
|
|
176
|
+
const rango = data.eerr[0].Rango;
|
|
177
|
+
for (let i = 1; i <= rango; i++) {
|
|
178
|
+
const cuentaOrigen = data.eerr.find((item) => item.RubroId == rubroOrigen && item.Correlativo == i);
|
|
179
|
+
if (!cuentaOrigen)
|
|
180
|
+
throw new Error(`No existe el rubro Calculado ${rubroOrigen}_${i} en el EERR`);
|
|
181
|
+
const original = dataOriginal.get(`${rubroDestino}_${i}`);
|
|
182
|
+
if (original.MontoEmpresa == 0 || original.MontoFamiliar == 0) {
|
|
183
|
+
const cuentaDestino = data.eerrMap.get(`${rubroDestino}_${i}`);
|
|
184
|
+
if (original.MontoEmpresa == 0)
|
|
185
|
+
cuentaDestino.MontoEmpresa += cuentaOrigen.MontoEmpresa;
|
|
186
|
+
if (original.MontoFamiliar == 0)
|
|
187
|
+
cuentaDestino.MontoFamiliar += cuentaOrigen.MontoFamiliar;
|
|
188
|
+
cuentaDestino.MontoEmpresa = Math.round(cuentaDestino.MontoEmpresa * 100) / 100;
|
|
189
|
+
cuentaDestino.MontoFamiliar = Math.round(cuentaDestino.MontoFamiliar * 100) / 100;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
};
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const RUBRO_INGRESO = 'ACT_CNFL_40001';
|
|
4
|
+
const RUBRO_COSTOS = 'ACT_CNFL_50001';
|
|
5
|
+
const RUBRO_GASTOS = 'ACT_CNFL_60001';
|
|
6
|
+
const RUBRO_OTROS_INGRESOS = 'ACT_CNFL_70001';
|
|
7
|
+
const RUBRO_GASTOS_FAMILIARES = 'ACT_CNFL_70002';
|
|
8
|
+
class FlujoProyectadoPrdStrategy {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.actividades = [];
|
|
11
|
+
}
|
|
12
|
+
execute(data) {
|
|
13
|
+
const copiaIngreso = getCuentaCopy(RUBRO_INGRESO, data);
|
|
14
|
+
const copiaCostos = getCuentaCopy(RUBRO_COSTOS, data);
|
|
15
|
+
const copiaGastos = getCuentaCopy(RUBRO_GASTOS, data);
|
|
16
|
+
const copiaOtrosIngresos = getCuentaCopy(RUBRO_OTROS_INGRESOS, data);
|
|
17
|
+
const copiaGastosFamiliares = getCuentaCopy(RUBRO_GASTOS_FAMILIARES, data);
|
|
18
|
+
for (let actividad of this.actividades) {
|
|
19
|
+
addIngresosM(actividad, data);
|
|
20
|
+
addCostosM(actividad, data);
|
|
21
|
+
addGastosM(actividad, data);
|
|
22
|
+
otrosIngresoM(actividad, data);
|
|
23
|
+
gastosFamiliaresM(actividad, data);
|
|
24
|
+
}
|
|
25
|
+
sumarizarCuenta(RUBRO_INGRESO, data, copiaIngreso);
|
|
26
|
+
sumarizarCuenta(RUBRO_COSTOS, data, copiaCostos);
|
|
27
|
+
sumarizarCuenta(RUBRO_GASTOS, data, copiaGastos);
|
|
28
|
+
sumarizarCuenta(RUBRO_OTROS_INGRESOS, data, copiaOtrosIngresos);
|
|
29
|
+
sumarizarCuenta(RUBRO_GASTOS_FAMILIARES, data, copiaGastosFamiliares);
|
|
30
|
+
return data;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.default = FlujoProyectadoPrdStrategy;
|
|
34
|
+
const getCuentaCopy = (rubroId, data) => {
|
|
35
|
+
const cuenta = data.FlujoProyectadoMensualMap.get(`${rubroId}_0`);
|
|
36
|
+
return Object.assign({}, cuenta);
|
|
37
|
+
};
|
|
38
|
+
const sumarizarCuenta = (rubroId, data, copia) => {
|
|
39
|
+
const cuenta = data.FlujoProyectadoMensualMap.get(`${rubroId}_0`);
|
|
40
|
+
const detalles = data.FlujoProyectadoMensual.filter((item) => item.RubroId == `${rubroId}.1`);
|
|
41
|
+
for (let detalle of detalles) {
|
|
42
|
+
for (let i = 1; i <= 12; i++) {
|
|
43
|
+
if (copia[`Monto${i}`] == 0)
|
|
44
|
+
cuenta[`Monto${i}`] += parseFloat(detalle[`Monto${i}`]);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const addIngresosM = (actividad, data) => {
|
|
49
|
+
const rubro = data.FlujoProyectadoMensualMap.get(`${RUBRO_INGRESO}_0`);
|
|
50
|
+
const productos = actividad.Ventas.Productos;
|
|
51
|
+
if (productos && productos.length > 0) {
|
|
52
|
+
for (const producto of productos) {
|
|
53
|
+
const ingresos = actividad.Ventas.EstacionalidadCalc.find((item) => item.ProductoId == producto.ProductoId);
|
|
54
|
+
if (!ingresos)
|
|
55
|
+
throw new Error('No se encontro la estacionalidad Calc de la actividad');
|
|
56
|
+
let row = Object.assign({}, rubro);
|
|
57
|
+
row.Descripcion = `Ingresos Actividad ${actividad.ActividadEconomicaId} - Producto ${ingresos.Descripcion}`;
|
|
58
|
+
row.Clasificador = 'CT';
|
|
59
|
+
row.Editable = false;
|
|
60
|
+
row.UUID = `${RUBRO_INGRESO}_${actividad.ActividadEconomicaId}_${producto.ProductoId}`;
|
|
61
|
+
row.RubroId = `${RUBRO_INGRESO}.1`;
|
|
62
|
+
for (let i = 1; i <= 12; i++) {
|
|
63
|
+
row[`Monto${i}`] = Math.round(parseFloat(ingresos[`C-${i}`]) * 100) / 100;
|
|
64
|
+
}
|
|
65
|
+
data.FlujoProyectadoMensual.push(row);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const addCostosM = (actividad, data) => {
|
|
70
|
+
const rubro = data.FlujoProyectadoMensualMap.get(`${RUBRO_COSTOS}_0`);
|
|
71
|
+
const productos = actividad.Ventas.Productos;
|
|
72
|
+
if (productos && productos.length > 0) {
|
|
73
|
+
for (const producto of productos) {
|
|
74
|
+
const costos = actividad.Costos.Meses.find((item) => item.ProductoId == producto.ProductoId);
|
|
75
|
+
if (!costos)
|
|
76
|
+
throw new Error(`No se encontro el costo cálculo para el producto ${producto.ProductoId}`);
|
|
77
|
+
let row = Object.assign({}, rubro);
|
|
78
|
+
row.Descripcion = `(-) Costos de Ventas Actividad: $${actividad.ActividadEconomicaId} Producto ${producto.ProductoId}`;
|
|
79
|
+
row.Clasificador = 'CT';
|
|
80
|
+
row.Editable = false;
|
|
81
|
+
row.UUID = `${RUBRO_COSTOS}_${actividad.ActividadEconomicaId}_${producto.ProductoId}`;
|
|
82
|
+
row.RubroId = `${RUBRO_COSTOS}.1`;
|
|
83
|
+
for (let i = 1; i <= 12; i++) {
|
|
84
|
+
row[`Monto${i}`] = Math.round(parseFloat(costos[`Monto${i}`]) * 100) / 100;
|
|
85
|
+
}
|
|
86
|
+
data.FlujoProyectadoMensual.push(row);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const addGastosM = (actividad, data) => {
|
|
91
|
+
const rubro = data.FlujoProyectadoMensualMap.get(`${RUBRO_GASTOS}_0`);
|
|
92
|
+
const otrosGastos = calcularOtrosGastos(actividad.OtrosGastos);
|
|
93
|
+
if (!otrosGastos)
|
|
94
|
+
throw new Error('No se encontro los gastos de la actividad');
|
|
95
|
+
let row = Object.assign({}, rubro);
|
|
96
|
+
row.Descripcion = `(-) Gastos Operativo ActividadId:${actividad.ActividadEconomicaId}`;
|
|
97
|
+
row.Clasificador = 'CT';
|
|
98
|
+
row.Editable = false;
|
|
99
|
+
row.UUID = `${RUBRO_GASTOS}_${actividad.ActividadEconomicaId}`;
|
|
100
|
+
row.RubroId = `${RUBRO_GASTOS}.1`;
|
|
101
|
+
for (let i = 1; i <= 12; i++) {
|
|
102
|
+
row[`Monto${i}`] = Math.round(parseFloat(otrosGastos.GastosOperativos) * 100) / 100;
|
|
103
|
+
}
|
|
104
|
+
data.FlujoProyectadoMensual.push(row);
|
|
105
|
+
};
|
|
106
|
+
const otrosIngresoM = (actividad, data) => {
|
|
107
|
+
const rubro = data.FlujoProyectadoMensualMap.get(`${RUBRO_OTROS_INGRESOS}_0`);
|
|
108
|
+
const otrosIngresos = actividad.Ventas.OtrosIngresos;
|
|
109
|
+
if (!otrosIngresos)
|
|
110
|
+
throw new Error('No se encontro la estacionalidad Calc de la actividad');
|
|
111
|
+
let row = Object.assign({}, rubro);
|
|
112
|
+
row.Descripcion = `Otros Ingresos Familiares Actividad: ${actividad.ActividadEconomicaId}`;
|
|
113
|
+
row.Clasificador = 'CT';
|
|
114
|
+
row.Editable = false;
|
|
115
|
+
row.UUID = `${RUBRO_OTROS_INGRESOS}_${actividad.ActividadEconomicaId}`;
|
|
116
|
+
row.RubroId = `${RUBRO_OTROS_INGRESOS}.1`;
|
|
117
|
+
if (otrosIngresos.length == 0) {
|
|
118
|
+
const suma = otrosIngresos.reduce((acc, item) => {
|
|
119
|
+
acc += parseFloat(item.Monto);
|
|
120
|
+
return acc;
|
|
121
|
+
}, 0);
|
|
122
|
+
for (let i = 1; i <= 12; i++) {
|
|
123
|
+
row[`Monto${i}`] = suma;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
for (let i = 1; i <= 12; i++) {
|
|
128
|
+
row[`Monto${i}`] = Math.round(parseFloat(otrosIngresos[`C-${i}`]) * 100) / 100;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
data.FlujoProyectadoMensual.push(row);
|
|
132
|
+
};
|
|
133
|
+
const gastosFamiliaresM = (actividad, data) => {
|
|
134
|
+
const rubro = data.FlujoProyectadoMensualMap.get(`$${RUBRO_GASTOS_FAMILIARES}_0`);
|
|
135
|
+
const otrosGastos = calcularOtrosGastos(actividad.OtrosGastos);
|
|
136
|
+
if (!otrosGastos)
|
|
137
|
+
throw new Error('No se encontro los gastos de la actividad');
|
|
138
|
+
let row = Object.assign({}, rubro);
|
|
139
|
+
row.Descripcion = `(-) Gastos Familiares Actividad ${actividad.ActividadEconomicaId}`;
|
|
140
|
+
row.Clasificador = 'CT';
|
|
141
|
+
row.Editable = false;
|
|
142
|
+
row.UUID = `${RUBRO_GASTOS_FAMILIARES}_${actividad.ActividadEconomicaId}`;
|
|
143
|
+
row.RubroId = `${RUBRO_GASTOS_FAMILIARES}.1`;
|
|
144
|
+
for (let i = 1; i <= 12; i++) {
|
|
145
|
+
row[`Monto${i}`] = Math.round(parseFloat(otrosGastos.gastosFamiliares) * 100) / 100;
|
|
146
|
+
}
|
|
147
|
+
data.FlujoProyectadoMensual.push(row);
|
|
148
|
+
};
|
|
149
|
+
const calcularOtrosGastos = (gastos) => {
|
|
150
|
+
const gastosOperativos = gastos.Operativos.reduce((acc, item) => {
|
|
151
|
+
acc += parseFloat(item.ImporteMensual);
|
|
152
|
+
return acc;
|
|
153
|
+
}, 0);
|
|
154
|
+
const gastosFamiliares = gastos.Familiares.reduce((acc, item) => {
|
|
155
|
+
acc += parseFloat(item.ImporteMensual);
|
|
156
|
+
return acc;
|
|
157
|
+
}, 0);
|
|
158
|
+
return {
|
|
159
|
+
GastosOperativos: Math.round(gastosOperativos * 100) / 100,
|
|
160
|
+
GastosFamiliares: Math.round(gastosFamiliares * 100) / 100
|
|
161
|
+
};
|
|
162
|
+
};
|
|
@@ -14,8 +14,6 @@ const calcularProductos = (data) => {
|
|
|
14
14
|
subtotal[`CDesc-${item.Correlativo}`] = item.CorrelativoDesc;
|
|
15
15
|
});
|
|
16
16
|
for (let i = 1; i < data.Rango; i++) {
|
|
17
|
-
// console.log('cantidad',i,cantidad[`CDesc-${i+1}`])
|
|
18
|
-
// console.log('cantidad',i,cantidad[`CDesc-${i}`])
|
|
19
17
|
cantidad[`V-${i}`] = cantidad[`C-${i + 1}`] - cantidad[`C-${i}`];
|
|
20
18
|
cantidad[`VDesc-${i}`] = cantidad[`CDesc-${i + 1}`].slice(-4) + ' - ' + cantidad[`CDesc-${i}`].slice(-4);
|
|
21
19
|
precio[`V-${i}`] = precio[`C-${i + 1}`] - precio[`C-${i}`];
|