From 770566ac9c57686d5ba4c0e272fc383351f9b6fa Mon Sep 17 00:00:00 2001 From: Christian Vidal Wolf Date: Tue, 27 Jan 2026 10:00:27 +0100 Subject: [PATCH] Forecast View: Added Annual Forecast and Annual Fulfillment cards --- components/ForecastView.tsx | 63 ++++++++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 12 deletions(-) diff --git a/components/ForecastView.tsx b/components/ForecastView.tsx index c015a8d..86ba58e 100644 --- a/components/ForecastView.tsx +++ b/components/ForecastView.tsx @@ -82,18 +82,33 @@ const ForecastView: React.FC = ({ data, filters, top50Ranking }, [data]); const globalSummary = useMemo(() => { - let totalForecast = 0; - let totalActual = 0; + let periodForecast = 0; + let periodActual = 0; + let annualForecast = 0; + let annualActual = 0; + data.forEach(p => { + annualForecast += p.annualForecast; p.monthlyData.forEach(md => { + annualActual += md.actualUnits; if (activeMonths.includes(md.month)) { - totalForecast += md.forecastUnits; - totalActual += md.actualUnits; + periodForecast += md.forecastUnits; + periodActual += md.actualUnits; } }); }); - const fulfillment = totalForecast > 0 ? (totalActual / totalForecast) * 100 : 0; - return { totalForecast, totalActual, fulfillment }; + + const periodFulfillment = periodForecast > 0 ? (periodActual / periodForecast) * 100 : 0; + const annualFulfillment = annualForecast > 0 ? (annualActual / annualForecast) * 100 : 0; + + return { + periodForecast, + periodActual, + periodFulfillment, + annualForecast, + annualActual, + annualFulfillment + }; }, [data, activeMonths]); const filteredProducts = useMemo(() => { @@ -137,12 +152,21 @@ const ForecastView: React.FC = ({ data, filters, top50Ranking
{/* Summary Cards */} -
+
+ {/* Annual Forecast Card */} +
+
+

Annual Forecast Total

+
+ {globalSummary.annualForecast.toLocaleString('de-DE')} Units +
+
+

Total Forecast (Period)

- {globalSummary.totalForecast.toLocaleString('de-DE')} Units + {globalSummary.periodForecast.toLocaleString('de-DE')} Units
@@ -150,7 +174,7 @@ const ForecastView: React.FC = ({ data, filters, top50Ranking

Total Actual Sales (Period)

- {globalSummary.totalActual.toLocaleString('de-DE')} Units + {globalSummary.periodActual.toLocaleString('de-DE')} Units
@@ -158,15 +182,30 @@ const ForecastView: React.FC = ({ data, filters, top50Ranking

Fulfillment (Period)

-
= 100 ? 'text-emerald-400' : 'text-indigo-400'}`}> - {globalSummary.fulfillment.toFixed(1)}% +
= 100 ? 'text-emerald-400' : 'text-indigo-400'}`}> + {globalSummary.periodFulfillment.toFixed(1)}%
{/* Fulfillment Progress Bar */}
+
+
+ + {/* Annual Fulfillment Card */} +
+
+

Annual Fulfillment %

+
+ {globalSummary.annualFulfillment.toFixed(1)}% +
+
+