From 5f107e5df96d36faf442e286f5cd45b9fb0c5964 Mon Sep 17 00:00:00 2001 From: Arin Choi Date: Fri, 28 Feb 2025 14:42:54 -0800 Subject: [PATCH 1/9] Only show mfj_disability questions if mfj & all filers are 62-65; show spouse-specific screen if only spouse 62-65 --- app/forms/state_file/id_disability_form.rb | 23 +- app/models/state_file_id_intake.rb | 26 ++- .../questions/id_disability/edit.html.erb | 9 +- config/locales/en.yml | 1 + config/locales/es.yml | 1 + .../state_file/id_disability_form_spec.rb | 69 +++++- spec/models/state_file_id_intake_spec.rb | 198 +++++++++++++++++- 7 files changed, 297 insertions(+), 30 deletions(-) diff --git a/app/forms/state_file/id_disability_form.rb b/app/forms/state_file/id_disability_form.rb index 42a1abe953..fa3cabf3f8 100644 --- a/app/forms/state_file/id_disability_form.rb +++ b/app/forms/state_file/id_disability_form.rb @@ -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 + + 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") @@ -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 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 diff --git a/app/models/state_file_id_intake.rb b/app/models/state_file_id_intake.rb index c26609b4b3..009a0207fe 100644 --- a/app/models/state_file_id_intake.rb +++ b/app/models/state_file_id_intake.rb @@ -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 diff --git a/app/views/state_file/questions/id_disability/edit.html.erb b/app/views/state_file/questions/id_disability/edit.html.erb index 08946d0389..5bcb8d54a0 100644 --- a/app/views/state_file/questions/id_disability/edit.html.erb +++ b/app/views/state_file/questions/id_disability/edit.html.erb @@ -5,18 +5,23 @@ <%= form_with model: @form, url: { action: :update }, local: true, method: "put", builder: VitaMinFormBuilder do |f| %>
- <% if current_intake.filing_status_mfj? %> + <% 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_spouse"), 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_mfs? && current_intake.spouse_between_62_and_65_years_old? %> + <%= f.cfa_radio_set(:spouse_disabled, label_text: t(".question_spouse_only"), collection: [ + { value: "yes", label: t("general.affirmative") }, + { value: "no", label: t("general.negative") } + ]) %> <% end %>
diff --git a/config/locales/en.yml b/config/locales/en.yml index ab52934ae2..c39928cf69 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2937,6 +2937,7 @@ en: 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_spouse_only: 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 diff --git a/config/locales/es.yml b/config/locales/es.yml index 274a620a08..24c029eaa7 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -2903,6 +2903,7 @@ es: 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_spouse_only: "¿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 diff --git a/spec/forms/state_file/id_disability_form_spec.rb b/spec/forms/state_file/id_disability_form_spec.rb index 4adc3c3d31..2348f1dea1 100644 --- a/spec/forms/state_file/id_disability_form_spec.rb +++ b/spec/forms/state_file/id_disability_form_spec.rb @@ -3,27 +3,71 @@ RSpec.describe StateFile::IdDisabilityForm do let(:intake) { create :state_file_id_intake } let(:form) { described_class.new(intake, params) } + let(:senior_dob) { Date.new((MultiTenantService.statefile.end_of_current_tax_year.year - 65), 1, 1) } + let(:not_senior_dob) { Date.new((MultiTenantService.statefile.end_of_current_tax_year.year - 63), 1, 1) } + describe "#valid?" do + let(:primary_birth_date) { not_senior_dob } + let(:spouse_birth_date) { not_senior_dob } + + before do + intake.update(primary_birth_date: primary_birth_date) + intake.update(spouse_birth_date: spouse_birth_date) + end + context "when filing status is MFJ" do before do allow(intake).to receive(:filing_status_mfj?).and_return true end - context "when mfj_disability is blank" do - let(:params) { { mfj_disability: "" } } + context "when both filers are between 62-65" do + context "when mfj_disability is blank" do + let(:params) { { mfj_disability: "" } } - it "is invalid and attaches the correct error" do - expect(form).not_to be_valid - expect(form.errors[:mfj_disability]).to include "Can't be blank." + it "is invalid and attaches the correct error" do + expect(form).not_to be_valid + expect(form.errors[:mfj_disability]).to include "Can't be blank." + end + end + + context "when mfj_disability is present" do + let(:params) { { mfj_disability: "primary" } } + + it "is valid" do + expect(form).to be_valid + end end end - context "when mfj_disability is present" do - let(:params) { { mfj_disability: "primary" } } + context "when only primary is between 62-65" do + let(:primary_birth_date) { not_senior_dob } + let(:spouse_birth_date) { senior_dob } - it "is valid" do - expect(form).to be_valid + context "when primary_disabled is blank" do + let(:params) { { primary_disabled: "" } } + + it "is invalid and attaches the correct error" do + expect(form).not_to be_valid + expect(form.errors[:primary_disabled]).to include "Can't be blank." + end + end + + context "when primary_disabled is not yes/no" do + let(:params) { { primary_disabled: "invalid" } } + + it "is invalid" do + expect(form).not_to be_valid + expect(form.errors[:primary_disabled]).to include "Can't be blank." + end + end + + context "when primary_disabled is valid" do + let(:params) { { primary_disabled: "yes" } } + + it "is valid" do + expect(form).to be_valid + end end end end @@ -75,7 +119,12 @@ recipient_ssn: "600000030" end - context "when filing status is MFJ" do + context "when filing status is MFJ and both are between 62-65" do + before do + intake.update(primary_birth_date: not_senior_dob) + intake.update(spouse_birth_date: not_senior_dob) + end + context "when mfj_disability is 'me'" do let(:params) { { mfj_disability: "primary" } } diff --git a/spec/models/state_file_id_intake_spec.rb b/spec/models/state_file_id_intake_spec.rb index 129dc7b4c6..8fdea904b7 100644 --- a/spec/models/state_file_id_intake_spec.rb +++ b/spec/models/state_file_id_intake_spec.rb @@ -197,15 +197,11 @@ end end - describe "#has_filer_between_62_and_65_years_old?" do + describe "#primary_between_62_and_65_years_old?" do let(:intake) { create(:state_file_id_intake) } - context "with a 1099R but zero taxable amount" do - let!(:state_file1099_r) { create(:state_file1099_r, intake: intake, taxable_amount: 0) } - - it "is false" do - expect(intake.has_filer_between_62_and_65_years_old?).to eq false - end + before do + intake.primary_birth_date = Date.new(MultiTenantService.statefile.current_tax_year - 60, 1, 1) end context "when filer is under 62" do @@ -214,7 +210,7 @@ end it "is false" do - expect(intake.has_filer_between_62_and_65_years_old?).to eq false + expect(intake.primary_between_62_and_65_years_old?).to eq false end end @@ -224,7 +220,7 @@ end it "is true" do - expect(intake.has_filer_between_62_and_65_years_old?).to eq true + expect(intake.primary_between_62_and_65_years_old?).to eq true end end @@ -234,7 +230,189 @@ end it "is false" do - expect(intake.has_filer_between_62_and_65_years_old?).to eq false + expect(intake.primary_between_62_and_65_years_old?).to eq false + end + end + end + + describe "#spouse_between_62_and_65_years_old?" do + let(:intake) { create(:state_file_id_intake, :with_spouse) } + + before do + intake.spouse_birth_date = Date.new(MultiTenantService.statefile.current_tax_year - 60, 1, 1) + end + + context "when filer is under 62" do + before do + intake.spouse_birth_date = Date.new(MultiTenantService.statefile.current_tax_year - 60, 1, 1) + end + + it "is false" do + expect(intake.spouse_between_62_and_65_years_old?).to eq false + end + end + + context "when filer is within the age range qualifications" do + before do + intake.spouse_birth_date = Date.new(MultiTenantService.statefile.current_tax_year - 62, 1, 1) + end + + it "is true" do + expect(intake.spouse_between_62_and_65_years_old?).to eq true + end + end + end + + describe "#all_filers_bewteen_62_and_65_years_old?" do + let(:primary_between) { false } + let(:spouse_between) { false } + + before do + allow(intake).to receive(:primary_between_62_and_65_years_old?).and_return(primary_between) + allow(intake).to receive(:spouse_between_62_and_65_years_old?).and_return(spouse_between) + end + + context "single" do + let(:intake) { create(:state_file_id_intake) } + + context "primary between 62 and 65 years old" do + let(:primary_between) { true } + it "is true" do + expect(intake.all_filers_between_62_and_65_years_old?).to eq true + end + end + + context "spouse between 62 and 65 years old" do + let(:spouse_between) { true } + it "is true" do + expect(intake.all_filers_between_62_and_65_years_old?).to eq false + end + end + + context "both between 62 and 65 years old" do + let(:primary_between) { true } + let(:spouse_between) { true } + + it "is true" do + expect(intake.all_filers_between_62_and_65_years_old?).to eq true + end + end + + context "neither" do + it "is true" do + expect(intake.all_filers_between_62_and_65_years_old?).to eq false + end + end + end + + context "mfj" do + let(:intake) { create(:state_file_id_intake, filing_status: :married_filing_jointly) } + + context "primary between 62 and 65 years old" do + let(:primary_between) { true } + it "is true" do + expect(intake.all_filers_between_62_and_65_years_old?).to eq false + end + end + + context "spouse between 62 and 65 years old" do + let(:spouse_between) { true } + it "is true" do + expect(intake.all_filers_between_62_and_65_years_old?).to eq false + end + end + + context "both between 62 and 65 years old" do + let(:primary_between) { true } + let(:spouse_between) { true } + + it "is true" do + expect(intake.all_filers_between_62_and_65_years_old?).to eq true + end + end + + context "neither" do + it "is true" do + expect(intake.all_filers_between_62_and_65_years_old?).to eq false + end + end + end + end + + describe "#has_filer_between_62_and_65_years_old?" do + let(:primary_between) { false } + let(:spouse_between) { false } + + before do + allow(intake).to receive(:primary_between_62_and_65_years_old?).and_return(primary_between) + allow(intake).to receive(:spouse_between_62_and_65_years_old?).and_return(spouse_between) + end + + context "single" do + let(:intake) { create(:state_file_id_intake) } + + context "primary between 62 and 65 years old" do + let(:primary_between) { true } + it "is true" do + expect(intake.has_filer_between_62_and_65_years_old?).to eq true + end + end + + context "spouse between 62 and 65 years old" do + let(:spouse_between) { true } + it "is true" do + expect(intake.has_filer_between_62_and_65_years_old?).to eq false + end + end + + context "both between 62 and 65 years old" do + let(:primary_between) { true } + let(:spouse_between) { true } + + it "is true" do + expect(intake.has_filer_between_62_and_65_years_old?).to eq true + end + end + + context "neither" do + it "is true" do + expect(intake.has_filer_between_62_and_65_years_old?).to eq false + end + end + end + + context "mfj" do + let(:intake) { create(:state_file_id_intake, filing_status: :married_filing_jointly) } + + context "primary between 62 and 65 years old" do + let(:primary_between) { true } + it "is true" do + expect(intake.has_filer_between_62_and_65_years_old?).to eq true + end + end + + context "spouse between 62 and 65 years old" do + let(:primary_between) { false } + let(:spouse_between) { true } + + it "is true" do + expect(intake.has_filer_between_62_and_65_years_old?).to eq true + end + end + + context "both between 62 and 65 years old" do + let(:primary_between) { true } + let(:spouse_between) { true } + + it "is true" do + expect(intake.has_filer_between_62_and_65_years_old?).to eq true + end + end + + context "neither" do + it "is true" do + expect(intake.has_filer_between_62_and_65_years_old?).to eq false + end end end end From 5658d84b5b6ebdb21cda14e1ccf8b5d901d7eb48 Mon Sep 17 00:00:00 2001 From: Arin Choi Date: Fri, 28 Feb 2025 15:14:06 -0800 Subject: [PATCH 2/9] Fix typo --- app/views/state_file/questions/id_disability/edit.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/state_file/questions/id_disability/edit.html.erb b/app/views/state_file/questions/id_disability/edit.html.erb index 5bcb8d54a0..2fcff580e9 100644 --- a/app/views/state_file/questions/id_disability/edit.html.erb +++ b/app/views/state_file/questions/id_disability/edit.html.erb @@ -17,7 +17,7 @@ { value: "yes", label: t("general.affirmative") }, { value: "no", label: t("general.negative") } ]) %> - <% elsif current_intake.filing_status_mfs? && current_intake.spouse_between_62_and_65_years_old? %> + <% 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_only"), collection: [ { value: "yes", label: t("general.affirmative") }, { value: "no", label: t("general.negative") } From 680659e84ee94b60141c40308b8fc83177d7156e Mon Sep 17 00:00:00 2001 From: Arin Choi Date: Fri, 28 Feb 2025 15:14:10 -0800 Subject: [PATCH 3/9] Add specs for controller conditionally showing different text --- .../id_disability_controller_spec.rb | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/spec/controllers/state_file/questions/id_disability_controller_spec.rb b/spec/controllers/state_file/questions/id_disability_controller_spec.rb index 6f33342db5..e0490eb02f 100644 --- a/spec/controllers/state_file/questions/id_disability_controller_spec.rb +++ b/spec/controllers/state_file/questions/id_disability_controller_spec.rb @@ -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_spouse')) + 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_only')) + end + end + end end describe ".show?" do From b570cd9c1209dbeeb574c49043bf2d8e69dcacc2 Mon Sep 17 00:00:00 2001 From: Arin Choi Date: Fri, 28 Feb 2025 15:18:38 -0800 Subject: [PATCH 4/9] Update yaml keys --- app/views/state_file/questions/id_disability/edit.html.erb | 4 ++-- config/locales/en.yml | 4 ++-- config/locales/es.yml | 4 ++-- .../state_file/questions/id_disability_controller_spec.rb | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/views/state_file/questions/id_disability/edit.html.erb b/app/views/state_file/questions/id_disability/edit.html.erb index 2fcff580e9..73d58e1ce0 100644 --- a/app/views/state_file/questions/id_disability/edit.html.erb +++ b/app/views/state_file/questions/id_disability/edit.html.erb @@ -6,7 +6,7 @@ <%= form_with model: @form, url: { action: :update }, local: true, method: "put", builder: VitaMinFormBuilder do |f| %>
<% 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_spouse"), collection: [ + <%= 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") }, @@ -18,7 +18,7 @@ { 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_only"), collection: [ + <%= f.cfa_radio_set(:spouse_disabled, label_text: t(".question_spouse"), collection: [ { value: "yes", label: t("general.affirmative") }, { value: "no", label: t("general.negative") } ]) %> diff --git a/config/locales/en.yml b/config/locales/en.yml index c39928cf69..f7c4ff2a27 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2936,8 +2936,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_spouse_only: Does your spouse meet the qualification 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 diff --git a/config/locales/es.yml b/config/locales/es.yml index 24c029eaa7..99192caa14 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -2902,8 +2902,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_spouse_only: "¿Tú cónyuge cumple con los requisitos para ser clasificados como discapacitado?" + 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 diff --git a/spec/controllers/state_file/questions/id_disability_controller_spec.rb b/spec/controllers/state_file/questions/id_disability_controller_spec.rb index e0490eb02f..c9921607e2 100644 --- a/spec/controllers/state_file/questions/id_disability_controller_spec.rb +++ b/spec/controllers/state_file/questions/id_disability_controller_spec.rb @@ -44,7 +44,7 @@ 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_spouse')) + expect(response.body).to include(I18n.t('state_file.questions.id_disability.edit.question_both')) end end @@ -69,7 +69,7 @@ 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_only')) + expect(response.body).to include(I18n.t('state_file.questions.id_disability.edit.question_spouse')) end end end From 10cc7acfd3f66970cc629d6b1aaad6cc8df075a3 Mon Sep 17 00:00:00 2001 From: Arin Choi Date: Fri, 28 Feb 2025 15:46:32 -0800 Subject: [PATCH 5/9] Make sure spouse followup gets deleted when mfj & spouse_disabled = no --- .../state_file/id_disability_form_spec.rb | 165 ++++++++++++------ 1 file changed, 110 insertions(+), 55 deletions(-) diff --git a/spec/forms/state_file/id_disability_form_spec.rb b/spec/forms/state_file/id_disability_form_spec.rb index 2348f1dea1..8f707d08a5 100644 --- a/spec/forms/state_file/id_disability_form_spec.rb +++ b/spec/forms/state_file/id_disability_form_spec.rb @@ -119,94 +119,149 @@ recipient_ssn: "600000030" end - context "when filing status is MFJ and both are between 62-65" do - before do - intake.update(primary_birth_date: not_senior_dob) - intake.update(spouse_birth_date: not_senior_dob) - end + context "when filing status is MFJ" do + context "when both filers are 62-65" do + before do + intake.update(primary_birth_date: not_senior_dob) + intake.update(spouse_birth_date: not_senior_dob) + end - context "when mfj_disability is 'me'" do - let(:params) { { mfj_disability: "primary" } } + context "when mfj_disability is 'me'" do + let(:params) { { mfj_disability: "primary" } } - it "updates intake with primary_disabled: 'yes' and spouse_disabled: 'no'" do - form.save - intake.reload - expect(intake.primary_disabled).to eq "yes" - expect(intake.spouse_disabled).to eq "no" + it "updates intake with primary_disabled: 'yes' and spouse_disabled: 'no'" do + form.save + intake.reload + expect(intake.primary_disabled).to eq "yes" + expect(intake.spouse_disabled).to eq "no" + end + + context "when a followup already exists for spouse no longer disabled" do + let!(:followup) { create :state_file_id1099_r_followup, state_file1099_r: spouse_1099r, eligible_income_source: "yes" } + + it "updates intake using attributes_for" do + expect do + form.save + end.to change(StateFileId1099RFollowup, :count).by(-1) + end + end end - context "when a followup already exists for spouse no longer disabled" do - let!(:followup) { create :state_file_id1099_r_followup, state_file1099_r: spouse_1099r, eligible_income_source: "yes" } + context "when mfj_disability is 'spouse'" do + let(:params) { { mfj_disability: "spouse" } } - it "updates intake using attributes_for" do - expect do - form.save - end.to change(StateFileId1099RFollowup, :count).by(-1) + it "updates intake with primary_disabled: 'no' and spouse_disabled: 'yes'" do + form.save + intake.reload + expect(intake.primary_disabled).to eq "no" + expect(intake.spouse_disabled).to eq "yes" + end + + context "when a followup already exists and primary no longer disabled" do + let!(:followup) { create :state_file_id1099_r_followup, state_file1099_r: primary_1099r, eligible_income_source: "yes" } + + it "updates intake using attributes_for" do + expect do + form.save + end.to change(StateFileId1099RFollowup, :count).by(-1) + end end end - end - context "when mfj_disability is 'spouse'" do - let(:params) { { mfj_disability: "spouse" } } + context "when mfj_disability is 'both'" do + let(:params) { { mfj_disability: "both" } } - it "updates intake with primary_disabled: 'no' and spouse_disabled: 'yes'" do - form.save - intake.reload - expect(intake.primary_disabled).to eq "no" - expect(intake.spouse_disabled).to eq "yes" + it "updates intake with primary_disabled: 'yes' and spouse_disabled: 'yes'" do + form.save + intake.reload + expect(intake.primary_disabled).to eq "yes" + expect(intake.spouse_disabled).to eq "yes" + end + + context "when a followup already exists" do + let!(:followup) { create :state_file_id1099_r_followup, state_file1099_r: primary_1099r, eligible_income_source: "yes" } + let!(:spouse_followup) { create :state_file_id1099_r_followup, state_file1099_r: spouse_1099r, eligible_income_source: "yes" } + + it "does not change the number of followups (does not destroy existing followups)" do + expect do + form.save + end.to change(StateFileId1099RFollowup, :count).by(0) + end + end end - context "when a followup already exists and primary no longer disabled" do - let!(:followup) { create :state_file_id1099_r_followup, state_file1099_r: primary_1099r, eligible_income_source: "yes" } + context "when mfj_disability is 'none'" do + let(:params) { { mfj_disability: "none" } } - it "updates intake using attributes_for" do - expect do - form.save - end.to change(StateFileId1099RFollowup, :count).by(-1) + it "updates intake with primary_disabled: 'no' and spouse_disabled: 'no'" do + form.save + intake.reload + expect(intake.primary_disabled).to eq "no" + expect(intake.spouse_disabled).to eq "no" + end + + context "when a followup already exists" do + let!(:followup) { create :state_file_id1099_r_followup, state_file1099_r: primary_1099r, eligible_income_source: "yes" } + let!(:spouse_followup) { create :state_file_id1099_r_followup, state_file1099_r: spouse_1099r, eligible_income_source: "yes" } + + it "does not change the number of followups (does not destroy existing followups)" do + expect do + form.save + end.to change(StateFileId1099RFollowup, :count).by(-2) + end end end end - context "when mfj_disability is 'both'" do - let(:params) { { mfj_disability: "both" } } + context "when only primary is 62-65" do + before do + intake.update(primary_birth_date: not_senior_dob) + end + context "when primary_disabled is set" do + let(:params) { { primary_disabled: "yes" } } - it "updates intake with primary_disabled: 'yes' and spouse_disabled: 'yes'" do - form.save - intake.reload - expect(intake.primary_disabled).to eq "yes" - expect(intake.spouse_disabled).to eq "yes" + it "updates intake using attributes_for" do + expect(intake).to receive(:update).with(form.send(:attributes_for, :intake)) + form.save + end end - context "when a followup already exists" do + context "when a followup already exists and changes answer to 'no'" do let!(:followup) { create :state_file_id1099_r_followup, state_file1099_r: primary_1099r, eligible_income_source: "yes" } - let!(:spouse_followup) { create :state_file_id1099_r_followup, state_file1099_r: spouse_1099r, eligible_income_source: "yes" } + let(:params) { { primary_disabled: "no" } } - it "does not change the number of followups (does not destroy existing followups)" do + it "updates intake using attributes_for" do + expect(intake).to receive(:update).with(form.send(:attributes_for, :intake)) expect do form.save - end.to change(StateFileId1099RFollowup, :count).by(0) + end.to change(StateFileId1099RFollowup, :count).by(-1) end end end - context "when mfj_disability is 'none'" do - let(:params) { { mfj_disability: "none" } } + context "when only spouse is 62-65" do + before do + intake.update(spouse_birth_date: not_senior_dob) + end - it "updates intake with primary_disabled: 'no' and spouse_disabled: 'no'" do - form.save - intake.reload - expect(intake.primary_disabled).to eq "no" - expect(intake.spouse_disabled).to eq "no" + context "when spouse_disabled is set" do + let(:params) { { spouse_disabled: "yes" } } + + it "updates intake using attributes_for" do + expect(intake).to receive(:update).with(form.send(:attributes_for, :intake)) + form.save + end end - context "when a followup already exists" do - let!(:followup) { create :state_file_id1099_r_followup, state_file1099_r: primary_1099r, eligible_income_source: "yes" } - let!(:spouse_followup) { create :state_file_id1099_r_followup, state_file1099_r: spouse_1099r, eligible_income_source: "yes" } + context "when a followup already exists and changes answer to 'no'" do + let!(:followup) { create :state_file_id1099_r_followup, state_file1099_r: spouse_1099r, eligible_income_source: "yes" } + let(:params) { { spouse_disabled: "no" } } - it "does not change the number of followups (does not destroy existing followups)" do + it "updates intake using attributes_for" do + expect(intake).to receive(:update).with(form.send(:attributes_for, :intake)) expect do form.save - end.to change(StateFileId1099RFollowup, :count).by(-2) + end.to change(StateFileId1099RFollowup, :count).by(-1) end end end From 1d4af2d92667f30d80a3736c099e552881d66838 Mon Sep 17 00:00:00 2001 From: Arin Choi Date: Fri, 28 Feb 2025 21:05:55 -0800 Subject: [PATCH 6/9] Add valid? tests for mfj with only spouse age_eligible --- .../state_file/id_disability_form_spec.rb | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/spec/forms/state_file/id_disability_form_spec.rb b/spec/forms/state_file/id_disability_form_spec.rb index 8f707d08a5..4da8729da1 100644 --- a/spec/forms/state_file/id_disability_form_spec.rb +++ b/spec/forms/state_file/id_disability_form_spec.rb @@ -70,6 +70,37 @@ end end end + + context "when only spouse is between 62-65" do + let(:primary_birth_date) { senior_dob } + let(:spouse_birth_date) { not_senior_dob } + + context "when primary_disabled is blank" do + let(:params) { { spouse_disabled: "" } } + + it "is invalid and attaches the correct error" do + expect(form).not_to be_valid + expect(form.errors[:spouse_disabled]).to include "Can't be blank." + end + end + + context "when primary_disabled is not yes/no" do + let(:params) { { spouse_disabled: "invalid" } } + + it "is invalid" do + expect(form).not_to be_valid + expect(form.errors[:spouse_disabled]).to include "Can't be blank." + end + end + + context "when primary_disabled is valid" do + let(:params) { { spouse_disabled: "yes" } } + + it "is valid" do + expect(form).to be_valid + end + end + end end context "when filing status is not MFJ" do From c515486b09a29ae6d29b097e31be1417bf847713 Mon Sep 17 00:00:00 2001 From: Arin Choi Date: Sun, 2 Mar 2025 22:55:12 -0800 Subject: [PATCH 7/9] Update description of tests --- spec/forms/state_file/id_disability_form_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/forms/state_file/id_disability_form_spec.rb b/spec/forms/state_file/id_disability_form_spec.rb index 4da8729da1..89de180159 100644 --- a/spec/forms/state_file/id_disability_form_spec.rb +++ b/spec/forms/state_file/id_disability_form_spec.rb @@ -75,7 +75,7 @@ let(:primary_birth_date) { senior_dob } let(:spouse_birth_date) { not_senior_dob } - context "when primary_disabled is blank" do + context "when spouse_disabled is blank" do let(:params) { { spouse_disabled: "" } } it "is invalid and attaches the correct error" do @@ -84,7 +84,7 @@ end end - context "when primary_disabled is not yes/no" do + context "when spouse_disabled is not yes/no" do let(:params) { { spouse_disabled: "invalid" } } it "is invalid" do @@ -93,7 +93,7 @@ end end - context "when primary_disabled is valid" do + context "when spouse_disabled is valid" do let(:params) { { spouse_disabled: "yes" } } it "is valid" do From 5e3dc55e9c4865ee4c770abb96ab5db2cd90d52c Mon Sep 17 00:00:00 2001 From: Arin Choi Date: Sun, 2 Mar 2025 23:02:09 -0800 Subject: [PATCH 8/9] Update ID calculator to only add up eligible_1099rs and update eligible_income factory for 1099Rs --- app/lib/efile/id/id39_r_calculator.rb | 2 +- spec/factories/state_file_id_intakes.rb | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/lib/efile/id/id39_r_calculator.rb b/app/lib/efile/id/id39_r_calculator.rb index 83d39e38ba..e0e2b2d113 100644 --- a/app/lib/efile/id/id39_r_calculator.rb +++ b/app/lib/efile/id/id39_r_calculator.rb @@ -85,7 +85,7 @@ def calculate_sec_b_line_8d end def calculate_sec_b_line_8e - @intake.state_file1099_rs.sum do |form1099r| + @intake.eligible_1099rs.sum do |form1099r| if form1099r.state_specific_followup&.eligible_income_source_yes? && form1099r.taxable_amount.present? form1099r.taxable_amount.round else diff --git a/spec/factories/state_file_id_intakes.rb b/spec/factories/state_file_id_intakes.rb index fc508c799e..10a033a9eb 100644 --- a/spec/factories/state_file_id_intakes.rb +++ b/spec/factories/state_file_id_intakes.rb @@ -192,9 +192,11 @@ trait :with_eligible_1099r_income do after(:create) do |intake| - create(:state_file1099_r, intake: intake, taxable_amount: 2000, state_tax_withheld_amount: 200) do |form_1099r| + create(:state_file1099_r, intake: intake, taxable_amount: 2000, state_tax_withheld_amount: 200, recipient_ssn: intake.primary.ssn) do |form_1099r| create(:state_file_id1099_r_followup, state_file1099_r: form_1099r, eligible_income_source: "yes") end + + intake.update(primary_disabled: "yes") end end From de3d0540a71f8400ea77cbcfce4149a945ae3a52 Mon Sep 17 00:00:00 2001 From: Arin Choi Date: Sun, 2 Mar 2025 23:13:06 -0800 Subject: [PATCH 9/9] Revert "Update ID calculator to only add up eligible_1099rs and update eligible_income factory for 1099Rs" This reverts commit 5e3dc55e9c4865ee4c770abb96ab5db2cd90d52c. --- app/lib/efile/id/id39_r_calculator.rb | 2 +- spec/factories/state_file_id_intakes.rb | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/lib/efile/id/id39_r_calculator.rb b/app/lib/efile/id/id39_r_calculator.rb index e0e2b2d113..83d39e38ba 100644 --- a/app/lib/efile/id/id39_r_calculator.rb +++ b/app/lib/efile/id/id39_r_calculator.rb @@ -85,7 +85,7 @@ def calculate_sec_b_line_8d end def calculate_sec_b_line_8e - @intake.eligible_1099rs.sum do |form1099r| + @intake.state_file1099_rs.sum do |form1099r| if form1099r.state_specific_followup&.eligible_income_source_yes? && form1099r.taxable_amount.present? form1099r.taxable_amount.round else diff --git a/spec/factories/state_file_id_intakes.rb b/spec/factories/state_file_id_intakes.rb index 10a033a9eb..fc508c799e 100644 --- a/spec/factories/state_file_id_intakes.rb +++ b/spec/factories/state_file_id_intakes.rb @@ -192,11 +192,9 @@ trait :with_eligible_1099r_income do after(:create) do |intake| - create(:state_file1099_r, intake: intake, taxable_amount: 2000, state_tax_withheld_amount: 200, recipient_ssn: intake.primary.ssn) do |form_1099r| + create(:state_file1099_r, intake: intake, taxable_amount: 2000, state_tax_withheld_amount: 200) do |form_1099r| create(:state_file_id1099_r_followup, state_file1099_r: form_1099r, eligible_income_source: "yes") end - - intake.update(primary_disabled: "yes") end end