bdpformulas 1.0.13 → 1.0.15

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 CHANGED
@@ -1,4 +1,10 @@
1
1
  import Auxiliar from './strategies/pecuary/anexo.strategy';
2
2
  import Desarrollo from './strategies/pecuary/desarrollo.strategy';
3
+ import VentasPec from "./strategies/pecuary/ventas.strategy";
3
4
  import Context from "./context";
4
- export { Auxiliar, Desarrollo, Context };
5
+ declare const Pecuario: {
6
+ Auxiliar: typeof Auxiliar;
7
+ Desarrollo: typeof Desarrollo;
8
+ VentasPec: typeof VentasPec;
9
+ };
10
+ export { Context, Pecuario };
package/build/index.js CHANGED
@@ -3,10 +3,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Context = exports.Desarrollo = exports.Auxiliar = void 0;
6
+ exports.Pecuario = exports.Context = void 0;
7
7
  const anexo_strategy_1 = __importDefault(require("./strategies/pecuary/anexo.strategy"));
8
- exports.Auxiliar = anexo_strategy_1.default;
9
8
  const desarrollo_strategy_1 = __importDefault(require("./strategies/pecuary/desarrollo.strategy"));
10
- exports.Desarrollo = desarrollo_strategy_1.default;
9
+ const ventas_strategy_1 = __importDefault(require("./strategies/pecuary/ventas.strategy"));
11
10
  const context_1 = __importDefault(require("./context"));
12
11
  exports.Context = context_1.default;
12
+ const Pecuario = {
13
+ Auxiliar: anexo_strategy_1.default,
14
+ Desarrollo: desarrollo_strategy_1.default,
15
+ VentasPec: ventas_strategy_1.default
16
+ };
17
+ exports.Pecuario = Pecuario;
@@ -64,6 +64,7 @@ const getMap = (array, key) => {
64
64
  return array.reduce((acc, item) => {
65
65
  const id = item[key];
66
66
  acc.set(id, item);
67
+ return acc;
67
68
  }, new Map());
68
69
  };
69
70
  exports.getMap = getMap;
@@ -5,7 +5,7 @@ const Constantes_1 = require("../Constantes");
5
5
  const estacionalidadCalc = (ventasPrimitivo, ventasIngresos) => {
6
6
  const ingresosMap = (0, Constantes_1.getMap)(ventasIngresos, 'RubroId');
7
7
  const ventasCalc = ventasPrimitivo.Estacionalidad.map((item) => {
8
- return Object.assign(Object.assign({}, item), { IngresoTotal: ingresosMap.get(item.RubroId).IngresoTotal, CalculoIngreso: ingresosMap.get(item.RubroId).IngresoTotal * item.Monto });
8
+ return Object.assign(Object.assign({}, item), { Monto: parseFloat(item.Monto), IngresoTotal: ingresosMap.get(item.RubroId).IngresoTotal, CalculoIngreso: ingresosMap.get(item.RubroId).IngresoTotal * parseFloat(item.Monto) });
9
9
  });
10
10
  return ventasCalc;
11
11
  };
@@ -22,18 +22,19 @@ const getEstacionalidadPorcentaje = (estacionalidad) => {
22
22
  }
23
23
  if (!acc.has(item.RubroId)) {
24
24
  acc.set(item.RubroId, {
25
- RubroId: estacionalidad.RubroId,
26
- Descripcion: estacionalidad.Descripcion,
27
- IngresoTotal: estacionalidad.IngresoTotal,
25
+ RubroId: item.RubroId,
26
+ Descripcion: item.Descripcion,
27
+ IngresoTotal: item.IngresoTotal,
28
28
  Total: 0
29
29
  });
30
- acc.get('TOT01').IngresoTotal += estacionalidad.IngresoTotal;
30
+ acc.get('TOT01').IngresoTotal += item.IngresoTotal;
31
31
  }
32
- acc.get(item.RubroId)[`C-${item.Correlativo}`] = item.Monto;
33
- acc.get(item.RubroId)[`label-${item.Correlativo}`] = item.CorrelativoDesc;
32
+ acc.get(item.RubroId)[`C${item.Correlativo}`] = item.Monto;
33
+ acc.get(item.RubroId)[`label${item.Correlativo}`] = item.CorrelativoDesc;
34
34
  acc.get(item.RubroId).Total += item.Monto;
35
+ return acc;
35
36
  }, new Map());
36
- return Array.from(result);
37
+ return Array.from(result.values());
37
38
  };
38
39
  exports.getEstacionalidadPorcentaje = getEstacionalidadPorcentaje;
39
40
  const getEstacionalidadCalc = (estacionalidad) => {
@@ -46,19 +47,25 @@ const getEstacionalidadCalc = (estacionalidad) => {
46
47
  Total: 0
47
48
  });
