Skip to content
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

[FYST-1882] Update ID disability logic to only ask questions about filers who fall within 62-65 age range #5664

Merged
merged 12 commits into from
Mar 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions app/forms/state_file/id_disability_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,24 @@ class IdDisabilityForm < QuestionsForm
set_attributes_for :intake, :primary_disabled, :spouse_disabled

attr_accessor :mfj_disability
validates_presence_of :mfj_disability, if: -> { intake.filing_status_mfj?}
validates :primary_disabled, inclusion: { in: %w[yes no], message: :blank }, unless: -> { intake.filing_status_mfj? }
validates_presence_of :mfj_disability, if: -> { intake.filing_status_mfj? && intake.all_filers_between_62_and_65_years_old? }
validates :primary_disabled, inclusion: { in: %w[yes no], message: :blank }, if: -> { should_check_primary_disabled? }
validates :spouse_disabled, inclusion: { in: %w[yes no], message: :blank }, if: -> { should_check_spouse_disabled? }

def save
def should_check_primary_disabled?
if intake.filing_status_mfj?
!intake.all_filers_between_62_and_65_years_old? && intake.primary_between_62_and_65_years_old?
else
intake.primary_between_62_and_65_years_old?
end
end

def should_check_spouse_disabled?
intake.filing_status_mfj? && !intake.all_filers_between_62_and_65_years_old? && intake.spouse_between_62_and_65_years_old?
end
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i thought about moving these to the intake level, but feel like the names could be a bit misleading/confusing and the use case for these methods are really limited to this presence check.


def save
if intake.filing_status_mfj? && intake.all_filers_between_62_and_65_years_old?
case mfj_disability
when "primary"
@intake.update(primary_disabled: "yes", spouse_disabled: "no")
Expand All @@ -28,12 +41,12 @@ def save
private

def clean_up_followups
primary_followups = @intake.filer_1099_rs(:primary).map(&:state_specific_followup).compact
if primary_disabled == "no" || %w[spouse none].include?(mfj_disability)
primary_followups = @intake.filer_1099_rs(:primary).map(&:state_specific_followup).compact
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 this is more for my own understanding, but why do you delete the followups?

Copy link
Contributor Author

@arinchoi03 arinchoi03 Mar 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is due to:
https://github.com/codeforamerica/vita-min/blob/main/app/lib/efile/id/id39_r_calculator.rb#L87-L95

If the user goes through the flow first for the 62-65 year old filer, answer "yes" for disability, then answer "eligible_income_source_yes?" for that eligible 1099R, but then comes back via the review page & then answers "no" for disabled. Without the clean up, we will add up all the income for 1099Rs, even though the filer may have changed their answer to no for disability.

I suppose another way to handle it is to:

  1. keep the followup (whatever the answer was -- eligible/not eligible)
  2. check if the filer is associated with a particular filer who is either disabled/over 65(senior) in the calculation

Pros of current approach:

  • we really don't need that eligible_income_source_yes? information unless the filer is disabled
  • it feels like a waste/unnecessary data to have records of if the 62-65 filer is not disabled in the first place. The followup only has that one piece of information (eligible_income_source)

Cons of current approach:

  • the calculations may benefit from double checking whether the 1099R comes from a disabled filer anyway?
    • to that end, i rather now think we should use eligible_1099rs instead of state_file_1099rs for calculations, which takes into account whether the person_qualifies? or not even though we may keep the cleanup logic

Another unrelated refactor I'm looking at is using eligible_1099rs method in the self.show? method of RetirementIncomeSubtractionController

This way we can clean up the unnecessary data and clear up the logic in the calculations to mirror what's happening in the flow. What do you think? Happy to create a chore & clean up

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quick followup here #5665 while my mind is on it but no need to get it through review or anything, unless we feel like we have loads of time to run through this quickly before release.

primary_followups.each(&:destroy)
end

if @intake.filing_status_mfj? && %w[primary none].include?(mfj_disability)
if @intake.filing_status_mfj? && (spouse_disabled == "no" || %w[primary none].include?(mfj_disability))
spouse_followups = @intake.filer_1099_rs(:spouse).map(&:state_specific_followup).compact
spouse_followups.each(&:destroy)
end
Expand Down
26 changes: 23 additions & 3 deletions app/models/state_file_id_intake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,32 @@ def has_filing_requirement?
end

def has_filer_between_62_and_65_years_old?
if filing_status_mfj?
primary_between_62_and_65_years_old? || spouse_between_62_and_65_years_old?
else
primary_between_62_and_65_years_old?
end
end

def all_filers_between_62_and_65_years_old?
if filing_status_mfj?
primary_between_62_and_65_years_old? && spouse_between_62_and_65_years_old?
else
primary_between_62_and_65_years_old?
end
end

def primary_between_62_and_65_years_old?
primary_age = calculate_age(primary_birth_date, inclusive_of_jan_1: true)
if filing_status_mfj? && spouse_birth_date.present?
primary_age >= 62 && primary_age < 65
end

