bdpformulas 1.0.19 → 1.0.21
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 +11 -1
- package/build/index.js +13 -1
- package/build/strategies/agriculture/costos.detail/costosCalc.d.ts +1 -0
- package/build/strategies/agriculture/costos.detail/costosCalc.js +20 -0
- package/build/strategies/agriculture/costos.detail/mesesCalc.d.ts +1 -0
- package/build/strategies/agriculture/costos.detail/mesesCalc.js +35 -0
- package/build/strategies/agriculture/costos.strategy.d.ts +4 -0
- package/build/strategies/agriculture/costos.strategy.js +37 -0
- package/build/strategies/pecuary/anexo.strategy.js +6 -5
- package/build/strategies/production/costos.detail/costosCalc.d.ts +2 -0
- package/build/strategies/production/costos.detail/costosCalc.js +40 -0
- package/build/strategies/production/costos.detail/mesesCalc.d.ts +1 -0
- package/build/strategies/production/costos.detail/mesesCalc.js +32 -0
- package/build/strategies/production/costos.strategy.d.ts +4 -0
- package/build/strategies/production/costos.strategy.js +38 -0
- package/build/strategies/production/ventas.detail/estacionalidadCalc.d.ts +2 -0
- package/build/strategies/production/ventas.detail/estacionalidadCalc.js +83 -0
- package/build/strategies/production/ventas.detail/ingresosCalc.d.ts +5 -1
- package/build/strategies/production/ventas.detail/ingresosCalc.js +46 -1
- package/build/strategies/production/ventas.strategy.js +6 -6
- 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
|
-
|
|
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,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
|
|
72
|
-
data.Inventario = data.Inventario.map((item)
|
|
73
|
-
|
|
74
|
-
|
|
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
|
}
|
|
@@ -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,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,83 @@
|
|
|
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
|
+
CriteriorId: item.CriterioId,
|
|
43
|
+
CriterioDesc: item.CriterioDesc,
|
|
44
|
+
Ingreso: getIngreso(item.ProductoId, ingresosCalc, productos.get(item.ProductoId).Rango, item.CriterioId),
|
|
45
|
+
Total: 0
|
|
46
|
+
});
|
|
47
|
+
acc.get(item.ProductoId)[`C-${item.Correlativo}`] = parseFloat(item.Monto);
|
|
48
|
+
acc.get(item.ProductoId)[`CDesc-${item.Correlativo}`] = item.CorrelativoDesc;
|
|
49
|
+
acc.get(item.ProductoId).Total += parseFloat(item.Monto);
|
|
50
|
+
return acc;
|
|
51
|
+
}, new Map());
|
|
52
|
+
return Array.from(datos.values());
|
|
53
|
+
};
|
|
54
|
+
exports.calcularPorcentaje = calcularPorcentaje;
|
|
55
|
+
const calcularEstacionalidad = (data) => {
|
|
56
|
+
const result = data.reduce((acc, item) => {
|
|
57
|
+
if (!acc.has(0)) {
|
|
58
|
+
acc.set(0, {
|
|
59
|
+
ProductoId: 0,
|
|
60
|
+
Descripcion: 'TOTAL',
|
|
61
|
+
Total: 0
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
if (!acc.has(item.ProductoId))
|
|
65
|
+
acc.set(item.ProductoId, {
|
|
66
|
+
ProductoId: item.ProductoId,
|
|
67
|
+
Descripcion: item.Descripcion,
|
|
68
|
+
Total: 0
|
|
69
|
+
});
|
|
70
|
+
for (const key in item) {
|
|
71
|
+
if (key.startsWith('C-')) {
|
|
72
|
+
const monto = Math.round(item[key] * item.Ingreso * 100) / 100;
|
|
73
|
+
acc.get(item.ProductoId)[key] = monto;
|
|
74
|
+
acc.get(item.ProductoId).Total += monto;
|
|
75
|
+
acc.get(0)[key] += monto;
|
|
76
|
+
acc.get(0).Total += monto;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return acc;
|
|
80
|
+
}, new Map());
|
|
81
|
+
return Array.from(result.values());
|
|
82
|
+
};
|
|
83
|
+
exports.calcularEstacionalidad = calcularEstacionalidad;
|
|
@@ -1,6 +1,51 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.calcular = void 0;
|
|
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;
|
|
4
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
|
+
};
|
|
5
50
|
};
|
|
6
51
|
exports.calcular = calcular;
|
|
@@ -24,15 +24,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
const ingresosCalc = __importStar(require("./ventas.detail/ingresosCalc"));
|
|
27
|
+
//@ts-ignore
|
|
28
|
+
const estacionalidadCalc = __importStar(require("./ventas.detail/estacionalidadCalc"));
|
|
27
29
|
class VentasPrd {
|
|
28
30
|
execute(data) {
|
|
29
31
|
let result = {};
|
|
30
|
-
result
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
// result.EstacionalidadCalc= estacionalidadCalc.getEstacionalidadCalc(estacionalidad)
|
|
35
|
-
result.OtrosIngresos = data.Ventas.OtrosIngresos;
|
|
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
36
|
return result;
|
|
37
37
|
}
|
|
38
38
|
}
|