bdpformulas 1.0.23 → 1.0.25
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.
|
@@ -24,6 +24,8 @@ exports.getValuePivote = getValuePivote;
|
|
|
24
24
|
const calcular = (Costos) => {
|
|
25
25
|
return Costos.map((item) => {
|
|
26
26
|
let result = Object.assign({}, item);
|
|
27
|
+
result.ActividadProductoId = item.ProductoId;
|
|
28
|
+
result.UnidadActividadId = item.UnidadId;
|
|
27
29
|
result.Cantidad = parseFloat(item.Cantidad);
|
|
28
30
|
result.PrecioUnitario = parseFloat(item.PrecioUnitario);
|
|
29
31
|
result.Total = Math.round(result.Cantidad * result.PrecioUnitario * 100) / 100;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const calcularMeses: (data: any) => unknown[];
|
|
1
|
+
export declare const calcularMeses: (data: any, productos: any[]) => unknown[];
|
|
@@ -1,17 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.calcularMeses = void 0;
|
|
4
|
-
const calcularMeses = (data) => {
|
|
5
|
-
|
|
6
|
-
if (!acc.has(0))
|
|
7
|
-
acc.set(0, { ProductoId: 0, Descripcion: 'TOTAL', Total: 0 });
|
|
4
|
+
const calcularMeses = (data, productos) => {
|
|
5
|
+
const mapProductos = productos.reduce((acc, item) => {
|
|
8
6
|
if (!acc.has(item.ProductoId)) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
acc.set(item.ProductoId, {
|
|
8
|
+
ProductoId: item.ProductoId,
|
|
9
|
+
Descripcion: item.Descripcion,
|
|
10
|
+
ActividadProductoId: item.ProductoId,
|
|
11
|
+
Total: 0
|
|
12
|
+
});
|
|
14
13
|
}
|
|
14
|
+
return acc;
|
|
15
|
+
}, new Map());
|
|
16
|
+
let result = data.reduce((acc, item) => {
|
|
17
|
+
if (!acc.has(0))
|
|
18
|
+
acc.set(0, { ProductoId: 0, ActividadProductoId: 0,
|
|
19
|
+
UnidadActividadId: '',
|
|
20
|
+
Descripcion: 'TOTAL', Total: 0 });
|
|
21
|
+
// if(!acc.has(item.ProductoId)){
|
|
22
|
+
// let value: any = {}
|
|
23
|
+
// value.ProductoId = item.ProductoId
|
|
24
|
+
// value.ActividadProductoId = item.ProductoId
|
|
25
|
+
// value.Total = 0
|
|
26
|
+
// value.Descripcion = item.Descripcion
|
|
27
|
+
// acc.set(item.ProductoId, value)
|
|
28
|
+
// }
|
|
15
29
|
for (let i in item) {
|
|
16
30
|
if (i.startsWith('Monto')) {
|
|
17
31
|
if (!(i in acc.get(item.ProductoId)))
|
|
@@ -26,7 +40,7 @@ const calcularMeses = (data) => {
|
|
|
26
40
|
}
|
|
27
41
|
}
|
|
28
42
|
return acc;
|
|
29
|
-
},
|
|
43
|
+
}, mapProductos);
|
|
30
44
|
return Array.from(result.values());
|
|
31
45
|
};
|
|
32
46
|
exports.calcularMeses = calcularMeses;
|
|
@@ -31,7 +31,7 @@ class CostosPrd {
|
|
|
31
31
|
let result = {};
|
|
32
32
|
result.CantidadesProducidas = costosCalc.getValuePivote(data.Ventas);
|
|
33
33
|
result.Costos = costosCalc.calcular(data.Costos.Costos);
|
|
34
|
-
result.Meses = mesesCalc.calcularMeses(result.Costos);
|
|
34
|
+
result.Meses = mesesCalc.calcularMeses(result.Costos, data.Costos.Productos);
|
|
35
35
|
return result;
|
|
36
36
|
}
|
|
37
37
|
}
|