PolicyEngine / PolicyEngine/policyengine-uk

Explore on-the-fly fiscal year parameter conversion

Open
#1,436 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
50
Forks
33
Avg merge
20h 58m
Merged PRs (30d)
14

Description

Context

PR #1435 fixes the fiscal year parameter conversion range by extending it from 2015-2025 to 2015-2040. This is a simple fix but requires pre-computing values for all 26 years at startup.

Proposed Enhancement

Explore converting fiscal year parameters on-the-fly rather than pre-computing them. This would:

  1. Remove the year range limit entirely - No need to extend the range for future projections
  2. Potentially improve startup time - No pre-computation needed for all years
  3. Simplify the code - Just convert January 1 queries to April 30 dynamically

Attempted Implementation

An initial attempt at this approach was made in PR #1434 by:

  • Adding convert_instant_to_fiscal_year() function
  • Overriding get_parameters_at_instant() in CountryTaxBenefitSystem
  • Making convert_to_fiscal_year_parameters() a no-op

However, this broke 24 existing tests because it changed parameter lookup behavior for ALL dates, not just annual queries.

PR #1434 contains the work-in-progress on-the-fly implementation - it can be used as a starting point.

Investigation Needed

  • Understand why the on-the-fly approach broke existing tests
  • Determine if on-the-fly conversion can be safely implemented
  • Consider performance implications
  • Evaluate backward compatibility concerns

References

  • PR #1435: Simple fix (extend range to 2040) ✅
  • PR #1434: On-the-fly approach (work-in-progress implementation for this issue)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the on-the-fly implementation in PR #1434 and inspect convert_instant_to_fiscal_year(), CountryTaxBenefitSystem.get_parameters_at_instant(), and convert_to_fiscal_year_parameters(). Run the existing test suite to reproduce the 24 failures, then determine whether conversion can remove the year range without changing non-annual parameter lookups; done means preserving existing behavior while supporting future fiscal years.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.