"""Freelance rate and capacity: the hourly rate that reaches a take-home income target after tax and deductible overhead, over the hours that can really be billed, plus day and project rates. Inputs: tax_rate_percent (0 to 95, required, effective rate on profit), target_annual_income (1 to 1e9, default 140000, after tax), annual_business_overhead (0 to 1e9, default 22000, deductible), buffer_percent (0 to 100, default 15), working_weeks_per_year (1 to 52, default 46), working_hours_per_week (1 to 168, default 40), billable_utilization_percent (1 to 100, default 65), project_hours (1 to 10000, default 35). Returns minimumViableHourlyRate, targetHourlyRate, requiredDayRate, requiredProjectRate, billableHoursPerYear, annualRevenueNeededNoBuffer, annualRevenueNeededWithBuffer (dollars, cents). mysi, Freelance rate and capacity, mysi.dev/freelance-rate-capacity-planner, version 1, changed 2026-12-04. MIT. """ import math def _freelance_rate_capacity_planner_num(name, value, low, high): if isinstance(value, bool) or not isinstance(value, (int, float)) or not low <= value <= high: raise ValueError(f"{name} must be a number from {low} to {high}") return float(value) def _freelance_rate_capacity_planner_r2(x): return math.floor(x * 100 + 0.5) / 100 # to the cent, halves up def freelance_rate_capacity_planner(tax_rate_percent, target_annual_income=140000, annual_business_overhead=22000, buffer_percent=15, working_weeks_per_year=46, working_hours_per_week=40, billable_utilization_percent=65, project_hours=35): num = _freelance_rate_capacity_planner_num income = num("target_annual_income", target_annual_income, 1, 1e9) overhead = num("annual_business_overhead", annual_business_overhead, 0, 1e9) tax = num("tax_rate_percent", tax_rate_percent, 0, 95) / 100 buffer = num("buffer_percent", buffer_percent, 0, 100) / 100 weeks = num("working_weeks_per_year", working_weeks_per_year, 1, 52) hours = num("working_hours_per_week", working_hours_per_week, 1, 168) util = num("billable_utilization_percent", billable_utilization_percent, 1, 100) / 100 project = num("project_hours", project_hours, 1, 10000) # take-home = (revenue - overhead) x (1 - tax): gross up the income, then add the overhead needed = income / (1 - tax) + overhead with_buffer = needed * (1 + buffer) billable = weeks * hours * util r2 = _freelance_rate_capacity_planner_r2 target = r2(with_buffer / billable) return { "minimumViableHourlyRate": r2(needed / billable), "targetHourlyRate": target, "requiredDayRate": r2(target * 8), # 8-hour day: ILO Convention No. 1, 1919 "requiredProjectRate": r2(target * project), "billableHoursPerYear": r2(billable), "annualRevenueNeededNoBuffer": r2(needed), "annualRevenueNeededWithBuffer": r2(with_buffer), } FREELANCE_RATE_CAPACITY_PLANNER_CASES = [ (dict(target_annual_income=140000, annual_business_overhead=22000, tax_rate_percent=28, buffer_percent=15, working_weeks_per_year=46, working_hours_per_week=40, billable_utilization_percent=65, project_hours=35), {"minimumViableHourlyRate": 180.97, "targetHourlyRate": 208.12, "requiredDayRate": 1664.96}), (dict(target_annual_income=60000, annual_business_overhead=10000, tax_rate_percent=25, buffer_percent=10, working_weeks_per_year=45, working_hours_per_week=40, billable_utilization_percent=50, project_hours=20), {"minimumViableHourlyRate": 100.0, "targetHourlyRate": 110.0, "requiredDayRate": 880.0}), (dict(target_annual_income=50000, annual_business_overhead=0, tax_rate_percent=0, buffer_percent=0, working_weeks_per_year=50, working_hours_per_week=40, billable_utilization_percent=100, project_hours=10), {"targetHourlyRate": 25.0, "requiredDayRate": 200.0, "requiredProjectRate": 250.0}), ] def freelance_rate_capacity_planner_check(tolerance=1e-3): for given, want in FREELANCE_RATE_CAPACITY_PLANNER_CASES: got = freelance_rate_capacity_planner(**given) for name, value in want.items(): close = abs(got[name] - value) <= tolerance * max(1, abs(value)) assert close, (name, got[name], value) return "ok" if __name__ == "__main__": import json, sys freelance_rate_capacity_planner_check() given = dict(a.split("=", 1) for a in sys.argv[1:] if "=" in a) js = lambda v: v.lstrip("-")[:1].isdigit() or v[:1] in '[{".' or v in ("true", "false", "null") given = {k: json.loads(v) if js(v) else v for k, v in given.items()} if given: print(json.dumps(freelance_rate_capacity_planner(**given)))