bdpformulas 1.0.27 → 1.0.29

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.
@@ -2,5 +2,7 @@ import { Strategy } from "../../strategy.interface";
2
2
  export default class BalanceAgrStrategy implements Strategy {
3
3
  ventas: any;
4
4
  costos: any;
5
+ gastos: any;
6
+ constructor();
5
7
  execute(data: any): any;
6
8
  }
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  class BalanceAgrStrategy {
4
+ constructor() {
5
+ this.ventas = {};
6
+ this.costos = {};
7
+ }
4
8
  execute(data) {
5
9
  data.eerr = calcularEERR(data.eerr, this.ventas, this.costos);
6
10
  return data;
@@ -8,5 +12,67 @@ class BalanceAgrStrategy {
8
12
  }
9
13
  exports.default = BalanceAgrStrategy;
10
14
  const calcularEERR = (eerr, ventas, costos) => {
15
+ // const totalesOtrosIngresos = getOtrosIngresos(ventas)
16
+ // const mapVentas = getVentasXGestion(ventas)
17
+ // const costoTotal = calcularCostoTotal(costos)
18
+ // const gastos = calcularOtrosGastos(costos)
19
+ //
20
+ // console.log('mapVentas',mapVentas)
21
+ // console.log('totalesOtrosIngresos',totalesOtrosIngresos)
22
+ // console.log('costoTotal',costoTotal)
23
+ // console.log('gastos',gastos)
11
24
  return eerr;
12
25
  };
26
+ //@ts-ignore
27
+ const getOtrosIngresos = (ventas) => {
28
+ const ingresosTotales = ventas.OtrosIngresos.reduce((acc, item) => {
29
+ for (let i = 1; i <= 12; i++) {
30
+ acc += item[`Gestion${i}`];
31
+ }
32
+ return acc;
33
+ }, 0);
34
+ return ingresosTotales;
35
+ };
36
+ //@ts-ignore
37
+ const getVentasXGestion = (ventas) => {
38
+ const ingresosTotales = ventas.Productos.map((item) => item.Ingresos).flat().
39
+ filter((item) => item.RubroId === 'ACT_AGR_ING_TO');
40
+ let result = ingresosTotales.reduce((acc, item) => {
41
+ const rango = item.Rango;
42
+ for (let i = 1; i <= rango; i++) {
43
+ if (!acc.has(i)) {
44
+ acc.set(i, 0);
45
+ }
46
+ let value = acc.get(i);
47
+ value += item[`Gestion${i}`];
48
+ acc.set(i, value);
49
+ }
50
+ return acc;
51
+ }, new Map());
52
+ return Array.from(result.values());
53
+ };
54
+ //@ts-ignore
55
+ const calcularCostoTotal = (costos) => {
56
+ let numero = 0;
57
+ const filter = costos.filter((item) => item.ActividadProductoId == 0);
58
+ if (filter.length > 0) {
59
+ numero = filter[0].Total;
60
+ }
61
+ numero = Math.round(numero * 100) / 100;
62
+ return numero;
63
+ };
64
+ //@ts-ignore
65
+ const calcularOtrosGastos = (gastos) => {
66
+ const gastosOperativos = gastos.Operativos.reduce((acc, item) => {
67
+ acc += item.ImporteAnual;
68
+ return acc;
69
+ }, 0);
70
+ const gastosFamiliares = gastos.Familiares.reduce((acc, item) => {
71
+ acc += item.ImporteAnual;
72
+ return acc;
73
+ }, 0);
74
+ return {
75
+ GastosOperativos: gastosOperativos,
76
+ GastosFamiliares: gastosFamiliares
77
+ };
78
+ };
@@ -1,12 +1,42 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
+ const commmon = __importStar(require("./common/balance.calc"));
3
27
  class Balance {
4
28
  execute(data) {
5
29
  let result = {};
6
30
  if (data.strategy != null)
7
31
  data = data.strategy.execute(data);
32
+ const balanceClone = trasponer(commmon.clone(data.balance));
33
+ const eerrClone = trasponer(commmon.clone(data.eerr));
8
34
  result.balance = calcularBalance(data.balance);
9
35
  result.eerr = calcularEERR(data.eerr);
36
+ result.DataOriginal = {
37
+ balance: balanceClone,
38
+ eerr: eerrClone
39
+ };
10
40
  return result;
11
41
  }
12
42
  }
@@ -132,6 +162,8 @@ const trasponer = (data) => {
132
162
  RubroPadreId: item.RubroPadreId,
133
163
  Descripcion: item.Descripcion,
134
164
  IndicadorABM: item.IndicadorABM,
165
+ Clasificador: item.Clasificador,
166
+ Borrable: esBorrable(item.RubroId),
135
167
  Editable: item.Editable,
136
168
  });
137
169
  acc.get(key)[`UUID_${item.Correlativo}`] = item.UUID;
@@ -143,3 +175,9 @@ const trasponer = (data) => {
143
175
  }, new Map());
144
176
  return Array.from(result.values());
145
177
  };
178
+ const esBorrable = (rubroId) => {
179
+ const rubrosBorrables = ['ACT_CN_11004', 'ACT_CN_12005',
180
+ 'ACT_CN_21003', 'ACT_CN_22003', 'ACT_CN_30002',
181
+ 'ACT_CN_40002', 'ACT_CN_41003', 'ACT_CN_43004', 'ACT_CN_45001'];
182
+ return (rubrosBorrables.includes(rubroId));
183
+ };
@@ -0,0 +1,2 @@
1
+ export declare const clone: (data: any) => any;
2
+ export declare const calcularPorcentaje: (balance: any) => void;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calcularPorcentaje = exports.clone = void 0;
4
+ const clone = (data) => {
5
+ return JSON.parse(JSON.stringify(data));
6
+ };
7
+ exports.clone = clone;
8
+ const calcularPorcentaje = (balance) => {
9
+ };
10
+ exports.calcularPorcentaje = calcularPorcentaje;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bdpformulas",
3
- "version": "1.0.27",
3
+ "version": "1.0.29",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",