Free code asset

Free ACA Affordability Check Script (Python)

A small, free script that screens your census for ACA affordability using the three IRS safe harbors. Download it, run it on your own computer, and get a results CSV.

Send Us Your Renewal

The script

Download and run it

Tested on a sample census before publishing. It runs locally, needs no installs and sends nothing anywhere.

#!/usr/bin/env python3
"""CFH ACA affordability screen.

Tests the employee's cost for the lowest-priced self-only plan that meets
minimum value against the IRS affordability percentage, using the three
safe harbors: W-2 Box 1, rate of pay, and federal poverty line.

Usage:
  python3 cfh_aca_affordability_check.py census.csv --year 2027
  python3 cfh_aca_affordability_check.py census.csv --year 2026 --fpl 15650

Required columns: employee, monthly_employee_cost
Optional columns: w2_box1_annual, hourly_rate, monthly_salary

Hourly workers use rate of pay x 130 hours a month. The poverty-line test
runs only when you pass --fpl (annual figure for one person, from HHS).
Percentages: 9.96% for 2026 plan years, 10.22% for 2027 plan years.
This is a screening aid, not tax or legal advice.
"""
import argparse
import csv

RATES = {2026: 0.0996, 2027: 0.1022}


def num(value):
    try:
        return float(str(value).replace('$', '').replace(',', '').strip())
    except ValueError:
        return None


def incomes(row, fpl):
    out = {}
    box1 = num(row.get('w2_box1_annual'))
    if box1:
        out['w2'] = box1 / 12
    hourly = num(row.get('hourly_rate'))
    salary = num(row.get('monthly_salary'))
    if hourly:
        out['rate'] = hourly * 130
    elif salary:
        out['rate'] = salary
    if fpl:
        out['fpl'] = fpl / 12
    return out


def main():
    ap = argparse.ArgumentParser(description=__doc__,
                                 formatter_class=argparse.RawDescriptionHelpFormatter)
    ap.add_argument('census')
    ap.add_argument('--year', type=int, default=2027, choices=sorted(RATES))
    ap.add_argument('--fpl', type=float, default=None)
    ap.add_argument('--out', default='affordability_results.csv')
    args = ap.parse_args()
    pct = RATES[args.year]

    results = []
    with open(args.census, newline='', encoding='utf-8-sig') as handle:
        for row in csv.DictReader(handle):
            cost = num(row.get('monthly_employee_cost'))
            name = (row.get('employee') or '').strip()
            if cost is None:
                results.append({'employee': name, 'monthly_cost': '',
                                'result': 'NO COST GIVEN'})
                continue
            inc = incomes(row, args.fpl)
            line = {'employee': name, 'monthly_cost': f'{cost:.2f}'}
            passed = []
            for key in ('w2', 'rate', 'fpl'):
                if key in inc:
                    limit = pct * inc[key]
                    ok = cost <= limit
                    line[key + '_limit'] = f'{limit:.2f}'
                    line[key + '_pass'] = 'yes' if ok else 'no'
                    passed.append(ok)
                else:
                    line[key + '_limit'] = ''
                    line[key + '_pass'] = 'n/a'
            if not passed:
                line['result'] = 'NO INCOME DATA'
            elif any(passed):
                line['result'] = 'AFFORDABLE'
            else:
                line['result'] = 'REVIEW: fails every safe harbor tested'
            results.append(line)

    fields = ['employee', 'monthly_cost', 'w2_limit', 'w2_pass', 'rate_limit',
              'rate_pass', 'fpl_limit', 'fpl_pass', 'result']
    with open(args.out, 'w', newline='', encoding='utf-8') as handle:
        writer = csv.DictWriter(handle, fieldnames=fields, restval='')
        writer.writeheader()
        writer.writerows(results)

    total = len(results)
    ok = sum(1 for r in results if r['result'] == 'AFFORDABLE')
    print(f'{args.year} plan year at {pct * 100:.2f}%: {ok} of {total} affordable.')
    print(f'Details written to {args.out}')


if __name__ == '__main__':
    main()
Census format

What your CSV needs

Start from the sample file if you want a working example.

Column Required What it holds
employee Yes A name or ID so you can match results to the census.
monthly_employee_cost Yes What the employee pays per month for the lowest-priced self-only plan that meets minimum value.
w2_box1_annual No Annual W-2 Box 1 wages. Used for the W-2 safe harbor.
hourly_rate No Hourly pay. The script multiplies it by 130 hours a month for the rate-of-pay test.
monthly_salary No Monthly salary, used for the rate-of-pay test when there is no hourly rate.

Run it with a CSV that has the first two columns at minimum. Everything else is optional.

Benefits Compliance

The Complete Compliance Guide

Benefits Compliance for Employers: ACA, COBRA, ERISA, Form 5500 and More

The ACA employer mandate and reporting, COBRA, ERISA and Form 5500 in one place.

Questions we get

Questions about the script

What it does and does not do.

What does the script check?

Whether the employee cost for the lowest-priced self-only plan that meets minimum value is within the IRS affordability percentage, using the W-2 Box 1, rate of pay and poverty-line safe harbors.

Which percentages does it use?

9.96% for 2026 plan years and 10.22% for 2027 plan years, from IRS Rev. Proc. 2026-26. Re-check them each year because the IRS indexes them annually.

What do I need to run it?

Python 3 and a CSV census. No packages to install. Run it from a terminal with the census file name and a plan year.

Does it replace a compliance review?

No. It screens a census and flags people to look at. Your broker, payroll provider or tax advisor should confirm the result before you rely on it.

Is my data uploaded anywhere?

No. The script runs on your own computer and writes a results CSV next to your census. Nothing is sent to CFH or anyone else.

Why does the poverty-line test need a number from me?

The federal poverty line changes every year, so the script takes it as an input instead of hard-coding a figure. Pass it with the –fpl option when you want that test.

Can I share or change the script?

Yes. Use it, adapt it and pass it to colleagues. If you improve it, tell us and we will link to your version.

Ready? Send us your renewal, or talk it through with someone first. No cost, no obligation.

Talk to an Expert

Sources

Where every figure on this page comes from.

IRS Rev. Proc. 2026-26

The 2027 affordability percentage.

Book a 30-minute call