feat: improve Week Coverage visibility, calculation robustness, and add aggregate WOC to grid totals and forecast view

This commit is contained in:
Christian Vidal Wolf
2026-04-17 12:35:25 +02:00
parent aa4a916c5d
commit 38f16aac89
4 changed files with 83 additions and 14 deletions
+24 -2
View File
@@ -361,13 +361,20 @@ const ForecastView: React.FC<ForecastViewProps> = ({
return sum + (curr.monthlyData?.[month]?.forecastUnits || 0);
}, 0);
const asin = curr.asin.trim().toUpperCase();
const stockData = vendorStockMap?.get(asin);
const stock = stockData ? (top50Mode === 'uk' ? stockData.uk : stockData.eu) : 0;
const velocity = curr.avgWeeklySales || 0;
return {
actualUnits: acc.actualUnits + (curr.actualUnits || 0),
forecastUnits: acc.forecastUnits + itemPeriodForecast,
annualForecast: acc.annualForecast + (curr.annualForecast || 0),
totalStock: acc.totalStock + stock,
totalVelocity: acc.totalVelocity + velocity
};
}, { actualUnits: 0, forecastUnits: 0, annualForecast: 0 });
}, [processedData, activeMonths]);
}, { actualUnits: 0, forecastUnits: 0, annualForecast: 0, totalStock: 0, totalVelocity: 0 });
}, [processedData, activeMonths, vendorStockMap, top50Mode]);
// [MOVED HERE] Chart Data - Now respects all filters including Search/WOC
const chartData = useMemo(() => {
@@ -442,6 +449,21 @@ const ForecastView: React.FC<ForecastViewProps> = ({
<div className="text-xl font-black text-white">{globalSummary.annualForecast > 0 ? ((globalSummary.actualUnits / globalSummary.annualForecast) * 100).toFixed(1) : '0.0'}%</div>
</div>
</div>
{/* New Aggregate WOC Card */}
<div className="bg-slate-900 border border-white/5 p-4 rounded-xl shadow-lg flex-1 flex flex-col justify-center">
<span className="text-[10px] font-black text-indigo-400 uppercase tracking-widest mb-1">Average Week Coverage</span>
<div className="flex items-baseline gap-2">
<div className={`text-2xl font-black ${globalSummary.totalVelocity > 0 && (globalSummary.totalStock / globalSummary.totalVelocity) < 4 ? 'text-rose-400' : 'text-emerald-400'}`}>
{globalSummary.totalVelocity > 0
? (globalSummary.totalStock / globalSummary.totalVelocity).toFixed(1)
: (globalSummary.totalStock > 0 ? '> 52' : '0.0')}
</div>
<span className="text-sm font-bold text-slate-500">Weeks</span>
</div>
<div className="text-[9px] font-bold text-slate-500 uppercase mt-1">
Total Stock: {globalSummary.totalStock.toLocaleString('de-DE')} | Velocity: {globalSummary.totalVelocity.toFixed(1)}/wk
</div>
</div>
</div>
<div className="flex-1 bg-slate-900 border border-white/5 rounded-xl shadow-lg p-6 flex flex-col">