diff --git a/frontend/src/pages/Monthly.tsx b/frontend/src/pages/Monthly.tsx index df26cc8..fed2556 100644 --- a/frontend/src/pages/Monthly.tsx +++ b/frontend/src/pages/Monthly.tsx @@ -131,7 +131,12 @@ export default function Monthly() { const pctBudget = budget != null && budget > 0 ? (totalForecast / budget) * 100 : null const pctSales = netSales > 0 ? (totalActual / netSales) * 100 : null const variance = budget != null ? totalForecast - budget : null - const pyWagesDiff = pyWages != null && totalActual > 0 ? totalActual - pyWages : null + + function pyPct(current: number, py: number): string { + if (py <= 0 || current <= 0) return '' + const p = ((current - py) / py) * 100 + return ` (${p >= 0 ? '+' : ''}${p.toFixed(1)}%)` + } // Build chart data with per-dept costs per week so Bar dataKey works type WeekEntry = { label: string; isPast: boolean; [dept: string]: number | boolean | string } @@ -187,15 +192,7 @@ export default function Monthly() {