Repository navigation
Add firm entity and firm-side tax rules - #2940
vahid-ahmadi wants to merge 28 commits into
Conversation
Adds a Firm entity beside person, benunit and household as a root population (no person membership), with firm-level rules for employer NICs and the Employment Allowance, the apprenticeship levy, corporation tax with capital allowances, R&D relief and the bank surcharge, England business rates, firm-side VAT and auto-enrolment. Incidence variables are added but not wired into gov_tax or household_tax. Refs #2939 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…yment Allowance out of firm-only tax Employer NI rate reforms raised the Employment Allowance of firms under the cap, which leaked into firm_tax_change_total and double counted with ni_employer. firm_only_tax now leaves the allowance out, and firm_tax_change_total adds only the change from the allowance's own rules at baseline liabilities. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Aggregate impact on certified data: passBase Checks: 0 broken by this change, 1 failing on both sides, 0 fixed. Moves flagged for review: 0 (thresholds in Notes
Moves flagged for reviewNone. Spending by benefit and service
Caseloads
Household net income by decileNo household's net income changes in any year. No change in any year: receipts by tax head; government balance, each component counted once; model totals; household income totals; population; poverty rates; people in poverty; inequality; mean household net income in each side's own deciles; standard reform costings (change in gov_balance); standard reforms: change in each reform's target. Checks failing on both base and head (1)
Counted-once checkThe check raised each of 92 components by £1 per unit in 2026-27 and read every head of its totals household by household: its own head must rise by exactly £1, no other tax head may move, no other benefit may rise, and the model's own total must move by what its heads moved. A response that is not finite breaks every rule. The check measures a head that breaks a rule twice more: once holding every other head at its baseline value, and once holding every other head at its value after the first £1 while the component rises again. The head fails where either measurement still shows the response. The check cannot hold a head at a value that is not finite. In each unit where another head is not finite after the first £1, it holds that head at its baseline value, and the second measurement judges no household the unit belongs to. There a head fails wherever it first broke a rule, or wherever the check could not confirm whether its response contains the component. 0 failed and the check skipped 0.
Provenance
Dataset: Receipts by tax head: head levels
Spending by benefit and service: head levels
Caseloads: head levels
Government balance, each component counted once: head levels
Model totals: head levels
Household income totals: head levels
Population: head levels
Poverty rates: head levels
People in poverty: head levels
Inequality: head levels
Mean household net income in each side's own deciles: head levels
Standard reform costings (change in gov_balance): head levels
Standard reforms: change in each reform's target: head levels
|
…redits from firm aggregates - Core Simulation.clone (used by the YAML runner and by formulas that clone, such as marginal tax rates) now keeps root populations; this fixes KeyError: 'firm' in 26 YAML tests. - Later-year firm tables must hold the same firms as the first year; tables without firm_id are numbered; filter_dataset keeps the firm table; validate rejects non-firm columns in the firm table. - firm_tax and firm_only_tax subtract R&D credits paid out (excess RDEC and the ERIS payable credit). - Sentence-case labels on corporation tax variables. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Core marks firm as a person-like entity, so the app would otherwise offer the 52 firm inputs as person variables in the household builder. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolves the remaining UNVERIFIED notes, backfills auto-enrolment thresholds for 2012-2018, adds missing references, and records the Finance Bill 2026-27 stage for announced-not-enacted values. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d gate, single firm clone - firm_tax_change_total holds last year's employer NI liabilities at baseline too, so a rate reform cannot flip eligibility under the 2020-21 to 2024-25 prior-year limit; mismatched baseline firm tables raise. - Replace the frozen regression fixture with structural checks (no firm variable in gov_tax or the budget totals) and live checks that firms and firm-only reforms leave household results unchanged. - The UK Simulation.clone reuses the root population the patched core clone already made. - Corporation tax verified_start_year 2026; docs wording. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ates Draw region (ONS UK Business 2025 Table 8) and legal status (Table 13) per firm after calibration, with Table 15 held out, and export them as policyengine-uk's firm_region, firm_in_england, firm_legal_form and firm_is_public_body. Record the status of all 52 policyengine-uk firm inputs, check the export against an ast snapshot of policyengine-uk's firm variables, and declare value-free M2 target candidates. The 8-target uk_firms_targets.json contract is unchanged. Refs #1705, PolicyEngine/policyengine-uk#2940. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…; pay-distribution inputs; source checks - Toy-frame microsimulation test (200 firms) checking each programme against an independent calculation, and a contract test for the columns microcosm reads and writes. - Worked firm reform examples page, every figure asserted in a test. - Optional inputs for staff below the secondary threshold and outside the auto-enrolment band, identical results when absent. - Remaining parameter values confirmed against sources; SBRR boundary cases; firm_in_freeport documented as not yet read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Clip the optional pay-distribution inputs to the firm's headcount and paybill, and document it. - A baseline without the same firm table raises in firm_tax_change_total. - Parity test between the Employment Allowance rule-change helper and employment_allowance; keep-in-step notes on both sides. - Docs describe the optional inputs and the earnings trigger; wording 'at or below' the threshold and trigger. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tools/build_uk_firms.py runs generation, attribute draws and the policyengine-uk table export to uk_firms.parquet with a JSON receipt (no publish path, required --rules). PolicyEngineUKFirmRules runs policyengine-uk's firm entity on the candidate table and reads firm_vat_liability_if_registered; it imports policyengine-uk lazily and is tested engine-free with a fake simulation, and was checked locally against PolicyEngine/policyengine-uk#2940. Refs #1705. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s, document the CT gap, register it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…charge base, day-weighted 2026-27 surcharge rate Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…aper rounding, firm Class 1A NIC, RDEC PAYE/NIC cap Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ther than infinite defaults Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Scotland scope notes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…oundary and reform tests - Wales 2026-27: retail multiplier 0.350 for shops, kiosks, pharmacies and post offices below £51,000 (WSI 2025/1163 reg 3; WSI 2026/39; LGFA 1988 Sch 7 para A19(2)), and the 19 public-service descriptions kept off the higher multiplier (reg 4). The thresholds are inert before 2026-27, so a reform to the single earlier multiplier reaches every Welsh property. The 2027-28 widening (WSI 2026/133) is documented, not modelled. - Tests: CT 2023-2025, the 2025 loss allowance edge, the Employment Allowance £100,000 prior-year edge and 2025 change, NIC year transitions, firm_rd_intensity, the AIA share, the England 2023-24 £51,000 multiplier edge, and four parameter-reform-to-incidence tests. - Docs: veterans relief on firm_zero_rated_class_1_earnings, the stale PAYE/NIC cap sentence, and a list of firm taxes not modelled. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rge, plant for leasing - VAT: the partial exemption recovery percentage is rounded up to a whole number, or to two decimal places above £400,000 a month of input tax (SI 1995/2518 reg 101(4)-(5), reg 101(5) added by SI 2005/762). - Capital allowances: a company disposing of fully expensed plant pays a balancing charge on the relevant proportion of the disposal value outside the main pool (CAA 2001 s.59A), via firm_disposal_proceeds_full_expensing. - Plant for leasing (firm_capex_main_pool_new_for_leasing) gets no full expensing (s.46 general exclusion 6) and takes the AIA then the s.45U main-rate FYA. Where the main-rate FYA is below the special-rate FYA, it takes the AIA before special-rate plant, so the order still gives the most relief in the year. - Docstrings: business rates cover Wales and Scotland; firm_n_properties drives SBRR and SBBS. Found by a Fable 5.2 rules audit; fixes reviewed by Fable 5.2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… rate, English rates gating - CTA 2009 s.1056(2)(a): the R&D surrenderable loss is reduced by relief against same-period non-trading profits, so the loss is not relieved twice. - The SME payable credit is capped at £20,000 plus 3x relevant PAYE/NIC from accounting periods beginning 1 April 2021 (s.1058(1)(aa)/(1A), then s.1112B), when firm_rdec_paye_nic_cap_supplied is set. - New firm_small_profits_rate_excluded: close investment-holding and non-resident companies pay the main rate with no marginal relief (CTA 2010 s.18A, s.18B, s.18N; s.1042K(5) notional tax). - England: RHL multipliers apply to occupied property only; before 2024-25 empty and charity property paid the standard multiplier (SI 2024/111); empty property below the reg 4(g) threshold (£2,900 from 2017-18) is exempt while empty. Audit and review by Fable 5.2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Reviewed at fa48a299b. The firm entity is the right idea, and the split that avoids double counting holds, with one gap. My main concern is how the entity attaches to policyengine-core. Below: your three questions first, then the PR's status, then one note.
Entity design
The concept is right:
- Firms are their own population, with their own ids and weights.
- They have no members until a job-link table exists.
- Reading or mapping values between firms and other entities raises an error.
- The certified-data aggregate-impact check confirms that no household or government total moves.
The risk is in how it attaches to core:
- The patches apply to every model in the process.
tax_benefit_system.pyreplacesTaxBenefitSystem.instantiate_entitiesandSimulation.cloneon core's own classes at import. That covers, for example, policyengine.py running the US and UK models side by side. The replacements pass through when there are no firms, so the risk is the dependency on core, not a change in behaviour. - It depends on core's private names, with no upper bound on core. Two modules import core's private
_branch_clone.simulation.pyreaches into private attributes:_holders,_memory_storage,_get_exportable_input_periods,_to_person_dataframeand_bind_to_tax_benefit_system. The pin ispolicyengine-core>=3.34.9, so a core release that renames_branch_clonewould breakimport policyengine_ukfor every user, whether or not they use firms. simulation.pygrows by about 350 lines of special cases. They cover binding, cloning, exports,map_result, and the situation and dataset builders, and they track core internals. Each one is a place where a core change could silently drop the firm population.- Core treats the firm as a person. It marks it
is_person=True, because a plainEntityis the only non-group kind it accepts. That is what forces the downstream changes.
My suggestion:
- Keep the design.
- File the core issue you have ready now, before PolicyEngine/policyengine.py#765 and PolicyEngine/policyengine-api#4339 build key comparisons into downstream code. The aim is to move root populations into core as a proper entity type.
- When the core changes are out, please make sure Anthony reviews them. We discussed the risks and code debt of patching core recently.
- Until then, add an upper bound on core and a CI job against core's main branch.
- If core won't take root entities, fall back to a separate firm simulation that shares the parameter tree. It would need no core patches, since firms and households never meet inside a formula.
Double counting of employer NICs and VAT
The split holds:
firm_only_taxleaves out employer NICs and VAT, which reach households throughni_employerandvat.- Household business rates come from the outturn parameter
gov.hmrc.business_rates.statistics.revenue, which the firm multipliers don't touch. - CT, the levy and the surcharge have no household term.
Gaps:
- The interaction between the Employment Allowance and NIC rates is dropped.
- Liabilities are held at baseline, so a rate or threshold change counts in full on the household side, which has no Employment Allowance. That includes employers whose liability stays under the allowance and who in fact pay nothing more.
- The firm side subtracts only the change that comes from the allowance's own rules.
- So the split overstates the yield of NIC rises and the cost of cuts. It matters most for packages like April 2025's: a 15% rate, a £5,000 threshold and a £10,500 allowance.
- One fix: subtract the full change in the allowance, computed on the reform's liabilities, and keep household
ni_employergross.
- VAT threshold and Flat Rate Scheme reforms reach no household total. This is documented. Splitting the VAT change the same way would carry them without counting rate changes twice: take only the change from rule changes, with rates held at baseline.
- There are two levers for business rates: the household outturn parameter and the firm multipliers. The docs should say which one a reform should change.
- CT could also be counted twice.
corporate_incident_tax_changeand a firm-side CT reform would add up if both were set. - The incidence shares aren't checked to sum to 1. The default, all to capital, puts the whole change on UK shareholders, with no share for foreign owners.
Announced values (12% WDA, 50% FYA, 6% surcharge)
Keep them in the baseline. pe-uk's own convention, in docs/book/policy/future-date-announcements.md, puts announced future-dated values in the baseline with the announcement cited. It keeps gov.contrib for changes that haven't been announced, and replaces a row when a measure is reversed. Add the Finance Act references at Royal Assent.
The three values match the HMRC Budget 2026 policy papers:
- Bank surcharge: 6% from 1 January 2027 for 15 months, back to 3% from 1 April 2028. Periods that straddle 1 April 2028 are split at 31 March 2028.
- Main-rate WDA: 12% for chargeable periods beginning on or after 1 April 2027.
- Main-rate FYA: 50% for expenditure from 1 January 2027.
Two small points on the surcharge:
- It is day-weighted over the wrong year. The weighting runs over 6 April to 5 April rather than the CT year, 1 April to 31 March. So 2027-28 gets 361/366 of a year at 6%, where the policy paper gives the whole financial year at 6%. Every year with a rate change is slightly off in the same way. A CT window for
fiscal_year_blendwould fix it. - The body and the YAML disagree. The body's "Known simplifications" says the 6% isn't apportioned, but the YAML day-weights it.
Status
- CI isn't green at the head. In run 45182122591, Python shards 2, 5 and 6 hit the 90-minute limit and were cancelled, so Test / Result failed. The five shards that finished ran 8,428 tests with no failures.
- The downstream PRs are already open. The body says they aren't opened yet, but PolicyEngine/policyengine.py#765 and PolicyEngine/policyengine-api#4339 have been open as drafts since 23 November.
- Not every value is confirmed yet. The body says about 150 of the 173 dated values were confirmed, and the WDA and FYA rows say their clause numbers aren't verified.
Note
- The default NIC base understates earnings above the threshold. Without a pay split it is paybill less headcount × threshold, so one low earner's unused threshold is netted against everyone else's pay. The docstring says so, and microcosm's runs show it: 0.828× the official figure with paybill alone, and 1.036× with the ASHE pay split.
Checked
- The core patches, the
simulation.pychanges and the firm aggregate and incidence variables, read in full. - The three Budget 2026 values, against the HMRC policy papers on GOV.UK.
- The CI log at the head.
|
Thanks María, this is very useful. My replies, point by point: Core attachment. Agreed, keep the design but stop patching core. I'll file the core issue for root populations this week, before policyengine.py#765 and policyengine-api#4339 build on the current shape, and ask Anthony to review the core changes. Until core supports them, I'll cap Employment Allowance and NIC rates. You're right. Holding liabilities at baseline drops the case where a firm stays under the allowance after a rate rise, so the split overstates the yield. I'll change VAT threshold and Flat Rate Scheme. I'll split VAT the same way: only the change from rule changes, with rates held at baseline, so rate changes aren't counted twice. Business rates and CT levers. I'll document which lever a reform should use: firm multipliers for firm-level analysis, the outturn parameter for household-only runs. I'll also add a guard against setting Announced values. Keeping them in the baseline, per Surcharge weighting. Good catch. I'll add a CT-year window (1 April to 31 March) for Status. I'll fix the body (the downstream PRs are open, and the confirmed-values count), confirm or flag the WDA and FYA clause numbers, and look at why shards 2, 5 and 6 hit the 90-minute limit. NIC base. Agreed. Without the ASHE pay split, the default nets one low earner's unused threshold against everyone else's pay. I'll make the pay split the default when it's available and keep the paybill-only path as a labelled fallback. Reply drafted with AI assistance. |
…e master The firm entity replaces core's instantiate_entities and Simulation.clone, imports core's private _branch_clone and reads private holder attributes, so a core rename would break `import policyengine_uk`. The cap holds core below the next minor version, and the Core master workflow runs the firm and core-internals tests on core's default branch for each code change and weekly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Household ni_employer counts the gross change in employer National Insurance. firm_tax_change_total held each firm's liabilities at baseline when it measured the allowance, so a firm that stays under the allowance after a rate rise was counted as paying more. It now subtracts the full change in the weighted Employment Allowance, each simulation computing it on its own liabilities (including the 2020-21 to 2024-25 prior-year limit), so the two sides together count the change in what firms pay. Tests: a rate rise for a firm under the allowance nets to zero (-7,000 on the firm side); the April 2025 package on a 2024-25 firm (-19,202.40); a rate rise past the prior-year limit counts the lost allowance (+25,000), and supplied prior-year liabilities keep it (0). The mirror helper and its keep-in-step comments are removed. Design and review by Fable 5.2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Household vat carries VAT rate changes, so firm_tax_change_total left VAT out and reforms to the registration threshold, the flat rate scheme and partial exemption reached no household total. It now adds the change in weighted firm VAT under the reform's rules with the rates held at baseline: only firm_output_vat reads the rates (firm_flat_rate_turnover through it), so those come from the baseline and everything else from the reform. A firm whose registration flips counts its full liability at baseline rates; a reform that changes both rates and rules drops their interaction. Tests: the no-reform identity (1,788,080), a rate-only reform (0), a 100,000 threshold (-98,000), a 15% default flat rate (+47,520), rate plus threshold (-98,000), and a threshold cut that registers a partly exempt firm (+89,250). Design and review by Fable 5.2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…relief, VAT de minimis, NI rates, SDIL and PPT to firms Fourth audit (Fable 5.2, four areas against fetched statute). All new inputs default to 0, False or UNKNOWN, and the full YAML suite is unchanged at those defaults. - Off-payroll deemed direct payments: secondary Class 1 for the fee-payer (SI 2000/727 regs 14, 17, 18), no Employment Allowance (NICA 2014 s.2(4)), and in the apprenticeship levy pay bill (FA 2016 s.100). Public authorities from April 2017, other clients from April 2021. - Class 1A on termination awards above £30,000 from April 2020 (SSCBA s.10(1A); ITEPA s.403), at the secondary rate (15.05% in 2022-23). - Class 1B on PAYE settlement agreements (SSCBA s.10A), 14.53% in 2022-23. - Group relief: Part 5 claimed amount capped at total profits, before carried-forward losses (CTA 2010 ss.137-140, 269ZFA); Part 5A from April 2017; non-banking group relief added back to bank surcharge profits; loss surrendered reduces the R&D surrenderable loss (CTA 2009 s.1056). - VAT: direct attribution of input tax (reg 101(2)) and the de minimis tests (regs 105A, 106) behind firm_applies_partial_exemption_de_minimis. - Northern Ireland rates from 2023-24 with firm_northern_ireland_district: regional and district poundages, SBRR (SR 2010/4) to March 2027, charity exemption, unoccupied property at half rate. - Soft drinks industry levy (FA 2017 Part 2) and plastic packaging tax (FA 2021 Part 2), in firm_tax and firm_only_tax. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…in the pay split NIC base All new inputs default to 0 (1 for firm_rpdt_allowance_share), and every existing firm output is unchanged at those defaults. - Patent Box (CTA 2010 s.357A): RP x (rate - 10%) / rate on supplied relevant IP profits, the main rate before April 2023 and the applicable rate from then (F(No.2)A 2023 s.11; CIRD201020), phased in 60% to 100% (FA 2012 Sch 2 para 8). firm_profits_before_losses now nets the deduction. - Residential property developer tax (FA 2022 ss.33, 43, 51): 4% above the group-shared £25m allowance, not deductible for CT. - Digital services tax (FA 2020 ss.46-47): 2% above £25m of group UK revenues where worldwide revenues exceed £500m. - Energy profits levy: 25%, 35% and 38%, day-weighted, to 31 March 2030. - All four in firm_tax and firm_only_tax, with registry entries, docs and reform-to-incidence tests. - Employer NIC: tests pin the pay split precedence and its two edge cases; docs say the split must be measured at the year's threshold. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… effect Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…final review - Test: a supplied employer NIC base is used as given with a pay split. - Docs: EPL day-weighting, the DST inputs and defaults, the Patent Box rate, RPDT profits net of RPDT loss and group relief, the pay split threshold note on both inputs, and the Transitional Relief Supplement, SBRR second-property and RHL bill cap updates from BRIL 8/2026. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fixes #2939
What and why
Adds a firm entity to policyengine-uk beside person, benefit unit and household, and firm-level rules for the main business taxes. Today the model only spreads national totals of firm taxes over households (business rates, corporate SDLT,
corporate_incident_tax_change). Corporation tax and the apprenticeship levy are listed underuncovered_receipts, and the Employment Allowance is not modelled.Part of #1320 (firm-level VAT and a Firm entity): this PR adds the entity and firm-side VAT, but not the sector-driven supply split or a calibrated firm dataset, so #1320 stays open.
The PR is a draft and still in progress. The design notes and the decisions behind them are below. The firm dataset itself is being built in microcosm (PolicyEngine/microcosm#1706).
Entity design
firm_weight), which come from business data rather than FRS households. No person is a member of a firm.Firmis built. It is a plain coreEntitylisted afterPerson([Person, BenUnit, Household, Firm]), so core treats it as neither the person entity nor a group entity.TaxBenefitSystem.instantiate_entities(intax_benefit_system.py) gives it aRootPopulation. This also covers coreReformsystems built by the YAML runner.RootPopulationraises on cross-entity shortcuts such asfirm.household._bind_to_tax_benefit_system(reforms and baselines),cloneandget_branch.map_resultraises when asked to map firm values to or from another entity.build_from_situationaccepts an optionalfirms: {name: {variable: value}}block.build_from_idstakes an optionalfirm_id.UKSingleYearDatasetandUKMultiYearDatasettake an optionalfirm=table.tablesstays three long, so uprating and subsampling are unchanged.subsampleraisesNotImplementedErrorwhen firms are present.Programs
All new variables use
entity = Firm. Every parameter has a legislation or GOV.UK reference. Values that have been announced but not yet enacted are marked in their YAML files.firm_employer_ni,firm_employer_ni_before_allowancegov.hmrc.national_insurance.class_1rate and threshold nodes. Earnings above the secondary threshold can be given as an input; by default they are approximated from paybill and employees.firm_class_1a_ni,firm_termination_award_class_1a_nifirm_class_1a_benefits), infirm_tax, notfirm_only_tax. From April 2020, Class 1A on termination awards above £30,000 per recipient (SSCBA s.10(1A); ITEPA s.403), at the secondary rate (15.05% in 2022-23), in both.firm_class_1b_nifirm_taxandfirm_only_tax.firm_off_payroll_employer_ni,firm_off_payroll_levy_earningsfirm_tax, notfirm_only_tax.soft_drinks_industry_levyfirm_patent_box_deductionfirm_relevant_ip_profits): the main rate before April 2023, the small profits rate where charged at it from then (CTA 2010 s.357A; F(No.2)A 2023 s.11; CIRD201020), phased in 60–100% (FA 2012 Sch 2 para 8). The rate test ignores losses and group relief (documented).residential_property_developer_taxdigital_services_taxenergy_profits_levyplastic_packaging_taxemployment_allowance,employment_allowance_eligibleapprenticeship_levyfirm_auto_enrolment_employer_contributioncorporation_tax,firm_taxable_profit,firm_marginal_relief,firm_losses_used, …firm_capital_allowances+ componentsfirm_rd_expenditure_credit,firm_rd_additional_deduction,firm_rd_payable_creditfirm_rdec_paye_nic_cap_suppliedis set.bank_surchargefirm_bank_surcharge_allowance_share). The announced 6% (1 January 2027 to 31 March 2028) is marked as not yet enacted and day-weighted into 2026-27; the blend window starts 6 April, so 1 April changes put 5 days into the previous year.firm_business_rates+ reliefsfirm_northern_ireland_district: NAV × (regional + district rate) for the 11 councils, SBRR (SR 2010/4) to March 2027, charity exemption, unoccupied property at half rate; 0 without a district.firm_vat,firm_vat_registered,firm_output_vat, …firm_applies_partial_exemption_de_minimis(default false; the law makes them mandatory, so data builders should set it). Reuses the existing VAT rate nodes.firm_minimum_wage_cost,firm_paybill_after_minimum_wagefirm_low_paid_hours,firm_low_paid_paybill) up to the adult rate. The levy and the default employer NIC and auto-enrolment approximations read the topped-up paybill. A firm cost, not a tax. 0 for compliant firms and before October 2010.Aggregates and incidence (not wired into totals)
firm_tax: total statutory liability, less R&D tax credits paid out to the firm (RDEC in excess of corporation tax, and the ERIS payable credit).firm_only_tax: the liability set by rules only the firm side models: CT, bank surcharge, levy, business rates, termination Class 1A, Class 1B, SDIL, PPT, RPDT, DST and EPL, less R&D credits paid out. Employer NIC and VAT rates are left out, because they already reach households throughni_employerandvat. The Employment Allowance is left out too:firm_tax_change_totalsubtracts its full change.firm_tax_change_total: the reform less baseline change infirm_only_tax, weighted byfirm_weight, less the change in the weighted Employment Allowance (each simulation on its own employer NIC liabilities), plus the change in firm VAT from VAT rules other than the rates (registration threshold, flat rate scheme, partial exemption) with the rates held at baseline.ni_employerstays gross, so the two sides together count the change in what firms pay after the allowance: a firm that stays under the allowance after a rate rise nets to zero (tests: a 2026 rate rise, −7,000; the April 2025 package on a 2024-25 firm, −19,202.40). Without a supplied prior-year input, a rate rise past the 2020-21 to 2024-25 £100,000 limit counts the lost allowance (+25,000).vatcarries rate changes, so the VAT term uses baseline rates. A firm whose registration flips counts its full liability at baseline rates, and a reform that changes both rates and rules drops their interaction (tests: rate-only 0, threshold −98,000, flat rate +47,520, a partly exempt firm registering +89,250).firm_tax_incidence: splitsfirm_tax_change_totalbetween households by capital, consumption and labour shares. The shares come from newgov.contrib.policyengine.firm_incidenceparameters, which default to capital 1.GOV_TAX_VARIABLES,household_tax,programs.yamlbudget lists orfiscal_partition.yaml. That waits for a calibrated firm dataset from microcosm. Household outputs are therefore unchanged by construction. A regression gate checks that adding firms, or a firm-only reform, leaves household results exactly unchanged.Downstream changes needed before release
Core marks
firmasis_person=True, because a plainEntityis the only non-group entity core accepts. Downstream code that readsis_personsees two person entities. Read-only research found these consequences:tests/test_model_entities.py:90asserts that the person entities are exactly["person"], so the UK release certification run would fail. The fix is insrc/policyengine/tax_benefit_models/common/model_version.py:213: deriveis_personby comparing against the system's person entity key, then update the pinned entities.policyengine_api/data/v2/catalog/extraction.py:281raises unless there is exactly one person entity.policyengine_api/country.py:413reportsis_person: truefor firm in v1 metadata.VariableResolver.ts:55would offer firm inputs as person inputs. This PR setshidden_input = Trueon all 58 firm inputs, so they stay out of the household builder until a firm builder exists.Household calculations without firms work unchanged in the API. The fixes are open as drafts: PolicyEngine/policyengine.py#765 (key-based
is_personand entity pins; 76 tests pass on the pinned UK version and on this branch) and PolicyEngine/policyengine-api#4339 (v1 metadata). This PR should not be released until the policyengine.py fix is released.Compatibility with policyengine-core
TaxBenefitSystem.instantiate_entitiesandSimulation.cloneso they keep root populations. Both patches are guarded and idempotent. The clone patch is what lets the YAML runner, and formulas that clone the simulation (such as marginal tax rates), see firms.pyproject.tomlcaps core below 3.38..github/workflows/core_master.yaml) runs the firm and core-internals tests against core's default branch on each code change and every Monday, so a rename of_branch_cloneor the holder internals fails in CI before a release reaches the cap. It is not a required check.Known simplifications
firm_zero_rated_class_1_earnings.firm_in_freeportis recorded but no rule reads it yet. Freeport capital allowances and business rates relief are not modelled.firm_idcomes back as int32.docs/book/policy/future-date-announcements.md, and the Finance Act references will be added at Royal Assent.Fourth audit, 27 November
Four Fable 5.2 agents read the NIC and levy, CT, VAT and rates formulas against fetched statute (notes outside the repo). They found no new error in the default paths. Two bank-only gaps are now documented, not modelled: the s.269DC add-back of pre-2016 and non-banking losses, and the s.269CA 25% cap on pre-April 2015 bank losses. Their specs became the rules in
c7e09f933(batch 1) and015d498d5(batch 2: Patent Box, RPDT, DST, EPL), each reviewed by Fable before commit. Every new input defaults to 0, False or UNKNOWN; at those defaults the full YAML suite is unchanged, and a random-firm comparison of all 79 existing firm outputs against the previous head (4,000 firms, 2010–2030) found zero differences.Follow-ups from the 24 November review
firm_tax_change_total: subtract the full Employment Allowance change computed on reform liabilities, keeping householdni_employergross; test the April 2025 package with a firm that stays under the allowance.fiscal_year_blend.corporate_incident_tax_changeand a firm-side CT reform together; check that the incidence shares sum to 1; add a foreign-owner share.Test plan
policyengine_uk/tests/policy/baseline/gov/hmrc/{corporation_tax,bank_surcharge,apprenticeship_levy,vat/firm,business_rates/firm,national_insurance/employer,national_insurance/employment_allowance,minimum_wage/firm}and.../gov/dwp/auto_enrolment. Boundary cases (at, just above and just below each limit) for CT marginal relief with associated companies, the levy allowance, the VAT threshold including the 2024 change year, and SBRR, checked against the statutory wording.test_firm_entity.py,test_firm_incidence.py,test_supplied_inputs.py: 119 passed.test_entity_ids,test_input_dataframe_export,test_dataframe_dataset,test_build_metadata,test_variable_units,test_parameter_metadata,test_subsample,test_household_subset,test_supplied_inputs, and the code_health tests.test_firm_regression_gate.py, 34 passed):GOV_TAX_VARIABLESmember or a budget term.70014b3exactly (35 passed). It was dropped so that later changes to household rules don't break this test.test_firm_incidence.py), thefirms:guard for YAML (test_firm_yaml_guard.py), and 3 integration cases (tests/policy/integration/firm/).test_firm_microsimulation.py): a seeded 200-firm frame checks weighted CT, levy, employer NIC, business rates and VAT against an independent numpy calculation. It also checks thefirm_taxidentity, that every firm variable is finite, and that household totals are unchanged whether or not the dataset has a firm table. The totals are toy numbers, not estimates.test_firm_microcosm_contract.py): checks the 10 firm columns and outputs the microcosm frame (UK firm data: paper-parity port on the shared firm layer microcosm#1706) reads or writes.docs/book/usage/firm-reforms.md): every figure on it is asserted intest_firm_docs_examples.py.UNVERIFIEDnotes remain. The clause numbers for the 12% main WDA and the 50% main-rate FYA are still to be confirmed against the Finance Bill.programs.yamlregisters 9 firm programmes (business rates now covers England, Wales and Scotland) aspartial(test_program_registryand the budget tests pass). New docs page:docs/book/usage/firms.md.mainthe same shards already take 82 to 90 minutes, and a local benchmark shows no slowdown in household simulations from this branch.mainmerged, so the Python tests run on ten shards; core capped below 3.38; Core master workflow; Employment Allowance and VAT incidence fixes): passed. The run at 70a842c was superseded before it finished. Locally: test_firm_incidence.py 37 passed, test_firm_docs_examples.py 15, test_firm_microcosm_contract.py 13, test_firm_microsimulation.py 9. The firm entity tests pass locally on core 3.34.9 and on core master (3.37.2).test_firm_additional_rules.py(reform-to-incidence).is_personflag: Publish only the person entity as is_person policyengine.py#765 and Describe only the person entity as a person in country metadata policyengine-api#4339. Release Add firm entity and firm-side tax rules #2940 only after the policyengine.py fix is released.make format(ruff format + ruff check).changelog.d/firm-entity-engine.added.mdandchangelog.d/firm-entity-engine-rules-4.added.md.Reproducer
Reproducer: policyengine_uk/tests/test_firm_entity.py, policyengine_uk/tests/test_firm_additional_rules.py
axiom: needed (new firm-side programmes. The rulespec-uk parity issues are not yet opened and are left for a maintainer's decision.)
🤖 Generated with Claude Code