bdpformulas 1.0.1 → 1.0.3

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.
@@ -0,0 +1,7 @@
1
+ import { Strategy } from "./strategy.interface";
2
+ export default class Context {
3
+ private strategy;
4
+ constructor(strategy: Strategy);
5
+ setStrategy(strategy: Strategy): void;
6
+ executeStrategy(data: any): any;
7
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class Context {
4
+ constructor(strategy) {
5
+ this.strategy = strategy;
6
+ }
7
+ setStrategy(strategy) {
8
+ this.strategy = strategy;
9
+ }
10
+ executeStrategy(data) {
11
+ return this.strategy.execute(data);
12
+ }
13
+ }
14
+ exports.default = Context;
@@ -0,0 +1,3 @@
1
+ import Auxiliar from './strategies/pecuary/anexo.strategy';
2
+ import Context from "./context";
3
+ export { Auxiliar, Context };
package/build/index.js CHANGED
@@ -1,7 +1,10 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.test = void 0;
4
- const test = () => {
5
- return { Probando: 'testing' };
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
6
4
  };
7
- exports.test = test;
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Context = exports.Auxiliar = void 0;
7
+ const anexo_strategy_1 = __importDefault(require("./strategies/pecuary/anexo.strategy"));
8
+ exports.Auxiliar = anexo_strategy_1.default;
9
+ const context_1 = __importDefault(require("./context"));
10
+ exports.Context = context_1.default;
@@ -0,0 +1,203 @@
1
+ import { z } from "zod";
2
+ export declare const AuxiliarSchema: z.ZodObject<{
3
+ EvaluacionId: z.ZodNumber;
4
+ ActividadEconomicaId: z.ZodNumber;
5
+ PID: z.ZodNumber;
6
+ PropiedadesGanaderas: z.ZodArray<z.ZodObject<{
7
+ UUID: z.ZodString;
8
+ IndicadorABM: z.ZodEnum<["A", "N", "M", "B"]>;
9
+ TipoGanadoId: z.ZodString;
10
+ RazaGanadoId: z.ZodString;
11
+ Fecha: z.ZodString;
12
+ TipoDocumentoId: z.ZodString;
13
+ Rubros: z.ZodArray<z.ZodObject<{
14
+ RubroId: z.ZodString;
15
+ CantidadCabezas: z.ZodNumber;
16
+ PesoPromedio: z.ZodNumber;
17
+ PrecioCabeza: z.ZodNumber;
18
+ PrecioCabezaBalance: z.ZodNumber;
19
+ Total: z.ZodOptional<z.ZodNumber>;
20
+ }, "strip", z.ZodTypeAny, {
21
+ RubroId: string;
22
+ CantidadCabezas: number;
23
+ PesoPromedio: number;
24
+ PrecioCabeza: number;
25
+ PrecioCabezaBalance: number;
26
+ Total?: number | undefined;
27
+ }, {
28
+ RubroId: string;
29
+ CantidadCabezas: number;
30
+ PesoPromedio: number;
31
+ PrecioCabeza: number;
32
+ PrecioCabezaBalance: number;
33
+ Total?: number | undefined;
34
+ }>, "many">;
35
+ Total: z.ZodOptional<z.ZodNumber>;
36
+ PesoAclaracion: z.ZodString;
37
+ PrecioAclaracion: z.ZodString;
38
+ TipoGanadoDesc: z.ZodOptional<z.ZodString>;
39
+ RazaGanadoDesc: z.ZodOptional<z.ZodString>;
40
+ TipoDocumentoDesc: z.ZodOptional<z.ZodString>;
41
+ }, "strip", z.ZodTypeAny, {
42
+ UUID: string;
43
+ IndicadorABM: "A" | "N" | "M" | "B";
44
+ TipoGanadoId: string;
45
+ RazaGanadoId: string;
46
+ Fecha: string;
47
+ TipoDocumentoId: string;
48
+ Rubros: {
49
+ RubroId: string;
50
+ CantidadCabezas: number;
51
+ PesoPromedio: number;
52
+ PrecioCabeza: number;
53
+ PrecioCabezaBalance: number;
54
+ Total?: number | undefined;
55
+ }[];
56
+ PesoAclaracion: string;
57
+ PrecioAclaracion: string;
58
+ Total?: number | undefined;
59
+ TipoGanadoDesc?: string | undefined;
60
+ RazaGanadoDesc?: string | undefined;
61
+ TipoDocumentoDesc?: string | undefined;
62
+ }, {
63
+ UUID: string;
64
+ IndicadorABM: "A" | "N" | "M" | "B";
65
+ TipoGanadoId: string;
66
+ RazaGanadoId: string;
67
+ Fecha: string;
68
+ TipoDocumentoId: string;
69
+ Rubros: {
70
+ RubroId: string;
71
+ CantidadCabezas: number;
72
+ PesoPromedio: number;
73
+ PrecioCabeza: number;
74
+ PrecioCabezaBalance: number;
75
+ Total?: number | undefined;
76
+ }[];
77
+ PesoAclaracion: string;
78
+ PrecioAclaracion: string;
79
+ Total?: number | undefined;
80
+ TipoGanadoDesc?: string | undefined;
81
+ RazaGanadoDesc?: string | undefined;
82
+ TipoDocumentoDesc?: string | undefined;
83
+ }>, "many">;
84
+ HistoricoHato: z.ZodArray<z.ZodObject<{
85
+ RubroId: z.ZodString;
86
+ Gestion: z.ZodNumber;
87
+ CantidadCabezas: z.ZodNumber;
88
+ PrecioCabeza: z.ZodNumber;
89
+ }, "strip", z.ZodTypeAny, {
90
+ RubroId: string;
91
+ CantidadCabezas: number;
92
+ PrecioCabeza: number;
93
+ Gestion: number;
94
+ }, {
95
+ RubroId: string;
96
+ CantidadCabezas: number;
97
+ PrecioCabeza: number;
98
+ Gestion: number;
99
+ }>, "many">;
100
+ Inventario: z.ZodArray<z.ZodObject<{
101
+ RubroId: z.ZodString;
102
+ IndicadorABM: z.ZodEnum<["A", "N", "M", "B"]>;
103
+ UUID: z.ZodString;
104
+ Descripcion: z.ZodString;
105
+ Cantidad: z.ZodNumber;
106
+ Precio: z.ZodNumber;
107
+ }, "strip", z.ZodTypeAny, {
108
+ RubroId: string;
109
+ UUID: string;
110
+ IndicadorABM: "A" | "N" | "M" | "B";
111
+ Descripcion: string;
112
+ Cantidad: number;
113
+ Precio: number;
114
+ }, {
115
+ RubroId: string;
116
+ UUID: string;
117
+ IndicadorABM: "A" | "N" | "M" | "B";
118
+ Descripcion: string;
119
+ Cantidad: number;
120
+ Precio: number;
121
+ }>, "many">;
122
+ }, "strip", z.ZodTypeAny, {
123
+ EvaluacionId: number;
124
+ ActividadEconomicaId: number;
125
+ PID: number;
126
+ PropiedadesGanaderas: {
127
+ UUID: string;
128
+ IndicadorABM: "A" | "N" | "M" | "B";
129
+ TipoGanadoId: string;
130
+ RazaGanadoId: string;
131
+ Fecha: string;
132
+ TipoDocumentoId: string;
133
+ Rubros: {
134
+ RubroId: string;
135
+ CantidadCabezas: number;
136
+ PesoPromedio: number;
137
+ PrecioCabeza: number;
138
+ PrecioCabezaBalance: number;
139
+ Total?: number | undefined;
140
+ }[];
141
+ PesoAclaracion: string;
142
+ PrecioAclaracion: string;
143
+ Total?: number | undefined;
144
+ TipoGanadoDesc?: string | undefined;
145
+ RazaGanadoDesc?: string | undefined;
146
+ TipoDocumentoDesc?: string | undefined;
147
+ }[];
148
+ HistoricoHato: {
149
+ RubroId: string;
150
+ CantidadCabezas: number;
151
+ PrecioCabeza: number;
152
+ Gestion: number;
153
+ }[];
154
+ Inventario: {
155
+ RubroId: string;
156
+ UUID: string;
157
+ IndicadorABM: "A" | "N" | "M" | "B";
158
+ Descripcion: string;
159
+ Cantidad: number;
160
+ Precio: number;
161
+ }[];
162
+ }, {
163
+ EvaluacionId: number;
164
+ ActividadEconomicaId: number;
165
+ PID: number;
166
+ PropiedadesGanaderas: {
167
+ UUID: string;
168
+ IndicadorABM: "A" | "N" | "M" | "B";
169
+ TipoGanadoId: string;
170
+ RazaGanadoId: string;
171
+ Fecha: string;
172
+ TipoDocumentoId: string;
173
+ Rubros: {
174
+ RubroId: string;
175
+ CantidadCabezas: number;
176
+ PesoPromedio: number;
177
+ PrecioCabeza: number;
178
+ PrecioCabezaBalance: number;
179
+ Total?: number | undefined;
180
+ }[];
181
+ PesoAclaracion: string;
182
+ PrecioAclaracion: string;
183
+ Total?: number | undefined;
184
+ TipoGanadoDesc?: string | undefined;
185
+ RazaGanadoDesc?: string | undefined;
186
+ TipoDocumentoDesc?: string | undefined;
187
+ }[];
188
+ HistoricoHato: {
189
+ RubroId: string;
190
+ CantidadCabezas: number;
191
+ PrecioCabeza: number;
192
+ Gestion: number;
193
+ }[];
194
+ Inventario: {
195
+ RubroId: string;
196
+ UUID: string;
197
+ IndicadorABM: "A" | "N" | "M" | "B";
198
+ Descripcion: string;
199
+ Cantidad: number;
200
+ Precio: number;
201
+ }[];
202
+ }>;
203
+ export type AuxiliarSchemaType = z.infer<typeof AuxiliarSchema>;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuxiliarSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const Rubro = zod_1.z.object({
6
+ RubroId: zod_1.z.string().max(50),
7
+ CantidadCabezas: zod_1.z.number(),
8
+ PesoPromedio: zod_1.z.number(),
9
+ PrecioCabeza: zod_1.z.number(),
10
+ PrecioCabezaBalance: zod_1.z.number(),
11
+ Total: zod_1.z.number().optional(),
12
+ });
13
+ const PropiedadesGanaderas = zod_1.z.object({
14
+ UUID: zod_1.z.string().max(50),
15
+ IndicadorABM: zod_1.z.enum(['A', 'N', 'M', 'B']),
16
+ TipoGanadoId: zod_1.z.string().max(20),
17
+ RazaGanadoId: zod_1.z.string().max(20),
18
+ Fecha: zod_1.z.string().datetime(),
19
+ TipoDocumentoId: zod_1.z.string().max(20),
20
+ Rubros: zod_1.z.array(Rubro),
21
+ Total: zod_1.z.number().optional(),
22
+ PesoAclaracion: zod_1.z.string().max(1000),
23
+ PrecioAclaracion: zod_1.z.string().max(1000),
24
+ TipoGanadoDesc: zod_1.z.string().optional(),
25
+ RazaGanadoDesc: zod_1.z.string().optional(),
26
+ TipoDocumentoDesc: zod_1.z.string().optional()
27
+ });
28
+ const HistoricoHato = zod_1.z.object({
29
+ RubroId: zod_1.z.string().max(50),
30
+ Gestion: zod_1.z.number(),
31
+ CantidadCabezas: zod_1.z.number(),
32
+ PrecioCabeza: zod_1.z.number(),
33
+ });
34
+ const Inventario = zod_1.z.object({
35
+ RubroId: zod_1.z.string().max(50),
36
+ IndicadorABM: zod_1.z.enum(['A', 'N', 'M', 'B']),
37
+ UUID: zod_1.z.string().max(50),
38
+ Descripcion: zod_1.z.string().min(3).max(250),
39
+ Cantidad: zod_1.z.number(),
40
+ Precio: zod_1.z.number(),
41
+ });
42
+ exports.AuxiliarSchema = zod_1.z.object({
43
+ EvaluacionId: zod_1.z.number(),
44
+ ActividadEconomicaId: zod_1.z.number(),
45
+ PID: zod_1.z.number(),
46
+ PropiedadesGanaderas: zod_1.z.array(PropiedadesGanaderas),
47
+ HistoricoHato: zod_1.z.array(HistoricoHato),
48
+ Inventario: zod_1.z.array(Inventario),
49
+ });
@@ -0,0 +1,5 @@
1
+ import { Strategy } from "../../strategy.interface";
2
+ import { AuxiliarSchemaType } from "../../models/pecuary/auxiliar.schema";
3
+ export default class Auxiliar implements Strategy {
4
+ execute(data: AuxiliarSchemaType): any;
5
+ }
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const calcularHato = (data) => {
4
+ const gestiones = data.reduce((acc, item) => {
5
+ if (!acc.includes(item.Gestion))
6
+ acc.push(item.Gestion);
7
+ return acc;
8
+ }, []);
9
+ return gestiones.map((gestion) => {
10
+ const rubros = data.filter((item) => item.Gestion === gestion);
11
+ const precios = rubros.reduce((acc, item) => {
12
+ if (Object.keys(acc).length === 0) {
13
+ acc.Gestion = item.gestion;
14
+ acc.key = 'PRECIOS';
15
+ acc.GestionDesc = item.GestionDesc;
16
+ acc.Total = parseFloat('0');
17
+ }
18
+ if (!(item.RubroId in acc)) {
19
+ acc[item.RubroId] = item.PrecioCabeza;
20
+ acc.Total = acc.Total + parseFloat(item.PrecioCabeza);
21
+ }
22
+ return acc;
23
+ }, {});
24
+ const cantidades = rubros.reduce((acc, item) => {
25
+ if (Object.keys(acc).length === 0) {
26
+ acc.Gestion = item.gestion;
27
+ acc.key = 'CANTIDADES';
28
+ acc.GestionDesc = item.GestionDesc;
29
+ acc.Total = 0;
30
+ }
31
+ if (!(item.RubroId in acc)) {
32
+ acc[item.RubroId] = item.CantidadCabezas;
33
+ acc.Total = acc.Total + parseFloat(item.CantidadCabezas);
34
+ }
35
+ return acc;
36
+ }, {});
37
+ return [precios, cantidades];
38
+ });
39
+ };
40
+ class Auxiliar {
41
+ execute(data) {
42
+ data.PropiedadesGanaderas.forEach((item) => {
43
+ item.Total = 0;
44
+ item.Rubros.forEach((rubro) => {
45
+ if (rubro.PrecioCabezaBalance > 0)
46
+ rubro.Total = parseFloat(rubro.CantidadCabezas) * parseFloat(rubro.PrecioCabezaBalance);
47
+ else
48
+ rubro.Total = parseFloat(rubro.CantidadCabezas) * parseFloat(rubro.CantidadCabezas);
49
+ item.Total = item.Total + rubro.Total;
50
+ });
51
+ });
52
+ data.HistoricoHato = calcularHato(data.HistoricoHato);
53
+ data.Inventario = data.Inventario.map((item) => {
54
+ item.Total = item.Cantidad * item.Precio;
55
+ return item;
56
+ });
57
+ return data;
58
+ }
59
+ }
60
+ exports.default = Auxiliar;
@@ -0,0 +1,3 @@
1
+ export interface Strategy {
2
+ execute(data: any): any;
3
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "bdpformulas",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
+ "types": "build/index.d.ts",
6
7
  "scripts": {
7
8
  "start": "set NODE_ENV=dev&& node build/index.js",
8
9
  "dev": "set NODE_ENV=dev&& ts-node-dev src/index.ts",
@@ -13,5 +14,8 @@
13
14
  "license": "ISC",
14
15
  "devDependencies": {
15
16
  "typescript": "^5.5.3"
17
+ },
18
+ "dependencies": {
19
+ "zod": "^3.23.8"
16
20
  }
17
21
  }
package/tsconfig.json CHANGED
@@ -49,7 +49,7 @@
49
49
  // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
50
50
 
51
51
  /* Emit */
52
- // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
52
+ "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
53
53
  // "declarationMap": true, /* Create sourcemaps for d.ts files. */
54
54
  // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
55
55
  // "sourceMap": true, /* Create source map files for emitted JavaScript files. */