diff --git a/changelog.d/bhp-followups.fixed.md b/changelog.d/bhp-followups.fixed.md new file mode 100644 index 0000000..c661774 --- /dev/null +++ b/changelog.d/bhp-followups.fixed.md @@ -0,0 +1 @@ +A link copied at $0 of earnings opens with $0 in the earnings box and its cards, and the code cites 42 U.S.C. 18051(e)(2), the paragraph that bars Basic Health Program enrollees from the Marketplace. diff --git a/src/aca_api/api.py b/src/aca_api/api.py index 4f605ac..4f28f80 100644 --- a/src/aca_api/api.py +++ b/src/aca_api/api.py @@ -554,7 +554,7 @@ def run_at_income(data: AtIncomeRequest, year: int, enhanced: bool) -> ScenarioA for m, c, b, h in zip(medicaid, chip, barred, basic_health) ] # Only members no program covers can buy a Marketplace plan; Basic Health - # Program enrollees can't (42 U.S.C. 18051(e)). + # Program enrollees can't (42 U.S.C. 18051(e)(2)). uncovered = [ name for name, person in zip(situation["people"], coverage) if not (person.medicaid or person.chip or person.basic_health_program) diff --git a/src/aca_api/models.py b/src/aca_api/models.py index c36729d..3b2ad0e 100644 --- a/src/aca_api/models.py +++ b/src/aca_api/models.py @@ -180,7 +180,7 @@ class PersonCoverage(BaseModel): description=( "Eligible for the state's Basic Health Program (MinnesotaCare, New " "York's Essential Plan, OHP Bridge or the Healthy DC Plan), which " - "rules out Marketplace enrollment (42 U.S.C. 18051(e))" + "rules out Marketplace enrollment (42 U.S.C. 18051(e)(2))" ), ) diff --git a/src/components/CalculatorForm.jsx b/src/components/CalculatorForm.jsx index b438e1f..1ffb258 100644 --- a/src/components/CalculatorForm.jsx +++ b/src/components/CalculatorForm.jsx @@ -51,7 +51,7 @@ const buildShareableUrl = (request, { compare = false, view = "net", income = nu if (request.zip_code) params.set("zip", request.zip_code); if (compare) params.set("compare", "1"); if (view !== "net" && VIEWS.includes(view)) params.set("view", view); - if (income > 0) params.set("income", String(income)); + if (income != null && income >= 0) params.set("income", String(income)); const baseUrl = window.location.origin + window.location.pathname; return `${baseUrl}#calculator?${params.toString()}`; @@ -112,7 +112,7 @@ const getLinkFromUrl = () => { form: getFormDataFromUrl(), compare: params.get("compare") === "1", view: VIEWS.includes(view) ? view : "net", - income: income > 0 ? income : null, + income: income >= 0 ? income : null, }; }; diff --git a/src/components/CalculatorForm.test.jsx b/src/components/CalculatorForm.test.jsx new file mode 100644 index 0000000..f62b0e3 --- /dev/null +++ b/src/components/CalculatorForm.test.jsx @@ -0,0 +1,65 @@ +// The calculator's links carry the earnings entered. $0 of earnings gets cards +// like any other income, so a link keeps it; a blank box leaves it out. +import { afterEach, describe, expect, test } from "bun:test"; +import { buildShareableUrl, getLinkFromUrl } from "./CalculatorForm"; + +const REQUEST = { + age_head: 40, + age_spouse: null, + dependent_ages: [], + state: "PA", + county: "Lebanon County", + zip_code: "", +}; + +// The page's address, which the link helpers read from window.location. +const originalWindow = globalThis.window; +function at(hash = "") { + globalThis.window = { + location: { origin: "https://policyengine.org", pathname: "/us/aca-calc", hash }, + }; +} +afterEach(() => { + globalThis.window = originalWindow; +}); + +// The query of the link for some income on the "Your household" tab. +function linkQuery(income) { + at(); + const hash = new URL(buildShareableUrl(REQUEST, { view: "impact", income })).hash; + return new URLSearchParams(hash.slice(hash.indexOf("?") + 1)); +} + +// The income a link opens with. +function openedIncome(query) { + at(`#calculator?age=40&state=PA&county=Lebanon+County&view=impact${query}`); + return getLinkFromUrl().income; +} + +describe("a link's income", () => { + test("keeps $0", () => { + expect(linkQuery(0).get("income")).toBe("0"); + }); + + test("keeps $40,000", () => { + expect(linkQuery(40_000).get("income")).toBe("40000"); + }); + + test("is left out for a blank box", () => { + expect(linkQuery(null).has("income")).toBe(false); + }); + + test("opens at $0 when the link asks for $0", () => { + expect(openedIncome("&income=0")).toBe(0); + }); + + test("opens at the amount a link asks for", () => { + expect(openedIncome("&income=40000")).toBe(40_000); + }); + + test("opens blank without an income, or with one that isn't a number or is below $0", () => { + expect(openedIncome("")).toBeNull(); + expect(openedIncome("&income=abc")).toBeNull(); + expect(openedIncome("&income=-5")).toBeNull(); + }); +}); diff --git a/src/components/CalculatorResults.jsx b/src/components/CalculatorResults.jsx index 70477cf..f9c2bc7 100644 --- a/src/components/CalculatorResults.jsx +++ b/src/components/CalculatorResults.jsx @@ -64,7 +64,7 @@ function describeMembers(indices, people) { // Medicaid's limit up to 200% FPL. New York's limit was 250% until its section // 1332 waiver ended on June 30, 2026; the model's eligibility is annual, so it // keeps 250% for all of 2026. People the program covers can't enroll in a -// Marketplace plan (42 U.S.C. 18051(e)). +// Marketplace plan (42 U.S.C. 18051(e)(2)). const BASIC_HEALTH_PROGRAMS = { DC: { state: "DC", @@ -372,12 +372,12 @@ function CalculatorResults({ // The tab and income a link opened on, or an example household's income, // so its cards match the Overview. const [activeTab, setActiveTab] = useState(initialTab); - const [userIncome, setUserIncome] = useState(initialIncome ? String(initialIncome) : ""); + const [userIncome, setUserIncome] = useState(initialIncome != null ? String(initialIncome) : ""); // Tell the calculator what's on screen, for the page's link. useEffect(() => { const income = parseFloat(userIncome); - onViewChange?.({ tab: activeTab, income: income > 0 ? income : null }); + onViewChange?.({ tab: activeTab, income: income >= 0 ? income : null }); }, [activeTab, userIncome, onViewChange]); // An answer from before the API took a year is for 2026.