fix: low stock detection for rarely-used items
- PHP smart_shopping: add absolute stock fallback that flags conf/pz items with <=2 units (medium) or <=1 unit (high) and g/ml at <=20% of default, regardless of usage frequency. Fixes products like Panna da cucina that are rarely used but running low and were invisible to the frequency-based urgency logic (pctLeft was 66% since last purchase was 3 at once). - JS isLowStock(): return true (not false) when totalRemaining <= 0. A fully depleted item is definitely low-stock; the Bring! add prompt should fire when you use the very last unit.
This commit is contained in:
+1
-1
@@ -3781,7 +3781,7 @@ function selectUseLocation(btn, loc) {
|
||||
|
||||
// ===== LOW STOCK → BRING! PROMPT =====
|
||||
function isLowStock(totalRemaining, unit, defaultQty) {
|
||||
if (totalRemaining <= 0) return false; // already fully depleted → auto-added
|
||||
if (totalRemaining <= 0) return true; // fully depleted → definitely needs restocking
|
||||
if (unit === 'pz') return totalRemaining <= 2;
|
||||
if (unit === 'conf') return totalRemaining <= 1;
|
||||
// Weight/volume: use percentage of default_qty or fixed threshold
|
||||
|
||||
Reference in New Issue
Block a user