|
| 1 | +from policyengine_us.model_api import * |
| 2 | +from policyengine_core.periods import period as period_ |
| 3 | + |
| 4 | + |
| 5 | +def create_nyc_school_tax_credit_with_phase_out() -> Reform: |
| 6 | + class nyc_school_tax_credit_phase_out(Variable): |
| 7 | + value_type = float |
| 8 | + unit = USD |
| 9 | + entity = TaxUnit |
| 10 | + label = "NYC School Tax Credit Phase Out" |
| 11 | + definition_period = YEAR |
| 12 | + defined_for = "in_nyc" |
| 13 | + reference = "https://www.nysenate.gov/legislation/bills/2025/S2238" |
| 14 | + |
| 15 | + def formula(tax_unit, period, parameters): |
| 16 | + agi = tax_unit("ny_agi", period) |
| 17 | + filing_status = tax_unit("filing_status", period) |
| 18 | + joint = filing_status == filing_status.possible_values.JOINT |
| 19 | + surviving_spouse = ( |
| 20 | + filing_status == filing_status.possible_values.SURVIVING_SPOUSE |
| 21 | + ) |
| 22 | + joint_filers = joint | surviving_spouse |
| 23 | + p = parameters(period).gov.contrib.local.nyc.stc.phase_out.rate |
| 24 | + return where( |
| 25 | + joint_filers, |
| 26 | + p.joint_and_surviving_spouse.calc(agi), |
| 27 | + p.other.calc(agi), |
| 28 | + ) |
| 29 | + |
| 30 | + class nyc_school_tax_credit(Variable): |
| 31 | + value_type = float |
| 32 | + entity = TaxUnit |
| 33 | + label = "NYC School Tax Credit" |
| 34 | + unit = USD |
| 35 | + definition_period = YEAR |
| 36 | + defined_for = "in_nyc" |
| 37 | + reference = "https://www.nysenate.gov/legislation/bills/2025/S2238" |
| 38 | + |
| 39 | + def formula(tax_unit, period, parameters): |
| 40 | + base_amount = add( |
| 41 | + tax_unit, |
| 42 | + period, |
| 43 | + [ |
| 44 | + "nyc_school_tax_credit_fixed_amount", |
| 45 | + "nyc_school_tax_credit_rate_reduction_amount", |
| 46 | + ], |
| 47 | + ) |
| 48 | + phase_out = tax_unit("nyc_school_tax_credit_phase_out", period) |
| 49 | + return max_(0, base_amount - phase_out) |
| 50 | + |
| 51 | + class reform(Reform): |
| 52 | + def apply(self): |
| 53 | + self.update_variable(nyc_school_tax_credit_phase_out) |
| 54 | + self.update_variable(nyc_school_tax_credit) |
| 55 | + |
| 56 | + return reform |
| 57 | + |
| 58 | + |
| 59 | +def create_nyc_school_tax_credit_with_phase_out_reform( |
| 60 | + parameters, period, bypass: bool = False |
| 61 | +): |
| 62 | + if bypass: |
| 63 | + return create_nyc_school_tax_credit_with_phase_out() |
| 64 | + |
| 65 | + p = parameters.gov.contrib.local.nyc.stc.phase_out |
| 66 | + |
| 67 | + reform_active = False |
| 68 | + current_period = period_(period) |
| 69 | + |
| 70 | + for i in range(5): |
| 71 | + if p(current_period).in_effect: |
| 72 | + reform_active = True |
| 73 | + break |
| 74 | + current_period = current_period.offset(1, "year") |
| 75 | + |
| 76 | + if reform_active: |
| 77 | + return create_nyc_school_tax_credit_with_phase_out() |
| 78 | + else: |
| 79 | + return None |
| 80 | + |
| 81 | + |
| 82 | +nyc_school_tax_credit_with_phase_out = ( |
| 83 | + create_nyc_school_tax_credit_with_phase_out_reform(None, None, bypass=True) |
| 84 | +) |
0 commit comments