Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions frontend/components/populace/populace-reforms-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { Fragment, useEffect, useMemo, useState } from "react";

import { EmptyState } from "@/components/shared/empty-state";
import { fmt, fmtMoney, releaseLabel } from "@/components/shared/format";
import { fmt, fmtMoney, fmtUnitValue, releaseLabel } from "@/components/shared/format";
import { KpiCard } from "@/components/shared/kpi-card";
import { LoadingBlock } from "@/components/shared/LoadingBlock";
import { PageHeader } from "@/components/shared/page-header";
Expand Down Expand Up @@ -253,10 +253,10 @@ function ReformTable({
</div>
</td>
<td className="whitespace-nowrap px-3 py-1.5 text-right tabular-nums">
{fmtMoney(row.jct_score)}
{fmtUnitValue(row.jct_score, row.unit)}
</td>
<td className="whitespace-nowrap px-3 py-1.5 text-right tabular-nums">
{fmtMoney(row.populace_estimate)}
{fmtUnitValue(row.populace_estimate, row.unit)}
</td>
<td className="whitespace-nowrap px-3 py-1.5">
<ErrorCell absRel={row.abs_relative_error} />
Expand Down
5 changes: 3 additions & 2 deletions frontend/components/populace/populace-staging-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useEffect, useMemo, useState } from "react";

import { EmptyState } from "@/components/shared/empty-state";
import {
fmtUnitValue,
fmt,
fmtCompact,
fmtMoney,
Expand Down Expand Up @@ -245,10 +246,10 @@ function ReformValidationTable({
</div>
</td>
<td className="whitespace-nowrap px-3 py-2 text-right tabular-nums">
{fmtMoney(row.jct_score)}
{fmtUnitValue(row.jct_score, row.unit)}
</td>
<td className="whitespace-nowrap px-3 py-2 text-right tabular-nums">
{fmtMoney(row.populace_estimate)}
{fmtUnitValue(row.populace_estimate, row.unit)}
</td>
<td
className={`whitespace-nowrap px-3 py-2 text-right tabular-nums ${
Expand Down
14 changes: 14 additions & 0 deletions frontend/components/shared/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,20 @@ export function fmtCompact(value: number | null | undefined): string {
return `${sign}${abs.toFixed(0)}`;
}

/** Format a validation value by its payload unit: "percent" rows hold
* decimal fractions (0.134 -> "13.4%"); everything else is USD. */
export function fmtUnitValue(
value: number | null | undefined,
unit: string | null | undefined,
): string {
if (unit === "percent") {
return value == null || !Number.isFinite(value)
? "—"
: `${(value * 100).toFixed(1)}%`;
}
return fmtMoney(value);
}

export function fmtMoney(value: number | null | undefined): string {
if (value == null || !Number.isFinite(value)) return "—";
const abs = Math.abs(value);
Expand Down
2 changes: 2 additions & 0 deletions frontend/lib/api/hooks/use-populace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,8 @@ export interface ReformValidationRow {
populace_estimate?: number | null;
populace_window?: string | null;
populace_annual?: Record<string, number> | null;
/** "percent" for rate backtests (decimal fractions); USD otherwise. */
unit?: "currency-USD" | "percent" | null;
abs_error?: number | null;
relative_error?: number | null;
abs_relative_error?: number | null;
Expand Down
5 changes: 5 additions & 0 deletions frontend/lib/populace/reforms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ export interface ReformValidationRow {
populace_estimate: number | null;
populace_window: string | null;
populace_annual: Record<string, number> | null;
// Value unit: "currency-USD" (default) or "percent" for rate backtests
// (e.g. Census state SPM poverty rates, where the values are decimal
// fractions like 0.134 rather than dollars).
unit: "currency-USD" | "percent";
// Derived (relative to jct_score, i.e. the FY2027 benchmark where available).
abs_error: number | null; // populace − jct (USD)
relative_error: number | null; // (populace − jct) / |jct|
Expand Down Expand Up @@ -157,6 +161,7 @@ function enrichReform(raw: JsonObject): ReformValidationRow {
description: stringOrNull(raw.description),
in_sample: raw.in_sample === true,
period: numberOrNull(raw.period),
unit: raw.unit === "percent" ? "percent" : "currency-USD",
jct_score: benchmark,
jct_score_fy2026: jctFy2026,
jct_score_type: stringOrNull(jct.score_type),
Expand Down