bdpformulas 1.0.18 → 1.0.20

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.
Files changed (23) hide show
  1. package/build/index.d.ts +11 -1
  2. package/build/index.js +13 -1
  3. package/build/strategies/agriculture/costos.detail/costosCalc.d.ts +1 -0
  4. package/build/strategies/agriculture/costos.detail/costosCalc.js +20 -0
  5. package/build/strategies/agriculture/costos.detail/mesesCalc.d.ts +1 -0
  6. package/build/strategies/agriculture/costos.detail/mesesCalc.js +35 -0
  7. package/build/strategies/agriculture/costos.strategy.d.ts +4 -0
  8. package/build/strategies/agriculture/costos.strategy.js +37 -0
  9. package/build/strategies/pecuary/anexo.strategy.js +6 -5
  10. package/build/strategies/pecuary/costos.detail/conceptosCalc.js +14 -1
  11. package/build/strategies/production/costos.detail/costosCalc.d.ts +2 -0
  12. package/build/strategies/production/costos.detail/costosCalc.js +40 -0
  13. package/build/strategies/production/costos.detail/mesesCalc.d.ts +1 -0
  14. package/build/strategies/production/costos.detail/mesesCalc.js +32 -0
  15. package/build/strategies/production/costos.strategy.d.ts +4 -0
  16. package/build/strategies/production/costos.strategy.js +38 -0
  17. package/build/strategies/production/ventas.detail/estacionalidadCalc.d.ts +2 -0
  18. package/build/strategies/production/ventas.detail/estacionalidadCalc.js +81 -0
  19. package/build/strategies/production/ventas.detail/ingresosCalc.d.ts +5 -0
  20. package/build/strategies/production/ventas.detail/ingresosCalc.js +51 -0
  21. package/build/strategies/production/ventas.strategy.d.ts +4 -0
  22. package/build/strategies/production/ventas.strategy.js +39 -0
  23. package/package.json +1 -1
package/build/index.d.ts CHANGED
@@ -3,10 +3,20 @@ import Desarrollo from './strategies/pecuary/desarrollo.strategy';
3
3
  import VentasPec from "./strategies/pecuary/ventas.strategy";
4
4
  import Context from "./context";
5
5
  import CostosPec from "./strategies/pecuary/costos.strategy";
6
+ import VentasPrd from "./strategies/production/ventas.strategy";
7
+ import CostosPrd from "./strategies/production/costos.strategy";
8
+ import CostosAgr from "./strategies/agriculture/costos.strategy";
6
9
  declare const Pecuario: {
7
10
  Auxiliar: typeof Auxiliar;
8
11
  Desarrollo: typeof Desarrollo;
9
12
  VentasPec: typeof VentasPec;
10
13
  CostosPec: typeof CostosPec;
11
14
  };
12
- export { Context, Pecuario };
15
+ declare const Produccion: {
16
+ VentasPrd: typeof VentasPrd;
17
+ CostosPrd: typeof CostosPrd;
18
+ };
19
+ declare const Agricola: {
20
+ CostosAgr: typeof CostosAgr;
21
+ };
22
+ export { Context, Agricola, Pecuario, Produccion };
package/build/index.js CHANGED
@@ -3,13 +3,16 @@ 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.Pecuario = exports.Context = void 0;
6
+ exports.Produccion = exports.Pecuario = exports.Agricola = exports.Context = void 0;
7
7
  const anexo_strategy_1 = __importDefault(require("./strategies/pecuary/anexo.strategy"));
8
8
  const desarrollo_strategy_1 = __importDefault(require("./strategies/pecuary/desarrollo.strategy"));
9
9
  const ventas_strategy_1 = __importDefault(require("./strategies/pecuary/ventas.strategy"));
10
10
  const context_1 = __importDefault(require("./context"));
11
11
  exports.Context = context_1.default;
12
12
  const costos_strategy_1 = __importDefault(require("./strategies/pecuary/costos.strategy"));
13
+ const ventas_strategy_2 = __importDefault(require("./strategies/production/ventas.strategy"));
14
+ const costos_strategy_2 = __importDefault(require("./strategies/production/costos.strategy"));
15
+ const costos_strategy_3 = __importDefault(require("./strategies/agriculture/costos.strategy"));
13
16
  const Pecuario = {
14
17
  Auxiliar: anexo_strategy_1.default,
15
18
  Desarrollo: desarrollo_strategy_1.default,
@@ -17,3 +20,12 @@ const Pecuario = {
17
20
  CostosPec: costos_strategy_1.default
18
21
  };
19
22
  exports.Pecuario = Pecuario;
23
+ const Produccion = {
24
+ VentasPrd: ventas_strategy_2.default,
25
+ CostosPrd: costos_strategy_2.default
26
+ };
27
+ exports.Produccion = Produccion;
28
+ const Agricola = {
29
+ CostosAgr: costos_strategy_3.default
30
+ };
31
+ exports.Agricola = Agricola;
@@ -0,0 +1 @@
1
+ export declare const calcular: (Costos: any) => any;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calcular = void 0;
4
+ const calcular = (Costos) => {
5
+ return Costos.map((item) => {
6
+ let result = Object.assign({}, item);
7
+ result.Cantidad = parseFloat(item.Cantidad);
8
+ result.PrecioUnitario = parseFloat(item.PrecioUnitario);
9
+ result.Total = Math.round(result.Cantidad * result.PrecioUnitario * result.Superficie * 100) / 100;
10
+ result.TotalMonto = 0;
11
+ for (let i in result) {
12
+ if (i.startsWith('Monto')) {
13
+ result[i] = parseFloat(item[i]);
14
+ result.TotalMonto += parseFloat(item[i]);
15
+ }
16
+ }
17
+ return result;
18
+ });
19
+ };
20
+ exports.calcular = calcular;
@@ -0,0 +1 @@
1
+ export declare const calcularMeses: (data: any) => unknown[];
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calcularMeses = void 0;
4
+ const calcularMeses = (data) => {
5
+ let result = data.reduce((acc, item) => {
6
+ if (!acc.has(0))
7
+ acc.set(0, { ActividadProductoId: 0, Descripcion: 'TOTAL', Total: 0 });
8
+ if (!acc.has(item.ActividadProductoId)) {
9
+ let value = {};
10
+ value.ActividadProductoId = item.ActividadProductoId;
11
+ value.Total = 0;
12
+ value.Descripcion = item.Descripcion;
13
+ acc.set(item.ActividadProductoId, value);
14
+ }
15
+ for (let i in item) {
16
+ if (i.startsWith('Monto')) {
17
+ if (!(i in acc.get(item.ActividadProductoId)))
18
+ acc.get(item.ActividadProductoId)[i] = 0;
19
+ if (!(i in acc.get(0)))
20
+ acc.get(0)[i] = 0;
21
+ const monto = Math.round(item[i] / 100 * item.Total * 100) / 100;
22
+ acc.get(item.ActividadProductoId)[i] += monto;
23
+ acc.get(item.ActividadProductoId).Total += monto;
24
+ acc.get(0)[i] += monto;
25
+ acc.get(0).Total += monto;
26
+ }
27
+ if (i.startsWith('CorrelativoDesc')) {
28
+ acc.get(item.ActividadProductoId)[i] = item[i];
29
+ }
30
+ }
31
+ return acc;
32
+ }, new Map());
33
+ return Array.from(result.values());
34
+ };
35
+ exports.calcularMeses = calcularMeses;
@@ -0,0 +1,4 @@
1
+ import { Strategy } from "../../strategy.interface";
2
+ export default class CostosAgr implements Strategy {
3
+ execute(data: any): any;
4
+ }
@@ -0,0 +1,37 @@
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
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const costosCalc = __importStar(require("./costos.detail/costosCalc"));
27
+ const mesesCalc = __importStar(require("./costos.detail/mesesCalc"));
28
+ //@ts-ignore
29
+ class CostosAgr {
30
+ execute(data) {
31
+ let result = {};
32
+ result.Costos = costosCalc.calcular(data.Costos);
33
+ result.Meses = mesesCalc.calcularMeses(result.Costos);
34
+ return result;
35
+ }
36
+ }
37
+ exports.default = CostosAgr;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ //@ts-ignore
3
4
  const calcularHato = (data) => {
4
5
  const gestiones = data.reduce((acc, item) => {
5
6
  if (!acc.includes(item.Gestion))
@@ -68,11 +69,11 @@ class Auxiliar {
68
69
  item.Total = item.Total + rubro.Total;
69
70
  });
70
71
  });
71
- data.HistoricoHato = calcularHato(data.HistoricoHato);
72
- data.Inventario = data.Inventario.map((item) => {
73
- item.Total = item.Cantidad * item.Precio;
74
- return item;
75
- });
72
+ // data.HistoricoHato= calcularHato(data.HistoricoHato)
73
+ // data.Inventario = data.Inventario.map((item: any)=>{
74
+ // item.Total = item.Cantidad * item.Precio
75
+ // return item
76
+ // })
76
77
  return data;
77
78
  }
