bdpformulas 1.0.41 → 1.0.42
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/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 +191 -0
- package/build/strategies/production/balancePrd.strategy.d.ts +6 -0
- package/build/strategies/production/balancePrd.strategy.js +11 -0
- package/build/strategies/production/flujoProyPrd.strategy.d.ts +6 -0
- package/build/strategies/production/flujoProyPrd.strategy.js +11 -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 = {
|
|
@@ -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
|
+
throw new Error('Debe ingresar actividades Pecuarias');
|
|
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.MontoEmpresa = actividad.Ventas.OtrosIngresos.reduce((acc, item) => {
|
|
152
|
+
acc += parseFloat(item.Monto);
|
|
153
|
+
return acc;
|
|
154
|
+
}, 0);
|
|
155
|
+
copy.MontoEmpresa = Math.round(copy.MontoEmpresa * 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,191 @@
|
|
|
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
|
+
throw new Error('Debe ingresar actividades Agrícolas');
|
|
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
|
+
for (let actividad of this.actividades) {
|
|
22
|
+
addIngresosM(actividad, data);
|
|
23
|
+
addCostosM(actividad, data);
|
|
24
|
+
addGastosM(actividad, data);
|
|
25
|
+
otrosIngresoM(actividad, data);
|
|
26
|
+
gastosFamiliaresM(actividad, data);
|
|
27
|
+
sumaDesarrollo.push(getDesarrolloSuma(actividad));
|
|
28
|
+
}
|
|
29
|
+
sumarizarCuenta(RUBRO_INGRESO, data, copiaIngreso);
|
|
30
|
+
sumarizarCuenta(RUBRO_COSTOS, data, copiaCostos);
|
|
31
|
+
sumarizarCuenta(RUBRO_GASTOS, data, copiaGastos);
|
|
32
|
+
sumarizarCuenta(RUBRO_OTROS_INGRESOS, data, copiaOtrosIngresos);
|
|
33
|
+
sumarizarCuenta(RUBRO_GASTOS_FAMILIARES, data, copiaGastosFamiliares);
|
|
34
|
+
addCalculosBase(data, sumaDesarrollo);
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.default = FlujoProyectadoPecStrategy;
|
|
39
|
+
const getCuentaCopy = (rubroId, data) => {
|
|
40
|
+
const cuenta = data.FlujoProyectadoMensualMap.get(`${rubroId}_0`);
|
|
41
|
+
return Object.assign({}, cuenta);
|
|
42
|
+
};
|
|
43
|
+
const sumarizarCuenta = (rubroId, data, copia) => {
|
|
44
|
+
const cuenta = data.FlujoProyectadoMensualMap.get(`${rubroId}_0`);
|
|
45
|
+
const detalles = data.FlujoProyectadoMensual.filter((item) => item.RubroId == `$${rubroId}.1`);
|
|
46
|
+
for (let detalle of detalles) {
|
|
47
|
+
for (let i = 1; i <= 12; i++) {
|
|
48
|
+
if (copia[`Monto${i}`] == 0)
|
|
49
|
+
cuenta[`Monto${i}`] += parseFloat(detalle[`Monto${i}`]);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const getDesarrolloSuma = (actividad) => {
|
|
54
|
+
const ventasCantidad = actividad.Desarrollo.VentasCantidad.find((item) => item.RubroId == 'TOT01');
|
|
55
|
+
if (!ventasCantidad)
|
|
56
|
+
throw new Error('No se econtró el Monto de desarrollo');
|
|
57
|
+
let result = 0;
|
|
58
|
+
for (let i = 1; i <= actividad.Desarrollo.CantidadProyeccion; i++) {
|
|
59
|
+
result += parseFloat(ventasCantidad[`C-${i}`]);
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
62
|
+
};
|
|
63
|
+
const addIngresosM = (actividad, data) => {
|
|
64
|
+
const rubro = data.FlujoProyectadoMensualMap.get(`$${RUBRO_INGRESO}_0`);
|
|
65
|
+
const ingresos = actividad.Ventas.EstacionalidadCalc.find((item) => item.RubroId == 'TOT01');
|
|
66
|
+
if (!ingresos)
|
|
67
|
+
throw new Error('No se encontro la estacionalidad Calc de la actividad');
|
|
68
|
+
let row = Object.assign({}, rubro);
|
|
69
|
+
row.Descripcion = `Ingresos ${actividad.Desarrollo.ActividadGanadera}`;
|
|
70
|
+
row.Clasificador = 'CT';
|
|
71
|
+
row.Editable = false;
|
|
72
|
+
row.UUID = `${RUBRO_INGRESO}_${actividad.Desarrollo.ActividadEconomicaId}`;
|
|
73
|
+
row.RubroId = `${RUBRO_INGRESO}.1`;
|
|
74
|
+
for (let i = 1; i <= 12; i++) {
|
|
75
|
+
row[`Monto${i}`] = Math.round(parseFloat(ingresos[`C${i}`]) * 100) / 100;
|
|
76
|
+
}
|
|
77
|
+
data.FlujoProyectadoMensual.push(row);
|
|
78
|
+
};
|
|
79
|
+
const addCostosM = (actividad, data) => {
|
|
80
|
+
const rubro = data.FlujoProyectadoMensualMap.get(`$${RUBRO_COSTOS}_0`);
|
|
81
|
+
const costos = actividad.Costos.Calculo.find((item) => item.RubroId == 'TOT01');
|
|
82
|
+
if (!costos)
|
|
83
|
+
throw new Error('No se encontro el costo cálculo de la actividad');
|
|
84
|
+
let row = Object.assign({}, rubro);
|
|
85
|
+
row.Descripcion = `(-) Costos de Ventas ${actividad.Desarrollo.ActividadGanadera}`;
|
|
86
|
+
row.Clasificador = 'CT';
|
|
87
|
+
row.Editable = false;
|
|
88
|
+
row.UUID = `${RUBRO_COSTOS}_${actividad.Desarrollo.ActividadEconomicaId}`;
|
|
89
|
+
row.RubroId = `${RUBRO_COSTOS}.1`;
|
|
90
|
+
for (let i = 1; i <= 12; i++) {
|
|
91
|
+
row[`Monto${i}`] = Math.round(parseFloat(costos[`C-${i}`]) * 100) / 100;
|
|
92
|
+
}
|
|
93
|
+
data.FlujoProyectadoMensual.push(row);
|
|
94
|
+
};
|
|
95
|
+
const addGastosM = (actividad, data) => {
|
|
96
|
+
const rubro = data.FlujoProyectadoMensualMap.get(`$${RUBRO_GASTOS}_0`);
|
|
97
|
+
const otrosGastos = calcularOtrosGastos(actividad.OtrosGastos);
|
|
98
|
+
if (!otrosGastos)
|
|
99
|
+
throw new Error('No se encontro los gastos de la actividad');
|
|
100
|
+
let row = Object.assign({}, rubro);
|
|
101
|
+
row.Descripcion = `(-) Gastos Operativo ${actividad.Desarrollo.ActividadGanadera}`;
|
|
102
|
+
row.Clasificador = 'CT';
|
|
103
|
+
row.Editable = false;
|
|
104
|
+
row.UUID = `${RUBRO_GASTOS}_${actividad.Desarrollo.ActividadEconomicaId}`;
|
|
105
|
+
row.RubroId = `${RUBRO_GASTOS}.1`;
|
|
106
|
+
for (let i = 1; i <= 12; i++) {
|
|
107
|
+
row[`Monto${i}`] = Math.round(parseFloat(otrosGastos.GastosOperativos) * 100) / 100;
|
|
108
|
+
}
|
|
109
|
+
data.FlujoProyectadoMensual.push(row);
|
|
110
|
+
};
|
|
111
|
+
const otrosIngresoM = (actividad, data) => {
|
|
112
|
+
const rubro = data.FlujoProyectadoMensualMap.get(`$${RUBRO_OTROS_INGRESOS}_0`);
|
|
113
|
+
const otrosIngresos = actividad.Ventas.OtrosIngresos;
|
|
114
|
+
if (!otrosIngresos)
|
|
115
|
+
throw new Error('No se encontro la estacionalidad Calc de la actividad');
|
|
116
|
+
let row = Object.assign({}, rubro);
|
|
117
|
+
row.Descripcion = `Otros Ingresos Familiares ${actividad.Desarrollo.ActividadGanadera}`;
|
|
118
|
+
row.Clasificador = 'CT';
|
|
119
|
+
row.Editable = false;
|
|
120
|
+
row.UUID = `${RUBRO_OTROS_INGRESOS}_${actividad.Desarrollo.ActividadEconomicaId}`;
|
|
121
|
+
row.RubroId = `${RUBRO_OTROS_INGRESOS}.1`;
|
|
122
|
+
if (otrosIngresos.length == 0) {
|
|
123
|
+
const suma = otrosIngresos.reduce((acc, item) => {
|
|
124
|
+
acc += parseFloat(item.Monto);
|
|
125
|
+
return acc;
|
|
126
|
+
}, 0);
|
|
127
|
+
for (let i = 1; i <= 12; i++) {
|
|
128
|
+
row[`Monto${i}`] = suma;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
for (let i = 1; i <= 12; i++) {
|
|
133
|
+
row[`Monto${i}`] = Math.round(parseFloat(otrosIngresos[`C${i}`]) * 100) / 100;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
data.FlujoProyectadoMensual.push(row);
|
|
137
|
+
};
|
|
138
|
+
const gastosFamiliaresM = (actividad, data) => {
|
|
139
|
+
const rubro = data.FlujoProyectadoMensualMap.get(`$${RUBRO_GASTOS_FAMILIARES}_0`);
|
|
140
|
+
const otrosGastos = calcularOtrosGastos(actividad.OtrosGastos);
|
|
141
|
+
if (!otrosGastos)
|
|
142
|
+
throw new Error('No se encontro los gastos de la actividad');
|
|
143
|
+
let row = Object.assign({}, rubro);
|
|
144
|
+
row.Descripcion = `(-) Gastos Operativo ${actividad.Desarrollo.ActividadGanadera}`;
|
|
145
|
+
row.Clasificador = 'CT';
|
|
146
|
+
row.Editable = false;
|
|
147
|
+
row.UUID = `${RUBRO_GASTOS_FAMILIARES}_${actividad.Desarrollo.ActividadEconomicaId}`;
|
|
148
|
+
row.RubroId = `${RUBRO_GASTOS_FAMILIARES}.1`;
|
|
149
|
+
for (let i = 1; i <= 12; i++) {
|
|
150
|
+
row[`Monto${i}`] = Math.round(parseFloat(otrosGastos.gastosFamiliares) * 100) / 100;
|
|
151
|
+
}
|
|
152
|
+
data.FlujoProyectadoMensual.push(row);
|
|
153
|
+
};
|
|
154
|
+
const addCalculosBase = (data, sumaDesarrollo) => {
|
|
155
|
+
const ingresos = data.FlujoProyectadoMensualMap.get(`$${RUBRO_INGRESO}_0`);
|
|
156
|
+
let sumaIngresos = 0;
|
|
157
|
+
for (let i = 1; i <= 12; i++) {
|
|
158
|
+
sumaIngresos += parseFloat(ingresos[`Monto${i}`]);
|
|
159
|
+
}
|
|
160
|
+
let sumaHato = sumaDesarrollo.reduce((acc, item) => {
|
|
161
|
+
acc += item;
|
|
162
|
+
return acc;
|
|
163
|
+
}, 0);
|
|
164
|
+
const sumaProyectada = Math.round((sumaIngresos * data.Desarrollo.CantidadProyeccion) * 100) / 100;
|
|
165
|
+
let result = {
|
|
166
|
+
EsEngorde: data.Parametros.EsEngorde,
|
|
167
|
+
SumaAnnoBase: sumaProyectada,
|
|
168
|
+
SumaHato: sumaHato,
|
|
169
|
+
Conclusion: 'NA'
|
|
170
|
+
};
|
|
171
|
+
if (result.EsEngorde == 'SI' || result.SumaAnnoBase < result.SumaHato)
|
|
172
|
+
result.Conclusion = 'FLUJO_HISTORICO';
|
|
173
|
+
else {
|
|
174
|
+
if (result.SumaHato < result.SumaAnnoBase)
|
|
175
|
+
result.Conclusion = 'DESARROLLO_HATO';
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
const calcularOtrosGastos = (gastos) => {
|
|
179
|
+
const gastosOperativos = gastos.Operativos.reduce((acc, item) => {
|
|
180
|
+
acc += parseFloat(item.ImporteMensual);
|
|
181
|
+
return acc;
|
|
182
|
+
}, 0);
|
|
183
|
+
const gastosFamiliares = gastos.Familiares.reduce((acc, item) => {
|
|
184
|
+
acc += parseFloat(item.ImporteMensual);
|
|
185
|
+
return acc;
|
|
186
|
+
}, 0);
|
|
187
|
+
return {
|
|
188
|
+
GastosOperativos: Math.round(gastosOperativos * 100) / 100,
|
|
189
|
+
GastosFamiliares: Math.round(gastosFamiliares * 100) / 100
|
|
190
|
+
};
|
|
191
|
+
};
|
|
@@ -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}`];
|