def spouse_between_62_and_65_years_old?
if spouse_birth_date.present?
spouse_age = calculate_age(spouse_birth_date, inclusive_of_jan_1: true)
(primary_age >= 62 && primary_age < 65) || (spouse_age >= 62 && spouse_age < 65)
spouse_age >= 62 && spouse_age < 65
else
primary_age >= 62 && primary_age < 65
false
end
end

Expand Down
11 changes: 8 additions & 3 deletions app/views/state_file/questions/id_disability/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,23 @@

<%= form_with model: @form, url: { action: :update }, local: true, method: "put", builder: VitaMinFormBuilder do |f| %>
<div class="white-group">
<% if current_intake.filing_status_mfj? %>
<%= f.cfa_radio_set(:mfj_disability, label_text: t(".question_spouse"), collection: [
<% if current_intake.filing_status_mfj? && current_intake.all_filers_between_62_and_65_years_old? %>
<%= f.cfa_radio_set(:mfj_disability, label_text: t(".question_both"), collection: [
{ value: "primary", label: t(".yes_me") },
{ value: "spouse", label: t(".yes_spouse") },
{ value: "both", label: t(".yes_both") },
{ value: "none", label: t(".no_neither") }
]) %>
<% else %>
<% elsif current_intake.primary_between_62_and_65_years_old? %>
<%= f.cfa_radio_set(:primary_disabled, label_text: t(".question"), collection: [
{ value: "yes", label: t("general.affirmative") },
{ value: "no", label: t("general.negative") }
]) %>
<% elsif current_intake.filing_status_mfj? && current_intake.spouse_between_62_and_65_years_old? %>
<%= f.cfa_radio_set(:spouse_disabled, label_text: t(".question_spouse"), collection: [
{ value: "yes", label: t("general.affirmative") },
{ value: "no", label: t("general.negative") }
]) %>
<% end %>
</div>

Expand Down
3 changes: 2 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2937,7 +2937,8 @@ en:
help_title: What is classified as disabled?
no_neither: No, neither of us is
question: Do you meet the qualifications to be classified as disabled?
question_spouse: Do you or your spouse meet the qualifications to be classified as disabled?
question_both: Do you or your spouse meet the qualifications to be classified as disabled?
question_spouse: Does your spouse meet the qualification to be classified as disabled?
title: You might be eligible for Idaho Retirement Income Deduction.
yes_both: Yes, we both are
yes_me: Yes, I am
Expand Down
3 changes: 2 additions & 1 deletion config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2903,7 +2903,8 @@ es:
help_title: "¿Qué se clasifica como discapacidad?"
no_neither: No, ninguno de los dos lo está
question: "¿Estás total y permanentemente discapacitado?"
question_spouse: "¿Tú o tu cónyuge están total y permanentemente discapacitados?"
question_both: "¿Tú o tu cónyuge están total y permanentemente discapacitados?"
question_spouse: "¿Tú cónyuge cumple con los requisitos para ser clasificados como discapacitado?"
title: "¡Podrías ser elegible para una deducción por ingresos de jubilación de Idaho!."
yes_both: Sí, ambos lo estamos
yes_me: Sí lo estoy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,69 @@

describe "#edit" do
render_views

let!(:state_file1099_r) { create(:state_file1099_r, intake: intake, taxable_amount: 25) }
let(:between_dob) { Date.new((MultiTenantService.statefile.end_of_current_tax_year.year - 63), 1, 1) }
let(:not_between_dob) { Date.new((MultiTenantService.statefile.end_of_current_tax_year.year - 60), 1, 1) }

it 'succeeds' do
get :edit
expect(response).to be_successful
end

context "single" do
context "primary is within 62-65 years old" do
before do
intake.update(primary_birth_date: between_dob)
end

it "primary_disabled questions" do
get :edit, params: {}
expect(response).to render_template :edit
expect(response.body).to include(I18n.t('state_file.questions.id_disability.edit.question'))
end
end
end

context "mfj" do
let(:intake) { create :state_file_id_intake, :with_spouse, filing_status: :married_filing_jointly }
context "both filers are within 62-65 years old" do
before do
intake.update(primary_birth_date: between_dob)
intake.update(spouse_birth_date: between_dob)
end
it "shows mfj disability questions for both filers" do
get :edit, params: {}
expect(response).to render_template :edit
expect(response.body).to include(I18n.t('state_file.questions.id_disability.edit.question_both'))
end
end

context "only primary is within 62-65 years old" do
before do
intake.update(primary_birth_date: between_dob)
intake.update(spouse_birth_date: not_between_dob)
end

it "primary_disabled questions" do
get :edit, params: {}
expect(response).to render_template :edit
expect(response.body).to include(I18n.t('state_file.questions.id_disability.edit.question'))
end
end

context "only spouse is within 62-65 years old" do
before do
intake.update(primary_birth_date: not_between_dob)
intake.update(spouse_birth_date: between_dob)
end
it "spouse_disabled questions" do
get :edit, params: {}
expect(response).to render_template :edit
expect(response.body).to include(I18n.t('state_file.questions.id_disability.edit.question_spouse'))
end
end
end
end

describe ".show?" do
Expand Down
Loading
Loading