Skip to content

Commit d55a323

Browse files
DrewProebstelDrew Proebstel
and
Drew Proebstel
authored
FYST-1902-md-update-disability-logic (#5709)
Co-authored-by: Drew Proebstel <[email protected]>
1 parent 8e594f2 commit d55a323

File tree

8 files changed

+327
-274
lines changed

8 files changed

+327
-274
lines changed

app/controllers/state_file/questions/md_pension_exclusion_offboarding_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module Questions
33
class MdPensionExclusionOffboardingController < QuestionsController
44
include OtherOptionsLinksConcern
55
def self.show?(intake)
6-
Flipper.enabled?(:show_retirement_ui) && intake.filing_status_mfj? && intake.state_file1099_rs.present? && intake.has_filer_under_65? && intake.filer_disabled? && intake.no_proof_of_disability_submitted?
6+
Flipper.enabled?(:show_retirement_ui) && intake.filing_status_mfj? && intake.should_warn_about_pension_exclusion? && intake.has_at_least_one_disabled_filer? && intake.no_proof_of_disability_submitted?
77
end
88
end
99
end

app/forms/state_file/md_permanently_disabled_form.rb

+2-10
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,14 @@ def save
2727

2828
private
2929

30-
def proof_not_required?
31-
if intake.filing_status_mfj?
32-
intake.primary_senior? && intake.spouse_senior?
33-
else
34-
intake.primary_senior?
35-
end
36-
end
37-
3830
def primary_requires_proof?
39-
return false if proof_not_required?
31+
return false unless intake.should_warn_about_pension_exclusion?
4032

4133
mfj_disability.in?(%w[primary both]) || primary_disabled == "yes"
4234
end
4335

4436
def spouse_requires_proof?
45-
return false if proof_not_required?
37+
return false unless intake.should_warn_about_pension_exclusion?
4638

4739
mfj_disability.in?(%w[spouse both])
4840
end

app/models/state_file_md_intake.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,11 @@ def has_banking_information_in_financial_resolution?
265265
true
266266
end
267267

268-
def filer_disabled?
268+
def has_at_least_one_disabled_filer?
269269
primary_disabled_yes? || spouse_disabled_yes?
270270
end
271+
272+
def should_warn_about_pension_exclusion?
273+
eligible_1099rs.present? && has_filer_under_65?
274+
end
271275
end

app/views/state_file/questions/md_permanently_disabled/edit.html.erb

+4-6
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,18 @@
1616
<div class="question-with-follow-up">
1717
<div class="question-with-follow-up__question">
1818
<div class="white-group">
19+
<% should_warn_about_pension_exclusion = current_intake.should_warn_about_pension_exclusion? %>
20+
<% primary_data_followup = should_warn_about_pension_exclusion ? "#primary-disability-proof" : nil %>
1921
<% if current_intake.filing_status_mfj? %>
20-
<% are_filers_under_65 = !(current_intake.primary_senior? && current_intake.spouse_senior?) %>
21-
<% primary_data_followup = are_filers_under_65 ? "#primary-disability-proof" : nil %>
22-
<% spouse_data_followup = are_filers_under_65 ? "#spouse-disability-proof" : nil %>
23-
<% both_data_followup = are_filers_under_65 ? "#both-disability-proof" : nil %>
24-
22+
<% spouse_data_followup = should_warn_about_pension_exclusion ? "#spouse-disability-proof" : nil %>
23+
<% both_data_followup = should_warn_about_pension_exclusion ? "#both-disability-proof" : nil %>
2524
<%= f.cfa_radio_set(:mfj_disability, collection: [
2625
{ value: "primary", label: t(".yes_me"), input_html: { "data-follow-up": primary_data_followup } },
2726
{ value: "spouse", label: t(".yes_spouse"), input_html: { "data-follow-up": spouse_data_followup } },
2827
{ value: "both", label: t(".yes_both"), input_html: { "data-follow-up": both_data_followup } },
2928
{ value: "none", label: t(".no_neither") }
3029
]) %>
3130
<% else %>
32-
<% primary_data_followup = !current_intake.primary_senior? ? "#primary-disability-proof" : nil %>
3331
<%= f.cfa_radio_set(:primary_disabled, collection: [
3432
{ value: "yes", label: t("general.affirmative"), input_html: { "data-follow-up": primary_data_followup } },
3533
{ value: "no", label: t("general.negative") }

spec/controllers/state_file/questions/md_pension_exclusion_offboarding_controller_spec.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@
2929
context "when they have 1099Rs in their DF XML" do
3030
context "when a filer is disabled" do
3131
before do
32-
allow(intake).to receive(:filer_disabled?).and_return(true)
32+
allow(intake).to receive(:has_at_least_one_disabled_filer?).and_return(true)
3333
end
34-
context "has a disabled filer under 65" do
34+
context "when we should warn about pension exclusion" do
3535
before do
36-
allow(intake).to receive(:has_filer_under_65?).and_return(true)
36+
allow(intake).to receive(:should_warn_about_pension_exclusion?).and_return(true)
3737
end
3838

3939
context "has no proof of disability" do
@@ -57,9 +57,9 @@
5757
end
5858
end
5959

60-
context "does not have a filer under 65" do
60+
context "should not warn about pension exclusion" do
6161
before do
62-
allow(intake).to receive(:has_filer_under_65?).and_return(false)
62+
allow(intake).to receive(:should_warn_about_pension_exclusion?).and_return(false)
6363
end
6464

6565
context "has no proof of disability" do
@@ -82,7 +82,7 @@
8282

8383
context "when no filers are disabled" do
8484
before do
85-
allow(intake).to receive(:filer_disabled?).and_return(false)
85+
allow(intake).to receive(:has_at_least_one_disabled_filer?).and_return(false)
8686
end
8787

8888
it "shows" do

spec/controllers/state_file/questions/md_permanently_disabled_controller_spec.rb

+103-67
Original file line numberDiff line numberDiff line change
@@ -62,87 +62,123 @@
6262
context "proof followup" do
6363
context "mfj filers" do
6464
let(:intake) { create :state_file_md_intake, :with_spouse }
65-
66-
it "has all followups when spouse is not senior" do
67-
intake.update(primary_birth_date: Date.new((MultiTenantService.statefile.current_tax_year - 66), 1, 1))
68-
intake.update(spouse_birth_date: Date.new((MultiTenantService.statefile.current_tax_year - 64), 1, 1))
69-
get :edit
70-
71-
html = Nokogiri::HTML.parse(response.body)
72-
expect(html.at_css("input[data-follow-up='#spouse-disability-proof']")).to be_present
73-
expect(html.at_css("input[data-follow-up='#primary-disability-proof']")).to be_present
74-
expect(html.at_css("input[data-follow-up='#both-disability-proof']")).to be_present
75-
end
76-
77-
it "has all followups primary is not senior" do
78-
intake.update(primary_birth_date: Date.new((MultiTenantService.statefile.current_tax_year - 64), 1, 1))
79-
intake.update(spouse_birth_date: Date.new((MultiTenantService.statefile.current_tax_year - 66), 1, 1))
80-
get :edit
81-
82-
html = Nokogiri::HTML.parse(response.body)
83-
expect(html.at_css("input[data-follow-up='#primary-disability-proof']")).to be_present
84-
expect(html.at_css("input[data-follow-up='#spouse-disability-proof']")).to be_present
85-
expect(html.at_css("input[data-follow-up='#both-disability-proof']")).to be_present
86-
end
87-
88-
it "has all followups when neither are senior" do
89-
intake.update(primary_birth_date: Date.new((MultiTenantService.statefile.current_tax_year - 64), 1, 1))
90-
intake.update(spouse_birth_date: Date.new((MultiTenantService.statefile.current_tax_year - 64), 1, 1))
91-
get :edit
92-
93-
html = Nokogiri::HTML.parse(response.body)
94-
expect(html.at_css("input[data-follow-up='#primary-disability-proof']")).to be_present
95-
expect(html.at_css("input[data-follow-up='#spouse-disability-proof']")).to be_present
96-
expect(html.at_css("input[data-follow-up='#both-disability-proof']")).to be_present
65+
context "with an eligible 1099r" do
66+
let!(:state_file1099_r) { create :state_file1099_r, intake: intake }
67+
68+
it "has all followups when spouse is not senior" do
69+
intake.update(primary_birth_date: Date.new((MultiTenantService.statefile.current_tax_year - 66), 1, 1))
70+
intake.update(spouse_birth_date: Date.new((MultiTenantService.statefile.current_tax_year - 64), 1, 1))
71+
get :edit
72+
73+
html = Nokogiri::HTML.parse(response.body)
74+
expect(html.at_css("input[data-follow-up='#spouse-disability-proof']")).to be_present
75+
expect(html.at_css("input[data-follow-up='#primary-disability-proof']")).to be_present
76+
expect(html.at_css("input[data-follow-up='#both-disability-proof']")).to be_present
77+
end
78+
79+
it "has all followups primary is not senior" do
80+
intake.update(primary_birth_date: Date.new((MultiTenantService.statefile.current_tax_year - 64), 1, 1))
81+
intake.update(spouse_birth_date: Date.new((MultiTenantService.statefile.current_tax_year - 66), 1, 1))
82+
get :edit
83+
84+
html = Nokogiri::HTML.parse(response.body)
85+
expect(html.at_css("input[data-follow-up='#primary-disability-proof']")).to be_present
86+
expect(html.at_css("input[data-follow-up='#spouse-disability-proof']")).to be_present
87+
expect(html.at_css("input[data-follow-up='#both-disability-proof']")).to be_present
88+
end
89+
90+
it "has all followups when neither are senior" do
91+
intake.update(primary_birth_date: Date.new((MultiTenantService.statefile.current_tax_year - 64), 1, 1))
92+
intake.update(spouse_birth_date: Date.new((MultiTenantService.statefile.current_tax_year - 64), 1, 1))
93+
get :edit
94+
95+
html = Nokogiri::HTML.parse(response.body)
96+
expect(html.at_css("input[data-follow-up='#primary-disability-proof']")).to be_present
97+
expect(html.at_css("input[data-follow-up='#spouse-disability-proof']")).to be_present
98+
expect(html.at_css("input[data-follow-up='#both-disability-proof']")).to be_present
99+
end
100+
101+
it "has no followup id when both are senior" do
102+
intake.update(primary_birth_date: Date.new((MultiTenantService.statefile.current_tax_year - 66), 1, 1))
103+
intake.update(spouse_birth_date: Date.new((MultiTenantService.statefile.current_tax_year - 66), 1, 1))
104+
get :edit
105+
106+
html = Nokogiri::HTML.parse(response.body)
107+
expect(html.at_css("input[data-follow-up='#primary-disability-proof']")).not_to be_present
108+
expect(html.at_css("input[data-follow-up='#spouse-disability-proof']")).not_to be_present
109+
expect(html.at_css("input[data-follow-up='#both-disability-proof']")).not_to be_present
110+
end
111+
112+
it "does not have the pension exclusion warning when follow ups are shown but filing status is mfj" do
113+
intake.update(primary_birth_date: Date.new((MultiTenantService.statefile.current_tax_year - 64), 1, 1))
114+
intake.update(spouse_birth_date: Date.new((MultiTenantService.statefile.current_tax_year - 64), 1, 1))
115+
get :edit
116+
117+
html = Nokogiri::HTML.parse(response.body)
118+
expect(html.at_css("input[data-follow-up='#primary-disability-proof']")).to be_present
119+
expect(html.at_css("input[data-follow-up='#spouse-disability-proof']")).to be_present
120+
expect(html.at_css("input[data-follow-up='#both-disability-proof']")).to be_present
121+
expect(html.to_s).not_to include('data-follow-up="#disability-warning"')
122+
end
97123
end
98124

99-
it "has no followup id when both are senior" do
100-
intake.update(primary_birth_date: Date.new((MultiTenantService.statefile.current_tax_year - 66), 1, 1))
101-
intake.update(spouse_birth_date: Date.new((MultiTenantService.statefile.current_tax_year - 66), 1, 1))
102-
get :edit
125+
context "without an eligible 1099rs" do
126+
let!(:state_file1099_r) { create :state_file1099_r, intake: intake, taxable_amount: 0}
103127

104-
html = Nokogiri::HTML.parse(response.body)
105-
expect(html.at_css("input[data-follow-up='#primary-disability-proof']")).not_to be_present
106-
expect(html.at_css("input[data-follow-up='#spouse-disability-proof']")).not_to be_present
107-
expect(html.at_css("input[data-follow-up='#both-disability-proof']")).not_to be_present
108-
end
128+
it "has no followups when neither are senior" do
129+
intake.update(primary_birth_date: Date.new((MultiTenantService.statefile.current_tax_year - 64), 1, 1))
130+
intake.update(spouse_birth_date: Date.new((MultiTenantService.statefile.current_tax_year - 64), 1, 1))
131+
get :edit
109132

110-
it "does not have the pension exclusion warning when follow ups are shown but filing status is mfj" do
111-
intake.update(primary_birth_date: Date.new((MultiTenantService.statefile.current_tax_year - 64), 1, 1))
112-
intake.update(spouse_birth_date: Date.new((MultiTenantService.statefile.current_tax_year - 64), 1, 1))
113-
get :edit
114-
115-
html = Nokogiri::HTML.parse(response.body)
116-
expect(html.at_css("input[data-follow-up='#primary-disability-proof']")).to be_present
117-
expect(html.at_css("input[data-follow-up='#spouse-disability-proof']")).to be_present
118-
expect(html.at_css("input[data-follow-up='#both-disability-proof']")).to be_present
119-
expect(html.to_s).not_to include('data-follow-up="#disability-warning"')
133+
html = Nokogiri::HTML.parse(response.body)
134+
expect(html.at_css("input[data-follow-up='#primary-disability-proof']")).not_to be_present
135+
expect(html.at_css("input[data-follow-up='#spouse-disability-proof']")).not_to be_present
136+
expect(html.at_css("input[data-follow-up='#both-disability-proof']")).not_to be_present
137+
end
120138
end
121139
end
122140

123141
context "not mfj" do
124142
let(:intake) { create :state_file_md_intake, filing_status: "single" }
125143

126-
it "has primary data followup and warning when primary is not senior" do
127-
intake.update(primary_birth_date: Date.new((MultiTenantService.statefile.current_tax_year - 64), 1, 1))
128-
get :edit
144+
context "with an eligible 1099rs" do
145+
let!(:state_file1099_r) { create :state_file1099_r, intake: intake }
146+
it "has primary data followup and warning when primary is not senior" do
147+
intake.update(primary_birth_date: Date.new((MultiTenantService.statefile.current_tax_year - 64), 1, 1))
148+
get :edit
149+
150+
html = Nokogiri::HTML.parse(response.body)
151+
152+
expect(html.at_css("input[data-follow-up='#primary-disability-proof']")).to be_present
153+
expect(html.to_s).to include('data-follow-up="#disability-warning"')
154+
expect(html.at_css("input[data-follow-up='#spouse-disability-proof']")).not_to be_present
155+
expect(html.at_css("input[data-follow-up='#both-disability-proof']")).not_to be_present
156+
end
157+
158+
it "does not have primary data followup when primary is senior" do
159+
intake.update(primary_birth_date: Date.new((MultiTenantService.statefile.current_tax_year - 66), 1, 1))
160+
get :edit
161+
162+
html = Nokogiri::HTML.parse(response.body)
163+
expect(html.at_css("input[data-follow-up='#primary-disability-proof']")).not_to be_present
164+
expect(html.at_css("input[data-follow-up='#spouse-disability-proof']")).not_to be_present
165+
expect(html.at_css("input[data-follow-up='#both-disability-proof']")).not_to be_present
166+
end
167+
end
129168

130-
html = Nokogiri::HTML.parse(response.body)
169+
context "without an eligible 1099rs" do
170+
let!(:state_file1099_r) { create :state_file1099_r, intake: intake, taxable_amount: 0}
131171

132-
expect(html.at_css("input[data-follow-up='#primary-disability-proof']")).to be_present
133-
expect(html.to_s).to include('data-follow-up="#disability-warning"')
134-
expect(html.at_css("input[data-follow-up='#spouse-disability-proof']")).not_to be_present
135-
expect(html.at_css("input[data-follow-up='#both-disability-proof']")).not_to be_present
136-
end
172+
it "has no followups and warning when primary is not senior" do
173+
intake.update(primary_birth_date: Date.new((MultiTenantService.statefile.current_tax_year - 64), 1, 1))
174+
get :edit
137175

138-
it "does not have primary data followup when primary is senior" do
139-
intake.update(primary_birth_date: Date.new((MultiTenantService.statefile.current_tax_year - 66), 1, 1))
140-
get :edit
176+
html = Nokogiri::HTML.parse(response.body)
141177

142-
html = Nokogiri::HTML.parse(response.body)
143-
expect(html.at_css("input[data-follow-up='#primary-disability-proof']")).not_to be_present
144-
expect(html.at_css("input[data-follow-up='#spouse-disability-proof']")).not_to be_present
145-
expect(html.at_css("input[data-follow-up='#both-disability-proof']")).not_to be_present
178+
expect(html.at_css("input[data-follow-up='#primary-disability-proof']")).not_to be_present
179+
expect(html.at_css("input[data-follow-up='#spouse-disability-proof']")).not_to be_present
180+
expect(html.at_css("input[data-follow-up='#both-disability-proof']")).not_to be_present
181+
end
146182
end
147183
end
148184
end

0 commit comments

Comments
 (0)