48
49
  }
50
+ if (!acc.get(TOT01)[`C${item.Correlativo}`]) {
51
+ acc.get(TOT01)[`C${item.Correlativo}`] = 0;
52
+ acc.get(TOT01)[`label${item.Correlativo}`] = '';
53
+ }
49
54
  if (!acc.has(item.RubroId)) {
50
55
  acc.set(item.RubroId, {
51
- RubroId: estacionalidad.RubroId,
52
- Descripcion: estacionalidad.Descripcion,
53
- IngresoTotal: estacionalidad.IngresoTotal,
56
+ RubroId: item.RubroId,
57
+ Descripcion: item.Descripcion,
54
58
  Total: 0
55
59
  });
56
60
  }
57
- acc.get(item.RubroId)[`C-${item.Correlativo}`] = item.CalculoIngreso;
58
- acc.get(item.RubroId)[`label-${item.Correlativo}`] = item.CorrelativoDesc;
59
- acc.get(TOT01)[`C-${item.Correlativo}`] += item.CalculoIngreso;
61
+ acc.get(item.RubroId)[`C${item.Correlativo}`] = item.CalculoIngreso;
62
+ acc.get(item.RubroId)[`label${item.Correlativo}`] = item.CorrelativoDesc;
63
+ acc.get(TOT01)[`C${item.Correlativo}`] += item.CalculoIngreso;
64
+ acc.get(TOT01).Total += item.CalculoIngreso;
60
65
  acc.get(item.RubroId).Total += item.CalculoIngreso;
66
+ return acc;
61
67
  }, new Map());
62
- return Array.from(result);
68
+ console.log(result.values());
69
+ return Array.from(result.values());
63
70
  };
64
71
  exports.getEstacionalidadCalc = getEstacionalidadCalc;
@@ -3,13 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.calcular = void 0;
4
4
  const Constantes_1 = require("../Constantes");
5
5
  const calcular = (ventasPrimitivo, auxiliarPrimitivo, desarrolloCalculado) => {
6
- const gestionMaxima = Math.max(auxiliarPrimitivo.HistoricoHato.map((item) => item.Gestion));
6
+ const gestionMaxima = Math.max(...auxiliarPrimitivo.HistoricoHato.map((item) => item.Gestion));
7
7
  const historicoHato = auxiliarPrimitivo.HistoricoHato.filter((item) => item.Gestion == gestionMaxima);
8
8
  const hatoMap = (0, Constantes_1.getMap)(historicoHato, 'RubroId');
9
9
  const avaluoMap = (0, Constantes_1.getMap)(desarrolloCalculado.Avaluo, 'RubroId');
10
- return ventasPrimitivo.Ventas.map((item) => {
11
- const cantidad = hatoMap.get(item.RubroId).CantidadCabezas;
12
- const precio = avaluoMap.get(item.RubroId).PrecioVenta;
10
+ return ventasPrimitivo.Ingresos.map((item) => {
11
+ const cantidad = parseFloat(hatoMap.get(item.RubroId).CantidadCabezas);
12
+ const precio = parseFloat(avaluoMap.get(item.RubroId).PrecioVenta);
13
13
  return Object.assign(Object.assign({}, item), { Animales: cantidad, Precio: precio, IngresoTotal: cantidad * precio });
14
14
  });
15
15
  };
@@ -27,17 +27,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  const ventasIngresosCalc = __importStar(require("./ventas.detail/ventasIngresosCalc"));
30
+ const estacionalidadCalc = __importStar(require("./ventas.detail/estacionalidadCalc"));
30
31
  const desarrollo_strategy_1 = __importDefault(require("./desarrollo.strategy"));
31
32
  class VentasPec {
32
33
  execute(data) {
33
34
  let result = {};
34
- //const ventasIngresos = ventasIngresosCalc.calcular()
35
35
  const dataDesarrollo = {
36
36
  Desarrollo: data.Desarrollo,
37
37
  Auxiliar: data.Auxiliar
38
38
  };
39
39
  const desarrolloCalc = new desarrollo_strategy_1.default().execute(dataDesarrollo);
40
40
  result.VentasIngreso = ventasIngresosCalc.calcular(data.Ventas, data.Auxiliar, desarrolloCalc);
41
+ const estacionalidad = estacionalidadCalc.estacionalidadCalc(data.Ventas, result.VentasIngreso);
42
+ result.EstacionalidadPorcentaje = estacionalidadCalc.getEstacionalidadPorcentaje(estacionalidad);
43
+ result.EstacionalidadCalc = estacionalidadCalc.getEstacionalidadCalc(estacionalidad);
41
44
  return result;
42
45
  }
43
46
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bdpformulas",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",