fix: remove 'untracked' anomaly direction — incomplete purchase history is normal, not an anomaly
This commit is contained in:
+5
-4
@@ -1807,11 +1807,12 @@ function getInventoryAnomalies(PDO $db): void {
|
||||
// so it stays dismissed until the user explicitly resets or the direction changes.
|
||||
// An inventory correction (bringing qty closer to expected) will flip the direction
|
||||
// or drop below threshold — naturally clearing the dismissed state.
|
||||
// If expected <= 0 it means more consumption recorded than purchases — the
|
||||
// transaction history is simply incomplete (very common: users track consumption
|
||||
// but not always purchases). Showing an anomaly here is just noise, skip it.
|
||||
if ($expected <= 0) continue;
|
||||
|
||||
$direction = $diff > 0 ? 'phantom' : 'missing';
|
||||
// Special case: expected is negative — more consumption recorded than entries.
|
||||
// The real qty vs tx comparison is meaningless; what we actually know is that
|
||||
// "initial stock was never formally registered as an 'in' transaction".
|
||||
if ($expected <= 0) $direction = 'untracked';
|
||||
$key = 'a_' . $r['product_id'] . '_' . $direction;
|
||||
if (!empty($dismissed[$key])) continue;
|
||||
$anomalies[] = [
|
||||
|
||||
+1
-6
@@ -3897,14 +3897,9 @@ function renderBannerItem() {
|
||||
} else if (entry.type === 'anomaly') {
|
||||
const an = entry.data;
|
||||
const isPhantom = an.direction === 'phantom';
|
||||
const isUntracked = an.direction === 'untracked';
|
||||
banner.className = 'alert-banner banner-anomaly';
|
||||
iconEl.textContent = '🔍';
|
||||
if (isUntracked) {
|
||||
// More consumption recorded than entries — initial stock was never registered
|
||||
titleEl.textContent = `${an.name} — ${t('dashboard.banner_anomaly_untracked_title')}`;
|
||||
detailEl.innerHTML = t('dashboard.banner_anomaly_untracked_detail', { inv_qty: an.inv_qty, unit: an.unit });
|
||||
} else if (isPhantom) {
|
||||
if (isPhantom) {
|
||||
titleEl.textContent = `${an.name} — ${t('dashboard.banner_anomaly_phantom_title')}`;
|
||||
detailEl.innerHTML = t('dashboard.banner_anomaly_phantom_detail', { inv_qty: an.inv_qty, unit: an.unit, expected_qty: an.expected_qty });
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user