78
79
  }
@@ -17,6 +17,7 @@ const getPrimeraFila = (configuracion, auxiliarPrimitivo, desarrolloCalc) => {
17
17
  acc.CorrelativoDesc = '';
18
18
  acc.Total = 0;
19
19
  acc.TotalPlusHato = 0;
20
+ acc.IndicadorABM = 'N';
20
21
  }
21
22
  let value = 0;
22
23
  if (item.RubroId !== 'ACT_PEC_SALDO') {
@@ -46,6 +47,7 @@ const getFila = (configuracion, correlativo = 0) => {
46
47
  acc.Descripcion = '';
47
48
  acc.Total = 0;
48
49
  acc.TotalPlusHato = 0;
50
+ acc.IndicadorABM = 'N';
49
51
  }
50
52
  acc[item.RubroId] = 0;
51
53
  return acc;
@@ -60,7 +62,7 @@ const getGrupoCalculado = (grupo, configuracion) => {
60
62
  const monto = parseFloat(item.Monto);
61
63
  result.get(item.Correlativo).CodigoConcepto = item.Grupo;
62
64
  result.get(item.Correlativo).Subtipo = item.Subtipo;
63
- result.get(item.Correlativo).Descripcion = item.Descripcion;
65
+ result.get(item.Correlativo).Descripcion = item.Descripcion1;
64
66
  result.get(item.Correlativo).SubtipoDesc = item.SubtipoDesc;
65
67
  result.get(item.Correlativo).Unidad = item.Descripcion2;
66
68
  result.get(item.Correlativo).CorrelativoDesc = item.CorrelativoDesc;
@@ -99,6 +101,14 @@ const calcular = (conceptos, configuracion, auxiliarPrimitivo, desarrolloCalc) =
99
101
  const subtipo = grupoCalc.get(3).Subtipo;
100
102
  if (!subtipos.has(subtipo))
101
103
  subtipos.set(subtipo, getFila(configuracion, 4));
104
+ if (!subtipos.has('T')) {
105
+ subtipos.set('T', getFila(configuracion, 4));
106
+ subtipos.get('T').CodigoConcepto = 'TOTAL';
107
+ subtipos.get('T').Subtipo = 'T';
108
+ subtipos.get('T').SubtipoDesc = 'TOTAL';
109
+ subtipos.get('T').Descripcion = 'TOTAL';
110
+ subtipos.get('T').Unidad = '';
111
+ }
102
112
  subtipos.get(subtipo).CodigoConcepto = 'TOTAL_GRUPO';
103
113
  subtipos.get(subtipo).Subtipo = grupoCalc.get(3).Subtipo;
104
114
  subtipos.get(subtipo).SubtipoDesc = grupoCalc.get(3).SubtipoDesc;
@@ -106,9 +116,12 @@ const calcular = (conceptos, configuracion, auxiliarPrimitivo, desarrolloCalc) =
106
116
  subtipos.get(subtipo).Unidad = grupoCalc.get(3).Unidad;
107
117
  configuracion.forEach((item) => {
108
118
  subtipos.get(subtipo)[item.RubroId] += grupoCalc.get(3)[item.RubroId];
119
+ subtipos.get('T')[item.RubroId] += grupoCalc.get(3)[item.RubroId];
109
120
  });
110
121
  subtipos.get(subtipo).Total += grupoCalc.get(3).Total;
111
122
  subtipos.get(subtipo).TotalPlusHato += grupoCalc.get(3).TotalPlusHato;
123
+ subtipos.get('T').Total += grupoCalc.get(3).Total;
124
+ subtipos.get('T').TotalPlusHato += grupoCalc.get(3).TotalPlusHato;
112
125
  result = [...result, ...Array.from(grupoCalc.values())];
113
126
  }
114
127
  return [...root, ...result, ...Array.from(subtipos.values())];
@@ -0,0 +1,2 @@
1
+ export declare const getValuePivote: (ventasPrimitivo: any) => any[];
2
+ export declare const calcular: (Costos: any) => any;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calcular = exports.getValuePivote = void 0;
4
+ const getValuePivote = (ventasPrimitivo) => {
5
+ let result = new Map();
6
+ if (ventasPrimitivo.Ingresos && ventasPrimitivo.Ingresos.length > 0) {
7
+ result = ventasPrimitivo.Ingresos.reduce((acc, item) => {
8
+ if (!acc.has(item.ProductoId)) {
9
+ let cantidad = 0;
10
+ if (item.Montos.some((monto) => monto.Correlativo === item.Rango)) {
11
+ cantidad = item.Montos.find((monto) => monto.Correlativo === item.Rango).Cantidad;
12
+ }
13
+ acc.set(item.ProductoId, {
14
+ ProductoId: item.ProductoId,
15
+ Cantidad: Math.round(parseFloat(cantidad) * parseFloat(item.CiclosProduccion) * 100) / 100
16
+ });
17
+ }
18
+ return acc;
19
+ }, new Map());
20
+ }
21
+ return Array.from(result.values());
22
+ };
23
+ exports.getValuePivote = getValuePivote;
24
+ const calcular = (Costos) => {
25
+ return Costos.map((item) => {
26
+ let result = Object.assign({}, item);
27
+ result.Cantidad = parseFloat(item.Cantidad);
28
+ result.PrecioUnitario = parseFloat(item.PrecioUnitario);
29
+ result.Total = Math.round(result.Cantidad * result.PrecioUnitario * 100) / 100;
30
+ result.TotalMonto = 0;
31
+ for (let i in result) {
32
+ if (i.startsWith('Monto')) {
33
+ result[i] = parseFloat(item[i]);
34
+ result.TotalMonto += parseFloat(item[i]);
35
+ }
36
+ }
37
+ return result;
38
+ });
39
+ };
40
+ exports.calcular = calcular;
@@ -0,0 +1 @@
1
+ export declare const calcularMeses: (data: any) => unknown[];
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calcularMeses = void 0;
4
+ const calcularMeses = (data) => {
5
+ let result = data.reduce((acc, item) => {
6
+ if (!acc.has(0))
7
+ acc.set(0, { ProductoId: 0, Descripcion: 'TOTAL', Total: 0 });
8
+ if (!acc.has(item.ProductoId)) {
9
+ let value = {};
10
+ value.ProductoId = item.ProductoId;
11
+ value.Total = 0;
12
+ value.Descripcion = item.Descripcion;
13
+ acc.set(item.ProductoId, value);
14
+ }
15
+ for (let i in item) {
16
+ if (i.startsWith('Monto')) {
17
+ if (!(i in acc.get(item.ProductoId)))
18
+ acc.get(item.ProductoId)[i] = 0;
19
+ if (!(i in acc.get(0)))
20
+ acc.get(0)[i] = 0;
21
+ const monto = Math.round(item[i] / 100 * item.Total * 100) / 100;
22
+ acc.get(item.ProductoId)[i] += monto;
23
+ acc.get(item.ProductoId).Total += monto;
24
+ acc.get(0)[i] += monto;
25
+ acc.get(0).Total += monto;
26
+ }
27
+ }
28
+ return acc;
29
+ }, new Map());
30
+ return Array.from(result.values());
31
+ };
32
+ exports.calcularMeses = calcularMeses;
@@ -0,0 +1,4 @@
1
+ import { Strategy } from "../../strategy.interface";
2
+ export default class CostosPrd implements Strategy {
3
+ execute(data: any): any;
4
+ }
@@ -0,0 +1,38 @@
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
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ //@ts-ignore
27
+ const costosCalc = __importStar(require("./costos.detail/costosCalc"));
28
+ const mesesCalc = __importStar(require("./costos.detail/mesesCalc"));
29
+ class CostosPrd {
30
+ execute(data) {
31
+ let result = {};
32
+ result.CantidadesProducidas = costosCalc.getValuePivote(data.Ventas);
33
+ result.Costos = costosCalc.calcular(data.Costos.Costos);
34
+ result.Meses = mesesCalc.calcularMeses(result.Costos);
35
+ return result;
36
+ }
37
+ }
38
+ exports.default = CostosPrd;
@@ -0,0 +1,2 @@
1
+ export declare const calcularPorcentaje: (productos: any, ingresosCalc: any, estacionalidad: any) => unknown[];
2
+ export declare const calcularEstacionalidad: (data: any) => unknown[];
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calcularEstacionalidad = exports.calcularPorcentaje = void 0;
4
+ const getIngreso = (productoId, ingresosCalc, rango, criterio) => {
5
+ const subtotal = ingresosCalc.find((item) => item.ProductoId === productoId && item.Id === 'SUBTOTAL');
6
+ let result = subtotal[`C-1`];
7
+ if (criterio == 'MIN') {
8
+ for (let i = 2; i <= rango; i++) {
9
+ if (subtotal[`C-${i}`] < result)
10
+ result = subtotal[`C-${i}`];
11
+ }
12
+ }
13
+ else if (criterio == 'MAX') {
14
+ for (let i = 2; i <= rango; i++) {
15
+ if (subtotal[`C-${i}`] > result)
16
+ result = subtotal[`C-${i}`];
17
+ }
18
+ }
19
+ else if (criterio == 'AVG') {
20
+ result = 0;
21
+ for (let i = 1; i <= rango; i++) {
22
+ result += subtotal[`C-${i}`];
23
+ }
24
+ result = Math.round(result / rango * 100) / 100;
25
+ }
26
+ else if (criterio == 'ULT') {
27
+ result = subtotal[`C-${rango}`];
28
+ }
29
+ return result;
30
+ };
31
+ const calcularPorcentaje = (productos, ingresosCalc, estacionalidad) => {
32
+ productos = productos.reduce((acc, item) => {
33
+ if (!acc.has(item.ProductoId))
34
+ acc.set(item.ProductoId, item);
35
+ return acc;
36
+ }, new Map());
37
+ const datos = estacionalidad.reduce((acc, item) => {
38
+ if (!acc.has(item.ProductoId))
39
+ acc.set(item.ProductoId, {
40
+ ProductoId: productos.get(item.ProductoId).ProductoId,
41
+ Descripcion: productos.get(item.ProductoId).Descripcion,
42
+ Ingreso: getIngreso(item.ProductoId, ingresosCalc, productos.get(item.ProductoId).Rango, item.CriterioId),
43
+ Total: 0
44
+ });
45
+ acc.get(item.ProductoId)[`C-${item.Correlativo}`] = parseFloat(item.Monto);
46
+ acc.get(item.ProductoId)[`CDesc-${item.Correlativo}`] = item.CorrelativoDesc;
47
+ acc.get(item.ProductoId).Total += parseFloat(item.Monto);
48
+ return acc;
49
+ }, new Map());
50
+ return Array.from(datos.values());
51
+ };
52
+ exports.calcularPorcentaje = calcularPorcentaje;
53
+ const calcularEstacionalidad = (data) => {
54
+ const result = data.reduce((acc, item) => {
55
+ if (!acc.has(0)) {
56
+ acc.set(0, {
57
+ ProductoId: 0,
58
+ Descripcion: 'TOTAL',
59
+ Total: 0
60
+ });
61
+ }
62
+ if (!acc.has(item.ProductoId))
63
+ acc.set(item.ProductoId, {
64
+ ProductoId: item.ProductoId,
65
+ Descripcion: item.Descripcion,
66
+ Total: 0
67
+ });
68
+ for (const key in item) {
69
+ if (key.startsWith('C-')) {
70
+ const monto = Math.round(item[key] * item.Ingreso * 100) / 100;
71
+ acc.get(item.ProductoId)[key] = monto;
72
+ acc.get(item.ProductoId).Total += monto;
73
+ acc.get(0)[key] += monto;
74
+ acc.get(0).Total += monto;
75
+ }
76
+ }
77
+ return acc;
78
+ }, new Map());
79
+ return Array.from(result.values());
80
+ };
81
+ exports.calcularEstacionalidad = calcularEstacionalidad;
@@ -0,0 +1,5 @@
1
+ export declare const calcularProductos: (data: any) => any[];
2
+ export declare const calcular: (data: any) => {
3
+ Productos: any;
4
+ Ingresos: any[];
5
+ };
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calcular = exports.calcularProductos = void 0;
4
+ const calcularProductos = (data) => {
5
+ let cantidad = { Id: 'CANTIDAD', ProductoId: data.ProductoId, IndicadorABM: 'M' };
6
+ let precio = { Id: 'PRECIO', ProductoId: data.ProductoId, IndicadorABM: 'M' };
7
+ let subtotal = { Id: 'SUBTOTAL', ProductoId: data.ProductoId, IndicadorABM: 'M' };
8
+ data.Montos.forEach((item) => {
9
+ cantidad[`C-${item.Correlativo}`] = parseFloat(item.Cantidad);
10
+ cantidad[`CDesc-${item.Correlativo}`] = item.CorrelativoDesc;
11
+ precio[`C-${item.Correlativo}`] = parseFloat(item.Precio);
12
+ precio[`CDesc-${item.Correlativo}`] = item.CorrelativoDesc;
13
+ subtotal[`C-${item.Correlativo}`] = Math.round(parseFloat(item.Precio) * (parseFloat(item.Cantidad) * parseFloat(data.CampannasAnno)) * (1 - parseFloat(data.Merma) / 100) * 100) / 100;
14
+ subtotal[`CDesc-${item.Correlativo}`] = item.CorrelativoDesc;
15
+ });
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
+ cantidad[`V-${i}`] = cantidad[`C-${i + 1}`] - cantidad[`C-${i}`];
20
+ cantidad[`VDesc-${i}`] = cantidad[`CDesc-${i + 1}`].slice(-4) + ' - ' + cantidad[`CDesc-${i}`].slice(-4);
21
+ precio[`V-${i}`] = precio[`C-${i + 1}`] - precio[`C-${i}`];
22
+ precio[`VDesc-${i}`] = precio[`CDesc-${i + 1}`].slice(-4) + ' - ' + precio[`CDesc-${i}`].slice(-4);
23
+ subtotal[`V-${i}`] = subtotal[`C-${i + 1}`] - subtotal[`C-${i}`];
24
+ subtotal[`VDesc-${i}`] = precio[`VDesc-${i}`];
25
+ }
26
+ return [cantidad, precio, subtotal];
27
+ };
28
+ exports.calcularProductos = calcularProductos;
29
+ const calcular = (data) => {
30
+ let ingresos = [];
31
+ let total = { Id: 'TOTAL', ProductoId: 0, IndicadorABM: 'M' };
32
+ for (let i = 0; i < data.length; i++) {
33
+ const nuevo = (0, exports.calcularProductos)(data[i]);
34
+ delete data[i].Montos;
35
+ const subtotal = nuevo.find((item) => item.Id === 'SUBTOTAL');
36
+ for (const key in subtotal) {
37
+ if (key.startsWith('C-') || key.startsWith('V-')) {
38
+ if (total[key] == undefined)
39
+ total[key] = 0;
40
+ total[key] += subtotal[key];
41
+ }
42
+ }
43
+ ingresos = [...ingresos, ...nuevo];
44
+ }
45
+ ingresos.push(total);
46
+ return {
47
+ Productos: data,
48
+ Ingresos: ingresos
49
+ };
50
+ };
51
+ exports.calcular = calcular;
@@ -0,0 +1,4 @@
1
+ import { Strategy } from "../../strategy.interface";
2
+ export default class VentasPrd implements Strategy {
3
+ execute(data: any): any;
4
+ }
@@ -0,0 +1,39 @@
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
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const ingresosCalc = __importStar(require("./ventas.detail/ingresosCalc"));
27
+ //@ts-ignore
28
+ const estacionalidadCalc = __importStar(require("./ventas.detail/estacionalidadCalc"));
29
+ class VentasPrd {
30
+ execute(data) {
31
+ let result = {};
32
+ result = ingresosCalc.calcular(data.Ingresos);
33
+ result.Estacionalidad = estacionalidadCalc.calcularPorcentaje(result.Productos, result.Ingresos, data.Estacionalidad);
34
+ result.EstacionalidadCalc = estacionalidadCalc.calcularEstacionalidad(result.Estacionalidad);
35
+ result.OtrosIngresos = data.OtrosIngresos;
36
+ return result;
37
+ }
38
+ }
39
+ exports.default = VentasPrd;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bdpformulas",
3
- "version": "1.0.18",
3
+ "version": "1.0.20",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",