Show budget % as delta (+/-) from 100% across all views

This commit is contained in:
jtricerolph 2026-07-23 11:48:38 +00:00
parent bbc9a23da0
commit 92400dbcec
4 changed files with 15 additions and 8 deletions

View file

@ -11,6 +11,7 @@ function fmt(d: Date): string {
}
function fmtMoney(n: number): string { return `£${Math.round(n).toLocaleString('en-GB')}` }
function pctClass(p: number): string { return p <= 100 ? 'pct-green' : p <= 110 ? 'pct-amber' : 'pct-red' }
function fmtDelta(p: number): string { const d = p - 100; return `${d >= 0 ? '+' : ''}${d.toFixed(1)}%` }
function daysInMonth(y: number, m: number): number { return new Date(y, m, 0).getDate() }
const DEPT_COLORS = ['#065f46','#059669','#0891b2','#7c3aed','#c2410c','#b45309','#0f766e','#4338ca','#be185d','#15803d']
@ -182,7 +183,7 @@ export default function Rolling12Months() {
)}
</td>
<td className="right">
{pctB != null ? <span className={`pct-badge ${pctClass(pctB)}`}>{pctB.toFixed(1)}%</span> : '—'}
{pctB != null ? <span className={`pct-badge ${pctClass(pctB)}`}>{fmtDelta(pctB)}</span> : '—'}
</td>
<td className="right">{r.sales > 0 ? fmtMoney(r.sales) : '—'}</td>
<td className="right">{pctS != null ? `${pctS.toFixed(1)}%` : '—'}</td>