Arreglos part I
by borisjavier
JavaScript
const data = {
"1&1&1680048000000Ac": {
"active": "si",
"empresa": 1,
"fecha": "2023-03-29",
"planta": "Sangão",
"preco": "2.5",
"product": "Aço",
"qty": "1000",
"responsible": "[email protected]",
"um": "Kg"
},
"1&1&1689811200000Ac": {
"active": "si",
"empresa": "1",
"fecha": "2023-07-20",
"planta": "Sangão",
"preco": "5",
"product": "Aco",
"qty": "200",
"responsible": "borisjavier",
"um": "Kg"
},
"1&1&1689811200000Ca": {
"active": "si",
"empresa": "1",
"fecha": "2023-07-20",
"planta": "Sangão",
"preco": "8",
"product": "Carvao",
"qty": "200",
"responsible": "borisjavier",
"um": "Kg"
},
"1&1&1689811200000Ol": {
"active": "si",
"empresa": "1",
"fecha": "2023-07-20",
"planta": "Sangão",
"preco": "2.00",
"product": "Oleo",
"qty": "1000",
"responsible": "borisjavier",
"um": "Lt"
},
"1&1&1689811200000Sy": {
"active": "si",
"empresa": "1",
"fecha": "2023-07-20",
"planta": "Sangão",
"preco": "1.00",
"product": "Syngas",
"qty": "500",
"responsible": "borisjavier",
"um": "M3"
},
"1&2&1689292800000Ne": {
"active": "si",
"empresa": "1",
"fecha": "2023-07-14",
"planta": "Pirula",
"preco": "8",
"product": "Negro de Fumo",
"qty": "100",
"responsible": "borisjavier",
"um": "Kg"
},
"1&3&1697760000000Bi": {
"active": "si",
"empresa": "1",
"fecha": "2023-10-20",
"planta": "Perenceja",
"preco": "2",
"product": "Biochar",
"qty": "100000",
"responsible": "[email protected]",
"um": "Kg"
}
}
// Obtener el timestamp hace 30 días
const today = new Date();
const thirtyDaysAgoTimestamp = today.getTime() - 30 * 24 * 60 * 60 * 1000;
// Filtrar por empresa y planta, excluyendo datos antiguos
const filteredData = Object.fromEntries(
Object.entries(data).filter(([key, value]) => {
const...