Fix anomaly banner when expected_qty is negative (untracked initial stock)

This commit is contained in:
dadaloop82
2026-04-29 15:26:59 +00:00
parent 22266cb620
commit da46fec174
5 changed files with 17 additions and 1 deletions
+6 -1
View File
@@ -2962,9 +2962,14 @@ 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 (isPhantom) {
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) {
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 {