-
Notifications
You must be signed in to change notification settings - Fork 201
Add NY tax calculation for filters with AGI above $25 million #6914
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
DTrim99
wants to merge
9
commits into
PolicyEngine:main
Choose a base branch
from
DTrim99:DTrim99/issue6872
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1abcf22
Add NY tax calculation for filters with AGI above $25 million
DTrim99 10ec7c1
Fix NY flat tax rate for AGI above $25 million
DTrim99 4e5fee7
Update uv.lock
DTrim99 469c511
Merge branch 'master' into DTrim99/issue6872
DTrim99 da4c5aa
Fix float32 precision issue for $25M AGI threshold
DTrim99 7685d42
Merge branch 'master' into DTrim99/issue6872
DTrim99 76b318e
Add NY tax calculation for filters with AGI above $25 million
DTrim99 5c53ba9
Add NY tax calculation for filters with AGI above $25 million
DTrim99 9d4fe7d
Merge branch 'main' into DTrim99/issue6872
DTrim99 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| - bump: minor | ||
| changes: | ||
| added: | ||
| - Add NY tax calculation for filters with AGI above $25 million integration test. |
34 changes: 34 additions & 0 deletions
34
policyengine_us/tests/policy/baseline/gov/states/ny/tax/income/integration.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| - name: 36828-NY.yaml | ||
| absolute_error_margin: 2 | ||
| period: 2024 | ||
| input: | ||
| people: | ||
| person1: | ||
| age: 40 | ||
| employment_income: 31_920_562 | ||
| ssi: 0 | ||
| wic: 0 | ||
| head_start: 0 | ||
| early_head_start: 0 | ||
| commodity_supplemental_food_program: 0 | ||
| taxable_interest_income: 1_519_734 | ||
| is_tax_unit_head: true | ||
| tax_units: | ||
| tax_unit: | ||
| members: [person1] | ||
| premium_tax_credit: 0 | ||
| local_income_tax: 0 | ||
| state_sales_tax: 0 | ||
| spm_units: | ||
| spm_unit: | ||
| members: [person1] | ||
| snap: 0 | ||
| tanf: 0 | ||
| free_school_meals: 0 | ||
| reduced_price_school_meals: 0 | ||
| households: | ||
| household: | ||
| members: [person1] | ||
| state_fips: 36 | ||
| output: | ||
| ny_income_tax: 3_644_120 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,18 @@ | ||
| from policyengine_us.model_api import * | ||
| from policyengine_core.taxscales import MarginalRateTaxScale | ||
| import numpy as np | ||
|
|
||
|
|
||
| def get_last_finite_threshold(scale): | ||
| """Get the last non-infinity threshold from a tax scale. | ||
|
|
||
| For NY tax scales, the last threshold may be infinity for certain years. | ||
| This function returns the last finite threshold value instead. | ||
| """ | ||
| thresholds = scale.thresholds | ||
| if np.isinf(thresholds[-1]): | ||
| return thresholds[-2] | ||
| return thresholds[-1] | ||
|
|
||
|
|
||
| class ny_supplemental_tax(Variable): | ||
|
|
@@ -53,20 +66,18 @@ def formula(tax_unit, period, parameters): | |
| applicable_amount / p.phase_in_length, | ||
| ) | ||
|
|
||
| # edge case for high agi | ||
| agi_limit = select( | ||
| # For AGI above the high threshold, apply flat top rate to all income | ||
| # Get the last finite threshold from each scale (handles infinity in 2022+) | ||
| high_agi_threshold = select( | ||
| in_each_status, | ||
| [ | ||
| single.thresholds[-1], | ||
| joint.thresholds[-1], | ||
| hoh.thresholds[-1], | ||
| surviving_spouse.thresholds[-1], | ||
| separate.thresholds[-1], | ||
| ], | ||
| [get_last_finite_threshold(scale) for scale in scales], | ||
| ) | ||
| # Create array for marginal_rates lookup | ||
| # Use +100 for float32 precision at $25M threshold | ||
| high_agi_lookup = ny_agi * 0 + high_agi_threshold + 100 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not +1 to account for the threshold. Not sure why we need a $100 buffer |
||
| high_agi_rate = select( | ||
| in_each_status, | ||
| [scale.marginal_rates(agi_limit + 1) for scale in scales], | ||
| [scale.marginal_rates(high_agi_lookup) for scale in scales], | ||
| ) | ||
|
|
||
| supplemental_tax_high_agi = ( | ||
|
|
@@ -105,13 +116,13 @@ def formula(tax_unit, period, parameters): | |
| ) | ||
|
|
||
| return where( | ||
| ny_agi > agi_limit, | ||
| ny_agi > high_agi_threshold, | ||
| supplemental_tax_high_agi, | ||
| supplemental_tax_general, | ||
| ) | ||
|
|
||
| return where( | ||
| ny_agi > agi_limit, | ||
| ny_agi > high_agi_threshold, | ||
| supplemental_tax_high_agi, | ||
| 0, | ||
| ) | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need a separate function for this? Can we not just do it in the formula? I assume we wont reuse this?