bdpformulas 1.0.58 → 1.0.59
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/agriculture/balanceAgr.strategy.js +1 -102
- package/build/strategies/balance.strategy.d.ts +2 -0
- package/build/strategies/balance.strategy.js +112 -5
- package/build/strategies/common/balance.calc.d.ts +0 -1
- package/build/strategies/common/balance.calc.js +1 -3
- package/build/strategies/pecuary/Constantes.d.ts +1 -1
- package/build/strategies/pecuary/anexo.strategy.d.ts +2 -2
- package/build/strategies/pecuary/anexo.strategy.js +10 -5
- package/build/strategies/pecuary/balancePec.strategy.d.ts +2 -1
- package/build/strategies/pecuary/balancePec.strategy.js +45 -17
- package/build/strategies/production/balancePrd.strategy.d.ts +2 -1
- package/build/strategies/production/balancePrd.strategy.js +52 -21
- package/package.json +1 -1
|
@@ -1,98 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const balanceAux_calc_1 = require("../common/balanceCalculos/balanceAux.calc");
|
|
4
|
-
const utils_1 = require("../utils");
|
|
5
4
|
class BalanceAgrStrategy {
|
|
6
5
|
actividades;
|
|
7
6
|
camposCalculadosDefinidos;
|
|
8
7
|
constructor() {
|
|
9
8
|
this.actividades = [];
|
|
10
9
|
this.camposCalculadosDefinidos = [
|
|
11
|
-
{
|
|
12
|
-
RubroId: 'ACT_CN_11001',
|
|
13
|
-
Correlativos: 'ultima',
|
|
14
|
-
Familiar: true,
|
|
15
|
-
Empresa: true
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
RubroId: 'ACT_CN_11002',
|
|
19
|
-
Correlativos: 'ultima',
|
|
20
|
-
Familiar: true,
|
|
21
|
-
Empresa: true
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
RubroId: 'ACT_CN_11003',
|
|
25
|
-
Correlativos: 'ultima',
|
|
26
|
-
Familiar: true,
|
|
27
|
-
Empresa: true
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
RubroId: 'ACT_CN_12001',
|
|
31
|
-
Correlativos: 'ultima',
|
|
32
|
-
Familiar: true,
|
|
33
|
-
Empresa: true
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
RubroId: 'ACT_CN_12002',
|
|
37
|
-
Correlativos: 'ultima',
|
|
38
|
-
Familiar: true,
|
|
39
|
-
Empresa: true
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
RubroId: 'ACT_CN_12003',
|
|
43
|
-
Correlativos: 'ultima',
|
|
44
|
-
Familiar: true,
|
|
45
|
-
Empresa: true
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
RubroId: 'ACT_CN_12004',
|
|
49
|
-
Correlativos: 'ultima',
|
|
50
|
-
Familiar: true,
|
|
51
|
-
Empresa: true
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
RubroId: 'ACT_CN_12005',
|
|
55
|
-
Correlativos: 'ultima',
|
|
56
|
-
Familiar: true,
|
|
57
|
-
Empresa: true
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
RubroId: 'ACT_CN_21001',
|
|
61
|
-
Correlativos: 'ultima',
|
|
62
|
-
Familiar: true,
|
|
63
|
-
Empresa: true
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
RubroId: 'ACT_CN_21002',
|
|
67
|
-
Correlativos: 'ultima',
|
|
68
|
-
Familiar: true,
|
|
69
|
-
Empresa: true
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
RubroId: 'ACT_CN_22001',
|
|
73
|
-
Correlativos: 'ultima',
|
|
74
|
-
Familiar: true,
|
|
75
|
-
Empresa: true
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
RubroId: 'ACT_CN_30001',
|
|
79
|
-
Correlativos: '*',
|
|
80
|
-
Familiar: true,
|
|
81
|
-
Empresa: true
|
|
82
|
-
},
|
|
83
|
-
//eeff
|
|
84
|
-
{
|
|
85
|
-
RubroId: 'ACT_CN_40001',
|
|
86
|
-
Correlativos: '*',
|
|
87
|
-
Familiar: false,
|
|
88
|
-
Empresa: true
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
RubroId: 'ACT_CN_41001',
|
|
92
|
-
Correlativos: 'ultima',
|
|
93
|
-
Familiar: false,
|
|
94
|
-
Empresa: true
|
|
95
|
-
},
|
|
96
10
|
{
|
|
97
11
|
RubroId: 'ACT_CN_41002',
|
|
98
12
|
Correlativos: '*',
|
|
@@ -105,18 +19,6 @@ class BalanceAgrStrategy {
|
|
|
105
19
|
Familiar: false,
|
|
106
20
|
Empresa: true
|
|
107
21
|
},
|
|
108
|
-
{
|
|
109
|
-
RubroId: 'ACT_CN_43002',
|
|
110
|
-
Correlativos: '*',
|
|
111
|
-
Familiar: false,
|
|
112
|
-
Empresa: true
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
RubroId: 'ACT_CN_45001',
|
|
116
|
-
Correlativos: 'ultima',
|
|
117
|
-
Familiar: true,
|
|
118
|
-
Empresa: false
|
|
119
|
-
},
|
|
120
22
|
{
|
|
121
23
|
RubroId: 'ACT_CN_45003',
|
|
122
24
|
Correlativos: 'ultima',
|
|
@@ -134,10 +36,7 @@ class BalanceAgrStrategy {
|
|
|
134
36
|
acumuladoActividades = addAcumulado(acumuladoActividades, actividadCalculada);
|
|
135
37
|
}
|
|
136
38
|
data.eerrMap = calcularEERR(data.eerrMap, data.eerr, acumuladoActividades);
|
|
137
|
-
data.
|
|
138
|
-
cantidadGestiones: data.cantidadGestiones,
|
|
139
|
-
definidos: this.camposCalculadosDefinidos
|
|
140
|
-
});
|
|
39
|
+
data.camposCalculadosDefinidos = this.camposCalculadosDefinidos;
|
|
141
40
|
return data;
|
|
142
41
|
}
|
|
143
42
|
}
|
|
@@ -28,7 +28,104 @@ const commmon = __importStar(require("./common/balance.calc"));
|
|
|
28
28
|
const declaracionJurada_calc_1 = require("./common/declaracionJurada.calc");
|
|
29
29
|
//import { setFlujoInEERR } from './common/balanceCalculos/flujoAux.calc'
|
|
30
30
|
const utils_1 = require("./eeff/admFinanciera/utils");
|
|
31
|
+
const utils_2 = require("./utils");
|
|
31
32
|
class Balance {
|
|
33
|
+
camposCalculadosDefinidos;
|
|
34
|
+
constructor() {
|
|
35
|
+
this.camposCalculadosDefinidos = [
|
|
36
|
+
{
|
|
37
|
+
RubroId: 'ACT_CN_11001',
|
|
38
|
+
Correlativos: 'ultima',
|
|
39
|
+
Familiar: true,
|
|
40
|
+
Empresa: true
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
RubroId: 'ACT_CN_11002',
|
|
44
|
+
Correlativos: 'ultima',
|
|
45
|
+
Familiar: true,
|
|
46
|
+
Empresa: true
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
RubroId: 'ACT_CN_11003',
|
|
50
|
+
Correlativos: 'ultima',
|
|
51
|
+
Familiar: true,
|
|
52
|
+
Empresa: true
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
RubroId: 'ACT_CN_12001',
|
|
56
|
+
Correlativos: 'ultima',
|
|
57
|
+
Familiar: true,
|
|
58
|
+
Empresa: true
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
RubroId: 'ACT_CN_12002',
|
|
62
|
+
Correlativos: 'ultima',
|
|
63
|
+
Familiar: true,
|
|
64
|
+
Empresa: true
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
RubroId: 'ACT_CN_12003',
|
|
68
|
+
Correlativos: 'ultima',
|
|
69
|
+
Familiar: true,
|
|
70
|
+
Empresa: true
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
RubroId: 'ACT_CN_21001',
|
|
74
|
+
Correlativos: 'ultima',
|
|
75
|
+
Familiar: true,
|
|
76
|
+
Empresa: true
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
RubroId: 'ACT_CN_21002',
|
|
80
|
+
Correlativos: 'ultima',
|
|
81
|
+
Familiar: true,
|
|
82
|
+
Empresa: true
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
RubroId: 'ACT_CN_22001',
|
|
86
|
+
Correlativos: 'ultima',
|
|
87
|
+
Familiar: true,
|
|
88
|
+
Empresa: true
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
RubroId: 'ACT_CN_22002',
|
|
92
|
+
Correlativos: 'ultima',
|
|
93
|
+
Familiar: true,
|
|
94
|
+
Empresa: true
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
RubroId: 'ACT_CN_30001',
|
|
98
|
+
Correlativos: '*',
|
|
99
|
+
Familiar: true,
|
|
100
|
+
Empresa: true
|
|
101
|
+
},
|
|
102
|
+
//eeff
|
|
103
|
+
{
|
|
104
|
+
RubroId: 'ACT_CN_40001',
|
|
105
|
+
Correlativos: '*',
|
|
106
|
+
Familiar: false,
|
|
107
|
+
Empresa: true
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
RubroId: 'ACT_CN_41001',
|
|
111
|
+
Correlativos: 'ultima',
|
|
112
|
+
Familiar: false,
|
|
113
|
+
Empresa: true
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
RubroId: 'ACT_CN_43002',
|
|
117
|
+
Correlativos: '*',
|
|
118
|
+
Familiar: false,
|
|
119
|
+
Empresa: true
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
RubroId: 'ACT_CN_45001',
|
|
123
|
+
Correlativos: 'ultima',
|
|
124
|
+
Familiar: true,
|
|
125
|
+
Empresa: false
|
|
126
|
+
}
|
|
127
|
+
];
|
|
128
|
+
}
|
|
32
129
|
execute(data) {
|
|
33
130
|
const result = {};
|
|
34
131
|
const balanceClone = balanceCalc.trasponer(commmon.clone(data.balance));
|
|
@@ -41,7 +138,13 @@ class Balance {
|
|
|
41
138
|
//setFlujoInEERR(data)
|
|
42
139
|
if (data.strategy != null)
|
|
43
140
|
data = data.strategy.execute(data);
|
|
44
|
-
result.camposCalculados =
|
|
141
|
+
result.camposCalculados = (0, utils_2.formatCamposCalculados)({
|
|
142
|
+
cantidadGestiones: data.cantidadGestiones,
|
|
143
|
+
definidos: [
|
|
144
|
+
...this.camposCalculadosDefinidos,
|
|
145
|
+
...data.camposCalculadosDefinidos
|
|
146
|
+
]
|
|
147
|
+
});
|
|
45
148
|
delete data.eerrMap;
|
|
46
149
|
data.balance = Array.from(balanceMap.values());
|
|
47
150
|
data.eerr = Array.from(eerrMap.values());
|
|
@@ -197,10 +300,14 @@ function calcularPorcentajes({ rubroDatos, rubroPorcentajes, datos, cantidadGest
|
|
|
197
300
|
const monto = montos.find((el) => el.Correlativo === item.Correlativo);
|
|
198
301
|
if (item.Correlativo === cantidadGestiones) {
|
|
199
302
|
if (porcentaje) {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
100;
|
|
303
|
+
const divisor = (0, utils_1.ourParseFloat)(monto?.MontoEmpresa);
|
|
304
|
+
if (divisor) {
|
|
305
|
+
porcentaje.MontoEmpresa =
|
|
306
|
+
((0, utils_1.ourParseFloat)(item.MontoEmpresa) / divisor) * 100;
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
porcentaje.MontoEmpresa = 0;
|
|
310
|
+
}
|
|
204
311
|
}
|
|
205
312
|
}
|
|
206
313
|
else {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.trasponer = exports.getBalanceHashMap = exports.clone = void 0;
|
|
4
4
|
const clone = (data) => {
|
|
5
5
|
return JSON.parse(JSON.stringify(data));
|
|
6
6
|
};
|
|
@@ -60,5 +60,3 @@ const trasponer = (data) => {
|
|
|
60
60
|
return result;
|
|
61
61
|
};
|
|
62
62
|
exports.trasponer = trasponer;
|
|
63
|
-
const calcularPorcentaje = (balance) => { };
|
|
64
|
-
exports.calcularPorcentaje = calcularPorcentaje;
|
|
@@ -20,5 +20,5 @@ export declare const RUBROS: {
|
|
|
20
20
|
ACT_PEC_NOV: string;
|
|
21
21
|
ACT_PEC_SALDO: string;
|
|
22
22
|
};
|
|
23
|
-
export declare const getOrden: (rubro: string) => 3 | 1 | 2 | 4 |
|
|
23
|
+
export declare const getOrden: (rubro: string) => 3 | 1 | 2 | 4 | 6 | 5 | 7 | 8 | 9 | 10 | undefined;
|
|
24
24
|
export declare const getMap: (array: any[], key: string) => any;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Strategy } from
|
|
2
|
-
import { AuxiliarSchemaType } from
|
|
1
|
+
import { Strategy } from '../../strategy.interface';
|
|
2
|
+
import { AuxiliarSchemaType } from '../../models/pecuary/auxiliar.schema';
|
|
3
3
|
export default class Auxiliar implements Strategy {
|
|
4
4
|
execute(data: AuxiliarSchemaType): any;
|
|
5
5
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("../eeff/admFinanciera/utils");
|
|
3
4
|
//@ts-ignore
|
|
4
5
|
const calcularHato = (data) => {
|
|
5
6
|
const gestiones = data.reduce((acc, item) => {
|
|
@@ -50,7 +51,7 @@ const calcularHato = (data) => {
|
|
|
50
51
|
}
|
|
51
52
|
if (!(item.RubroId in acc)) {
|
|
52
53
|
acc[item.RubroId] = item.CantidadCabezas * item.PrecioCabeza;
|
|
53
|
-
acc.Total = acc.Total +
|
|
54
|
+
acc.Total = acc.Total + item.CantidadCabezas * item.PrecioCabeza;
|
|
54
55
|
}
|
|
55
56
|
return acc;
|
|
56
57
|
}, {});
|
|
@@ -62,11 +63,15 @@ class Auxiliar {
|
|
|
62
63
|
data.PropiedadesGanaderas.forEach((item) => {
|
|
63
64
|
item.Total = 0;
|
|
64
65
|
item.Rubros.forEach((rubro) => {
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
const precioCabezaBalance = (0, utils_1.ourParseFloat)(rubro.PrecioCabezaBalance);
|
|
67
|
+
if (precioCabezaBalance)
|
|
68
|
+
rubro.Total =
|
|
69
|
+
parseFloat(rubro.CantidadCabezas) * precioCabezaBalance;
|
|
67
70
|
else
|
|
68
|
-
rubro.Total =
|
|
69
|
-
|
|
71
|
+
rubro.Total =
|
|
72
|
+
parseFloat(rubro.CantidadCabezas) *
|
|
73
|
+
parseFloat(rubro.PrecioCabeza);
|
|
74
|
+
item.Total += rubro.Total;
|
|
70
75
|
});
|
|
71
76
|
});
|
|
72
77
|
data.HistoricoHato = calcularHato(data.HistoricoHato);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Strategy } from
|
|
1
|
+
import { Strategy } from '../../strategy.interface';
|
|
2
2
|
export default class BalancePecStrategy implements Strategy {
|
|
3
3
|
actividades: any[];
|
|
4
|
+
private camposCalculadosDefinidos;
|
|
4
5
|
constructor();
|
|
5
6
|
execute(data: any): any;
|
|
6
7
|
}
|
|
@@ -6,8 +6,23 @@ const gCuentaGasto = 'ACT_CN_43002';
|
|
|
6
6
|
const gCuentaOtrosIngresosDet = 'ACT_CN_45001';
|
|
7
7
|
class BalancePecStrategy {
|
|
8
8
|
actividades;
|
|
9
|
+
camposCalculadosDefinidos;
|
|
9
10
|
constructor() {
|
|
10
11
|
this.actividades = [];
|
|
12
|
+
this.camposCalculadosDefinidos = [
|
|
13
|
+
{
|
|
14
|
+
RubroId: 'ACT_CN_12004',
|
|
15
|
+
Correlativos: 'ultima',
|
|
16
|
+
Familiar: true,
|
|
17
|
+
Empresa: true
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
RubroId: 'ACT_CN_41002',
|
|
21
|
+
Correlativos: '*',
|
|
22
|
+
Familiar: false,
|
|
23
|
+
Empresa: true
|
|
24
|
+
}
|
|
25
|
+
];
|
|
11
26
|
}
|
|
12
27
|
execute(data) {
|
|
13
28
|
if (!this.actividades || this.actividades.length == 0)
|
|
@@ -15,7 +30,7 @@ class BalancePecStrategy {
|
|
|
15
30
|
const cuentasIngresosCopy = getCuentasCopy(data, gCuentaIngreso);
|
|
16
31
|
const cuentasCostoCopy = getCuentasCopy(data, gCuentaCosto);
|
|
17
32
|
const cuentaGastoCopy = getCuentasCopy(data, gCuentaGasto);
|
|
18
|
-
for (
|
|
33
|
+
for (const actividad of this.actividades) {
|
|
19
34
|
anadirIngresosAuxPec(actividad, data);
|
|
20
35
|
anadirIngresoVenta(actividad, data);
|
|
21
36
|
anadirCosto(actividad, data);
|
|
@@ -25,6 +40,7 @@ class BalancePecStrategy {
|
|
|
25
40
|
sumarizarCuentas(`${gCuentaIngreso}.1`, gCuentaIngreso, data, cuentasIngresosCopy);
|
|
26
41
|
sumarizarCuentas(`${gCuentaCosto}.1`, gCuentaCosto, data, cuentasCostoCopy);
|
|
27
42
|
sumarizarCuentas(`${gCuentaGasto}.1`, gCuentaGasto, data, cuentaGastoCopy);
|
|
43
|
+
data.camposCalculadosDefinidos = this.camposCalculadosDefinidos;
|
|
28
44
|
return data;
|
|
29
45
|
}
|
|
30
46
|
}
|
|
@@ -32,12 +48,14 @@ exports.default = BalancePecStrategy;
|
|
|
32
48
|
const getCuentasCopy = (data, rubroId) => {
|
|
33
49
|
if (!data.eerr || data.eerr.length == 0)
|
|
34
50
|
throw new Error('Debe ingresar cuentas EERR');
|
|
35
|
-
|
|
51
|
+
const originalData = new Map();
|
|
36
52
|
const rango = data.eerr[0].Rango;
|
|
37
53
|
for (let i = 1; i <= rango; i++) {
|
|
38
|
-
|
|
39
|
-
cuentaIngreso.MontoEmpresa =
|
|
40
|
-
|
|
54
|
+
const cuentaIngreso = data.eerrMap.get(`${rubroId}_${i}`);
|
|
55
|
+
cuentaIngreso.MontoEmpresa =
|
|
56
|
+
Math.round(parseFloat(cuentaIngreso.MontoEmpresa) * 100) / 100;
|
|
57
|
+
cuentaIngreso.MontoFamiliar =
|
|
58
|
+
Math.round(parseFloat(cuentaIngreso.MontoFamiliar) * 100) / 100;
|
|
41
59
|
originalData.set(`${rubroId}_${i}`, { ...cuentaIngreso });
|
|
42
60
|
}
|
|
43
61
|
return originalData;
|
|
@@ -46,7 +64,7 @@ const anadirIngresosAuxPec = (actividad, data) => {
|
|
|
46
64
|
const rango = data.eerr[0].Rango;
|
|
47
65
|
for (let i = 1; i <= rango - 1; i++) {
|
|
48
66
|
const cuentaIngreso = data.eerrMap.get(`${gCuentaIngreso}_${i}`);
|
|
49
|
-
|
|
67
|
+
const copy = { ...cuentaIngreso };
|
|
50
68
|
copy.RubroId = `${gCuentaIngreso}.1`;
|
|
51
69
|
copy.Descripcion = `Ingresos por Ventas ${actividad.Desarrollo.ActividadGanadera}`;
|
|
52
70
|
copy.UUID = `${gCuentaIngreso}_${actividad.AuxPec.ActividadEconomicaId}_${i}`;
|
|
@@ -54,10 +72,13 @@ const anadirIngresosAuxPec = (actividad, data) => {
|
|
|
54
72
|
copy.MontoFamiliar = 0;
|
|
55
73
|
copy.Correlativo = i;
|
|
56
74
|
copy.Clasificador = 'CT';
|
|
57
|
-
if (actividad.AuxPec &&
|
|
75
|
+
if (actividad.AuxPec &&
|
|
76
|
+
actividad.AuxPec.HistoricoHato &&
|
|
77
|
+
actividad.AuxPec.HistoricoHato.length > 0) {
|
|
58
78
|
const historico = actividad.AuxPec.HistoricoHato.find((value) => value.Gestion === i && value.key == 'TOTALES');
|
|
59
79
|
if (historico)
|
|
60
|
-
copy.MontoEmpresa =
|
|
80
|
+
copy.MontoEmpresa =
|
|
81
|
+
Math.round(parseFloat(historico.Total) * 100) / 100;
|
|
61
82
|
}
|
|
62
83
|
data.eerr.push(copy);
|
|
63
84
|
}
|
|
@@ -65,7 +86,7 @@ const anadirIngresosAuxPec = (actividad, data) => {
|
|
|
65
86
|
const anadirIngresoVenta = (actividad, data) => {
|
|
66
87
|
const rango = data.eerr[0].Rango;
|
|
67
88
|
const cuentaIngreso = data.eerrMap.get(`${gCuentaIngreso}${rango}`);
|
|
68
|
-
|
|
89
|
+
const copy = { ...cuentaIngreso };
|
|
69
90
|
copy.RubroId = `${gCuentaIngreso}.1`;
|
|
70
91
|
copy.Descripcion = `Ingresos por Ventas ${actividad.Desarrollo.ActividadGanadera}`;
|
|
71
92
|
copy.UUID = `${gCuentaIngreso}_${actividad.AuxPec.ActividadEconomicaId}_${rango}`;
|
|
@@ -85,7 +106,7 @@ const anadirCosto = (actividad, data) => {
|
|
|
85
106
|
const rango = data.eerr[0].Rango;
|
|
86
107
|
const cuentaCosto = data.eerrMap.get(`${gCuentaCosto}_${rango}`);
|
|
87
108
|
for (let i = 1; i <= rango; i++) {
|
|
88
|
-
|
|
109
|
+
const copy = { ...cuentaCosto };
|
|
89
110
|
copy.RubroId = `${gCuentaCosto}.1`;
|
|
90
111
|
copy.Descripcion = `Costos de Ventas ${actividad.Desarrollo.ActividadGanadera}`;
|
|
91
112
|
copy.UUID = `${gCuentaCosto}_${actividad.AuxPec.ActividadEconomicaId}_${i}`;
|
|
@@ -93,7 +114,9 @@ const anadirCosto = (actividad, data) => {
|
|
|
93
114
|
copy.MontoFamiliar = 0;
|
|
94
115
|
copy.Correlativo = i;
|
|
95
116
|
copy.Clasificador = 'CT';
|
|
96
|
-
if (rango == i &&
|
|
117
|
+
if (rango == i &&
|
|
118
|
+
actividad.Costos.Calculo &&
|
|
119
|
+
actividad.Costos.Calculo.length > 0) {
|
|
97
120
|
const monto = actividad.Costos.Calculo.find((value) => value.RubroId === 'TOT01');
|
|
98
121
|
if (!monto)
|
|
99
122
|
throw new Error('No existe el rubro TOT01 en los costos');
|
|
@@ -106,7 +129,7 @@ const anadirGasto = (actividad, data) => {
|
|
|
106
129
|
const rango = data.eerr[0].Rango;
|
|
107
130
|
const cuentaGasto = data.eerrMap.get(`${gCuentaGasto}_${rango}`);
|
|
108
131
|
for (let i = 1; i <= rango; i++) {
|
|
109
|
-
|
|
132
|
+
const copy = { ...cuentaGasto };
|
|
110
133
|
copy.RubroId = `${gCuentaGasto}.1`;
|
|
111
134
|
copy.UUID = `${gCuentaGasto}_${actividad.AuxPec.ActividadEconomicaId}_${i}`;
|
|
112
135
|
copy.Descripcion = `Gastos Administrativos Operativos ${actividad.Desarrollo.ActividadGanadera}`;
|
|
@@ -116,7 +139,8 @@ const anadirGasto = (actividad, data) => {
|
|
|
116
139
|
copy.Clasificador = 'CT';
|
|
117
140
|
if (rango == i) {
|
|
118
141
|
const otrosGastos = calcularOtrosGastos(actividad.OtrosGastos);
|
|
119
|
-
copy.MontoEmpresa =
|
|
142
|
+
copy.MontoEmpresa =
|
|
143
|
+
Math.round(parseFloat(otrosGastos.GastosOperativos) * 100) / 100;
|
|
120
144
|
}
|
|
121
145
|
data.eerr.push(copy);
|
|
122
146
|
}
|
|
@@ -139,14 +163,16 @@ const anadirOtrosIngresos = (actividad, data) => {
|
|
|
139
163
|
const rango = data.eerr[0].Rango;
|
|
140
164
|
const cuentaOtrosIngresos = data.eerr.find((item) => item.RubroId == gCuentaOtrosIngresosDet);
|
|
141
165
|
for (let i = 1; i <= rango; i++) {
|
|
142
|
-
|
|
166
|
+
const copy = { ...cuentaOtrosIngresos };
|
|
143
167
|
copy.UUID = `${gCuentaOtrosIngresosDet}_${actividad.AuxPec.ActividadEconomicaId}_${rango}`;
|
|
144
168
|
copy.Descripcion = `Otros Ingresos ${actividad.Desarrollo.ActividadGanadera}`;
|
|
145
169
|
copy.MontoEmpresa = 0;
|
|
146
170
|
copy.MontoFamiliar = 0;
|
|
147
171
|
copy.Correlativo = i;
|
|
148
172
|
copy.Clasificador = 'CT';
|
|
149
|
-
if (rango == i &&
|
|
173
|
+
if (rango == i &&
|
|
174
|
+
actividad.Ventas &&
|
|
175
|
+
actividad.Ventas.OtrosIngresos &&
|
|
150
176
|
actividad.Ventas.OtrosIngresos.length > 0) {
|
|
151
177
|
copy.MontoFamiliar = actividad.Ventas.OtrosIngresos.reduce((acc, item) => {
|
|
152
178
|
acc += parseFloat(item.Monto);
|
|
@@ -170,8 +196,10 @@ const sumarizarCuentas = (rubroOrigen, rubroDestino, data, dataOriginal) => {
|
|
|
170
196
|
cuentaDestino.MontoEmpresa += cuentaOrigen.MontoEmpresa;
|
|
171
197
|
if (original.MontoFamiliar == 0)
|
|
172
198
|
cuentaDestino.MontoFamiliar += cuentaOrigen.MontoFamiliar;
|
|
173
|
-
cuentaDestino.MontoEmpresa =
|
|
174
|
-
|
|
199
|
+
cuentaDestino.MontoEmpresa =
|
|
200
|
+
Math.round(cuentaDestino.MontoEmpresa * 100) / 100;
|
|
201
|
+
cuentaDestino.MontoFamiliar =
|
|
202
|
+
Math.round(cuentaDestino.MontoFamiliar * 100) / 100;
|
|
175
203
|
}
|
|
176
204
|
}
|
|
177
205
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Strategy } from
|
|
1
|
+
import { Strategy } from '../../strategy.interface';
|
|
2
2
|
export default class BalancePrdStrategy implements Strategy {
|
|
3
3
|
actividades: any[];
|
|
4
|
+
private camposCalculadosDefinidos;
|
|
4
5
|
constructor();
|
|
5
6
|
execute(data: any): any;
|
|
6
7
|
}
|
|
@@ -7,8 +7,29 @@ const gCuentaGastoFamiliares = 'ACT_CN_45003';
|
|
|
7
7
|
const gCuentaOtrosIngresosDet = 'ACT_CN_45001';
|
|
8
8
|
class BalancePrdStrategy {
|
|
9
9
|
actividades;
|
|
10
|
+
camposCalculadosDefinidos;
|
|
10
11
|
constructor() {
|
|
11
12
|
this.actividades = [];
|
|
13
|
+
this.camposCalculadosDefinidos = [
|
|
14
|
+
{
|
|
15
|
+
RubroId: 'ACT_CN_41002',
|
|
16
|
+
Correlativos: '*',
|
|
17
|
+
Familiar: true,
|
|
18
|
+
Empresa: true
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
RubroId: 'ACT_CN_43001',
|
|
22
|
+
Correlativos: 'ultima',
|
|
23
|
+
Familiar: false,
|
|
24
|
+
Empresa: true
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
RubroId: 'ACT_CN_45003',
|
|
28
|
+
Correlativos: 'ultima',
|
|
29
|
+
Familiar: true,
|
|
30
|
+
Empresa: false
|
|
31
|
+
}
|
|
32
|
+
];
|
|
12
33
|
}
|
|
13
34
|
execute(data) {
|
|
14
35
|
if (!this.actividades || this.actividades.length == 0)
|
|
@@ -20,7 +41,7 @@ class BalancePrdStrategy {
|
|
|
20
41
|
//@ts-ignore
|
|
21
42
|
const cuentaGastoCopy = getCuentasCopy(data, gCuentaGasto);
|
|
22
43
|
const cuentaGastoFamiliarCopy = getCuentasCopy(data, gCuentaGastoFamiliares);
|
|
23
|
-
for (
|
|
44
|
+
for (const actividad of this.actividades) {
|
|
24
45
|
anadirIngreso(actividad, data);
|
|
25
46
|
anadirCosto(actividad, data);
|
|
26
47
|
anadirGasto(actividad, data);
|
|
@@ -31,6 +52,7 @@ class BalancePrdStrategy {
|
|
|
31
52
|
sumarizarCuentas(`${gCuentaCosto}.1`, gCuentaCosto, data, cuentasCostoCopy);
|
|
32
53
|
sumarizarCuentas(`${gCuentaGasto}.1`, gCuentaGasto, data, cuentaGastoCopy);
|
|
33
54
|
sumarizarCuentas(`${gCuentaGastoFamiliares}.1`, gCuentaGastoFamiliares, data, cuentaGastoFamiliarCopy);
|
|
55
|
+
data.camposCalculadosDefinidos = this.camposCalculadosDefinidos;
|
|
34
56
|
return data;
|
|
35
57
|
}
|
|
36
58
|
}
|
|
@@ -38,12 +60,14 @@ exports.default = BalancePrdStrategy;
|
|
|
38
60
|
const getCuentasCopy = (data, rubroId) => {
|
|
39
61
|
if (!data.eerr || data.eerr.length == 0)
|
|
40
62
|
throw new Error('Debe ingresar cuentas EERR');
|
|
41
|
-
|
|
63
|
+
const originalData = new Map();
|
|
42
64
|
const rango = data.eerr[0].Rango;
|
|
43
65
|
for (let i = 1; i <= rango; i++) {
|
|
44
|
-
|
|
45
|
-
cuentaIngreso.MontoEmpresa =
|
|
46
|
-
|
|
66
|
+
const cuentaIngreso = data.eerrMap.get(`${rubroId}_${i}`);
|
|
67
|
+
cuentaIngreso.MontoEmpresa =
|
|
68
|
+
Math.round(parseFloat(cuentaIngreso.MontoEmpresa) * 100) / 100;
|
|
69
|
+
cuentaIngreso.MontoFamiliar =
|
|
70
|
+
Math.round(parseFloat(cuentaIngreso.MontoFamiliar) * 100) / 100;
|
|
47
71
|
originalData.set(`${rubroId}_${i}`, { ...cuentaIngreso });
|
|
48
72
|
}
|
|
49
73
|
return originalData;
|
|
@@ -53,11 +77,11 @@ const anadirIngreso = (actividad, data) => {
|
|
|
53
77
|
const productos = actividad.Ventas.Productos;
|
|
54
78
|
if (productos && productos.length > 0) {
|
|
55
79
|
for (const producto of productos) {
|
|
56
|
-
const subtotal = actividad.Ventas.
|
|
57
|
-
|
|
80
|
+
const subtotal = actividad.Ventas.Ingresos.find((item) => item.Id == 'SUBTOTAL' &&
|
|
81
|
+
item.ProductoId == producto.ProductoId);
|
|
58
82
|
for (let i = 1; i <= rango; i++) {
|
|
59
83
|
const cuentaIngreso = data.eerrMap.get(`${gCuentaIngreso}_${i}`);
|
|
60
|
-
|
|
84
|
+
const copy = { ...cuentaIngreso };
|
|
61
85
|
copy.RubroId = `${gCuentaIngreso}.1`;
|
|
62
86
|
copy.Descripcion = `Ingresos por Ventas ${producto.ProductoId} ${producto.Descripcion}`;
|
|
63
87
|
copy.UUID = `${gCuentaIngreso}_${actividad.ActividadEconomicaId}_${producto.ProductoId}_${i}`;
|
|
@@ -66,7 +90,8 @@ const anadirIngreso = (actividad, data) => {
|
|
|
66
90
|
copy.Correlativo = i;
|
|
67
91
|
copy.Clasificador = 'CT';
|
|
68
92
|
if (subtotal && subtotal[`C-${i}`]) {
|
|
69
|
-
copy.MontoEmpresa =
|
|
93
|
+
copy.MontoEmpresa =
|
|
94
|
+
Math.round(parseFloat(subtotal[`C-${i}`]) * 100) / 100;
|
|
70
95
|
}
|
|
71
96
|
data.eerr.push(copy);
|
|
72
97
|
}
|
|
@@ -78,11 +103,10 @@ const anadirCosto = (actividad, data) => {
|
|
|
78
103
|
const productos = actividad.Ventas.Productos;
|
|
79
104
|
if (productos && productos.length > 0) {
|
|
80
105
|
for (const producto of productos) {
|
|
81
|
-
const subtotal = actividad.
|
|
82
|
-
Costos.Meses.find((item) => item.ProductoId == producto.ProductoId);
|
|
106
|
+
const subtotal = actividad.Costos.Meses.find((item) => item.ProductoId == producto.ProductoId);
|
|
83
107
|
for (let i = 1; i <= rango; i++) {
|
|
84
108
|
const cuentaIngreso = data.eerrMap.get(`${gCuentaCosto}_${i}`);
|
|
85
|
-
|
|
109
|
+
const copy = { ...cuentaIngreso };
|
|
86
110
|
copy.RubroId = `${gCuentaCosto}.1`;
|
|
87
111
|
copy.Descripcion = `Ingresos por Ventas ${producto.ProductoId} ${producto.Descripcion}`;
|
|
88
112
|
copy.UUID = `${gCuentaCosto}_${actividad.ActividadEconomicaId}_${producto.ProductoId}_${i}`;
|
|
@@ -91,7 +115,8 @@ const anadirCosto = (actividad, data) => {
|
|
|
91
115
|
copy.Correlativo = i;
|
|
92
116
|
copy.Clasificador = 'CT';
|
|
93
117
|
if (i == rango && subtotal) {
|
|
94
|
-
copy.MontoEmpresa =
|
|
118
|
+
copy.MontoEmpresa =
|
|
119
|
+
Math.round(parseFloat(subtotal.Total) * 100) / 100;
|
|
95
120
|
}
|
|
96
121
|
data.eerr.push(copy);
|
|
97
122
|
}
|
|
@@ -102,7 +127,7 @@ const anadirGasto = (actividad, data) => {
|
|
|
102
127
|
const rango = data.eerr[0].Rango;
|
|
103
128
|
const cuentaGasto = data.eerrMap.get(`${gCuentaGasto}_${rango}`);
|
|
104
129
|
for (let i = 1; i <= rango; i++) {
|
|
105
|
-
|
|
130
|
+
const copy = { ...cuentaGasto };
|
|
106
131
|
copy.RubroId = `${gCuentaGasto}.1`;
|
|
107
132
|
copy.UUID = `${gCuentaGasto}_${actividad.ActividadEconomicaId}_${i}`;
|
|
108
133
|
copy.Descripcion = `Gastos Administrativos Operativos Actividad: ${actividad.ActividadEconomicaId}`;
|
|
@@ -112,7 +137,8 @@ const anadirGasto = (actividad, data) => {
|
|
|
112
137
|
copy.Clasificador = 'CT';
|
|
113
138
|
if (rango == i) {
|
|
114
139
|
const otrosGastos = calcularOtrosGastos(actividad.OtrosGastos);
|
|
115
|
-
copy.MontoEmpresa =
|
|
140
|
+
copy.MontoEmpresa =
|
|
141
|
+
Math.round(parseFloat(otrosGastos.GastosOperativos) * 100) / 100;
|
|
116
142
|
}
|
|
117
143
|
data.eerr.push(copy);
|
|
118
144
|
}
|
|
@@ -121,7 +147,7 @@ const anadirGastoFamiliares = (actividad, data) => {
|
|
|
121
147
|
const rango = data.eerr[0].Rango;
|
|
122
148
|
const cuentaGasto = data.eerrMap.get(`${gCuentaGastoFamiliares}_${rango}`);
|
|
123
149
|
for (let i = 1; i <= rango; i++) {
|
|
124
|
-
|
|
150
|
+
const copy = { ...cuentaGasto };
|
|
125
151
|
copy.RubroId = `${gCuentaGastoFamiliares}.1`;
|
|
126
152
|
copy.UUID = `${gCuentaGastoFamiliares}_${actividad.ActividadEconomicaId}_${i}`;
|
|
127
153
|
copy.Descripcion = `Gastos Familiares Actividad: ${actividad.ActividadEconomicaId}`;
|
|
@@ -131,7 +157,8 @@ const anadirGastoFamiliares = (actividad, data) => {
|
|
|
131
157
|
copy.Clasificador = 'CT';
|
|
132
158
|
if (rango == i) {
|
|
133
159
|
const otrosGastos = calcularOtrosGastos(actividad.OtrosGastos);
|
|
134
|
-
copy.MontoFamiliar =
|
|
160
|
+
copy.MontoFamiliar =
|
|
161
|
+
Math.round(parseFloat(otrosGastos.GastosFamiliares) * 100) / 100;
|
|
135
162
|
}
|
|
136
163
|
data.eerr.push(copy);
|
|
137
164
|
}
|
|
@@ -154,14 +181,16 @@ const anadirOtrosIngresos = (actividad, data) => {
|
|
|
154
181
|
const rango = data.eerr[0].Rango;
|
|
155
182
|
const cuentaOtrosIngresos = data.eerr.find((item) => item.RubroId == gCuentaOtrosIngresosDet);
|
|
156
183
|
for (let i = 1; i <= rango; i++) {
|
|
157
|
-
|
|
184
|
+
const copy = { ...cuentaOtrosIngresos };
|
|
158
185
|
copy.UUID = `${gCuentaOtrosIngresosDet}_${actividad.ActividadEconomicaId}_${rango}`;
|
|
159
186
|
copy.Descripcion = `Otros Ingresos ${actividad.ActividadEconomicaId}`;
|
|
160
187
|
copy.MontoEmpresa = 0;
|
|
161
188
|
copy.MontoFamiliar = 0;
|
|
162
189
|
copy.Correlativo = i;
|
|
163
190
|
copy.Clasificador = 'CT';
|
|
164
|
-
if (rango == i &&
|
|
191
|
+
if (rango == i &&
|
|
192
|
+
actividad.Ventas &&
|
|
193
|
+
actividad.Ventas.OtrosIngresos &&
|
|
165
194
|
actividad.Ventas.OtrosIngresos.length > 0) {
|
|
166
195
|
copy.MontoFamiliar = actividad.Ventas.OtrosIngresos.reduce((acc, item) => {
|
|
167
196
|
acc += parseFloat(item.Monto);
|
|
@@ -185,8 +214,10 @@ const sumarizarCuentas = (rubroOrigen, rubroDestino, data, dataOriginal) => {
|
|
|
185
214
|
cuentaDestino.MontoEmpresa += cuentaOrigen.MontoEmpresa;
|
|
186
215
|
if (original.MontoFamiliar == 0)
|
|
187
216
|
cuentaDestino.MontoFamiliar += cuentaOrigen.MontoFamiliar;
|
|
188
|
-
cuentaDestino.MontoEmpresa =
|
|
189
|
-
|
|
217
|
+
cuentaDestino.MontoEmpresa =
|
|
218
|
+
Math.round(cuentaDestino.MontoEmpresa * 100) / 100;
|
|
219
|
+
cuentaDestino.MontoFamiliar =
|
|
220
|
+
Math.round(cuentaDestino.MontoFamiliar * 100) / 100;
|
|
190
221
|
}
|
|
191
222
|
}
|
|
192
223
|
};
|