feat: smarter alert banners — expired only, explanatory messages
- Scadenze: rimuove 'in scadenza' dal banner (solo prodotti già scaduti) - Consumo anomalo: spiega la media giornaliera, giorni dall'ultimo rifornimento e direzione della discrepanza (più/meno del previsto) con contesto - Quantità sospetta: messaggio specifico per caso (bassa/alta/conf insolita) - Anomalia inventario: linguaggio naturale invece di jargon tecnico phantom='hai più scorte del previsto', missing='hai meno scorte del previsto' - API prediction: aggiunge days_since_restock, direction, tx_count - confirmBannerPrediction: toast con info su ricalcolo previsioni
This commit is contained in:
+13
-10
@@ -1634,16 +1634,19 @@ function getConsumptionPredictions(PDO $db): void {
|
||||
}
|
||||
|
||||
$predictions[] = [
|
||||
'inventory_id' => (int)$item['inventory_id'],
|
||||
'product_id' => (int)$item['product_id'],
|
||||
'name' => $item['name'],
|
||||
'brand' => $item['brand'],
|
||||
'location' => $item['location'],
|
||||
'unit' => $displayUnit,
|
||||
'expected_qty' => $expDisplay,
|
||||
'actual_qty' => $actDisplay,
|
||||
'daily_rate' => round($dailyRate, 3),
|
||||
'deviation_pct'=> round($pctDev * 100),
|
||||
'inventory_id' => (int)$item['inventory_id'],
|
||||
'product_id' => (int)$item['product_id'],
|
||||
'name' => $item['name'],
|
||||
'brand' => $item['brand'],
|
||||
'location' => $item['location'],
|
||||
'unit' => $displayUnit,
|
||||
'expected_qty' => $expDisplay,
|
||||
'actual_qty' => $actDisplay,
|
||||
'daily_rate' => round($dailyRate, 3),
|
||||
'deviation_pct' => round($pctDev * 100),
|
||||
'days_since_restock' => (int)round($daysSinceRestock),
|
||||
'direction' => $actualQty > $expectedQty ? 'more' : 'less',
|
||||
'tx_count' => count($rows),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user