Skip to content

Conversation

@MaxGhenis
Copy link
Collaborator

Summary

  • Fix fiscal year parameter handling to use April 30 reference date for annual queries
  • Ensures policies that change on April 6 (UK fiscal year start) are correctly reflected in simulations

Problem

Previously, convert_to_fiscal_year_parameters() only covered years 2015-2025 (range(2015, 2026)). When querying parameters for year 2026 or later, the system fell back to January 1 as the reference date instead of April 30.

This caused policies that change on April 6 (UK fiscal year start) to not be reflected in annual simulations. For example:

  • The two-child limit repeal on April 6, 2026 would show as limit=2 for 2026 simulations instead of limit=infinity
  • The salary sacrifice cap starting April 6, 2029 would not be reflected in 2029 simulations

Solution

  1. Add convert_instant_to_fiscal_year() function that converts year-only and January 1 queries to April 30 of that year
  2. Override get_parameters_at_instant() in CountryTaxBenefitSystem to apply this conversion on-the-fly
  3. Make convert_to_fiscal_year_parameters() a no-op (deprecated) since the conversion is now done on-the-fly

This ensures:

  • param("2026") returns the April 30, 2026 value (fiscal year 2026/27)
  • Specific date queries like param("2026-04-05") are unchanged
  • Works for any future year without needing to extend a range

Test plan

  • Run new fiscal year parameter tests
  • Verify existing tests pass
  • CI passes

🤖 Generated with Claude Code

Previously, the fiscal year conversion in convert_to_fiscal_year_parameters()
only covered years 2015-2025 (range(2015, 2026)). When querying parameters
for year 2026 or later, the system fell back to January 1 as the reference
date instead of April 30.

This caused policies that change on April 6 (UK fiscal year start) to not
be reflected in annual simulations. For example, the two-child limit repeal
on April 6, 2026 would show as limit=2 for 2026 simulations instead of
limit=infinity.

The fix:
1. Add convert_instant_to_fiscal_year() function that converts year-only
   and January 1 queries to April 30 of that year
2. Override get_parameters_at_instant() in CountryTaxBenefitSystem to
   apply this conversion on-the-fly
3. Make convert_to_fiscal_year_parameters() a no-op (deprecated) since
   the conversion is now done on-the-fly

This ensures:
- param("2026") returns the April 30, 2026 value (fiscal year 2026/27)
- Specific date queries like param("2026-04-05") are unchanged
- Works for any future year without needing to extend a range

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@MaxGhenis MaxGhenis changed the title Fix fiscal year parameter handling for UK simulations [Draft] Fix fiscal year parameter handling (on-the-fly approach - needs work) Dec 3, 2025
@MaxGhenis MaxGhenis marked this pull request as draft December 3, 2025 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants