Show budget % as delta (+/-) from 100% across all views
This commit is contained in:
parent
bbc9a23da0
commit
92400dbcec
4 changed files with 15 additions and 8 deletions
|
|
@ -41,6 +41,10 @@ function pctClass(pct: number | null): string {
|
|||
if (pct <= 110) return 'pct-amber'
|
||||
return 'pct-red'
|
||||
}
|
||||
function fmtDelta(pct: number): string {
|
||||
const d = pct - 100
|
||||
return `${d >= 0 ? '+' : ''}${d.toFixed(1)}%`
|
||||
}
|
||||
|
||||
export default function Weekly() {
|
||||
const [fromStr, setFromStr] = useState<string>(() => mondayOf(new Date()))
|
||||
|
|
@ -195,7 +199,7 @@ export default function Weekly() {
|
|||
<div className="label">% vs Budget</div>
|
||||
<div className="value">
|
||||
{pctBudget != null
|
||||
? <span className={`pct-badge ${pctClass(pctBudget)}`}>{pctBudget.toFixed(1)}%</span>
|
||||
? <span className={`pct-badge ${pctClass(pctBudget)}`}>{fmtDelta(pctBudget)}</span>
|
||||
: '—'}
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -247,7 +251,7 @@ export default function Weekly() {
|
|||
<td className="right">{depBudg != null ? fmtMoney(depBudg) : '—'}</td>
|
||||
<td className="right">
|
||||
{depPct != null
|
||||
? <span className={`pct-badge ${pctClass(depPct)}`}>{depPct.toFixed(1)}%</span>
|
||||
? <span className={`pct-badge ${pctClass(depPct)}`}>{fmtDelta(depPct)}</span>
|
||||
: '—'}
|
||||
</td>
|
||||
<td className="right">{depSPct != null ? `${depSPct.toFixed(1)}%` : '—'}</td>
|
||||
|
|
@ -261,7 +265,7 @@ export default function Weekly() {
|
|||
<td className="right">{budget != null ? fmtMoney(budget) : '—'}</td>
|
||||
<td className="right">
|
||||
{pctBudget != null
|
||||
? <span className={`pct-badge ${pctClass(pctBudget)}`}>{pctBudget.toFixed(1)}%</span>
|
||||
? <span className={`pct-badge ${pctClass(pctBudget)}`}>{fmtDelta(pctBudget)}</span>
|
||||
: '—'}
|
||||
</td>
|
||||
<td className="right">{pctSales != null ? `${pctSales.toFixed(1)}%` : '—'}</td>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue