Skip to content

Commit 78da193

Browse files
author
Hugo Melo
authored
[Fyst-1224] nc screener flow (#5052)
* Remove nc eligibility residence form Co-authored-by: Hugo Melo <[email protected]> * Update nc eligibility sreener form to 1 question Co-authored-by: Hugo Melo <[email protected]> * update annotations Co-authored-by: Hugo Melo <[email protected]> * Fix failing specs Co-authored-by: Hugo Melo <[email protected]> * Validate that one and only one option is selected Co-authored-by: Hugo Melo <[email protected]> * Correct checkbox name in spec Co-authored-by: Hugo Melo <[email protected]> * Fix specs by replace with actual controller Co-authored-by: Hugo Melo <[email protected]> * Check and uncheck when options are selected Co-authored-by: Hugo Melo <[email protected]>
1 parent af50144 commit 78da193

25 files changed

+196
-254
lines changed

app/controllers/state_file/questions/nc_eligibility_residence_controller.rb renamed to app/controllers/state_file/questions/nc_eligibility_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module StateFile
22
module Questions
3-
class NcEligibilityResidenceController < QuestionsController
3+
class NcEligibilityController < QuestionsController
44
include EligibilityOffboardingConcern
55
end
66
end
7-
end
7+
end

app/controllers/state_file/questions/nc_eligibility_out_of_state_income_controller.rb

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
module StateFile
2+
class NcEligibilityForm < QuestionsForm
3+
set_attributes_for :intake, :eligibility_ed_loan_cancelled, :eligibility_ed_loan_emp_payment, :nc_eligiblity_none
4+
5+
validate :at_most_one_option_selected
6+
validate :at_least_one_option_selected
7+
8+
def save
9+
@intake.update(attributes_for(:intake))
10+
end
11+
12+
private
13+
14+
def at_least_one_option_selected
15+
values = attributes_for(:intake).values_at(:eligibility_ed_loan_emp_payment, :eligibility_ed_loan_cancelled, :nc_eligiblity_none)
16+
selected = values.select { |value| value == "yes" }
17+
if selected.count < 1
18+
errors.add(:nc_eligiblity_none, I18n.t("forms.errors.nc_eligibility_form.at_most_one_option_selected"))
19+
end
20+
end
21+
22+
def at_most_one_option_selected
23+
if attributes_for(:intake)[:nc_eligiblity_none] == "yes"
24+
if attributes_for(:intake).values_at(:eligibility_ed_loan_emp_payment, :eligibility_ed_loan_cancelled).any? { |value| value == "yes" }
25+
errors.add(:nc_eligiblity_none, I18n.t("forms.errors.nc_eligibility_form.at_most_one_option_selected"))
26+
end
27+
end
28+
end
29+
end
30+
end

app/forms/state_file/nc_eligibility_out_of_state_income_form.rb

Lines changed: 0 additions & 12 deletions
This file was deleted.

app/forms/state_file/nc_eligibility_residence_form.rb

Lines changed: 0 additions & 11 deletions
This file was deleted.

app/lib/navigation/state_file_nc_question_navigation.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ class StateFileNcQuestionNavigation < Navigation::StateFileBaseQuestionNavigatio
44

55
SECTIONS = [
66
Navigation::NavigationSection.new("state_file.navigation.section_1", [
7-
Navigation::NavigationStep.new(StateFile::Questions::NcEligibilityResidenceController),
8-
Navigation::NavigationStep.new(StateFile::Questions::NcEligibilityOutOfStateIncomeController),
7+
Navigation::NavigationStep.new(StateFile::Questions::NcEligibilityController),
98
Navigation::NavigationStep.new(StateFile::Questions::EligibilityOffboardingController, false),
109
Navigation::NavigationStep.new(StateFile::Questions::EligibleController),
1110
]),

app/models/state_file_base_intake.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ def submission_efile_device_info
319319
end
320320

321321
def save_nil_enums_with_unfilled
322-
keys_with_unfilled = self.defined_enums.map { |e| e.first if e.last.include?("unfilled") }
322+
keys_with_unfilled = self.defined_enums.map { |e| e.first if e.last.include?("unfilled") }.compact
323323
keys_with_unfilled.each do |key|
324324
if self.send(key).nil?
325325
self.send("#{key}=", "unfilled")
@@ -339,7 +339,6 @@ def increment_failed_attempts
339339
end
340340

341341
def controller_for_current_step
342-
343342
if efile_submissions.present?
344343
StateFile::Questions::ReturnStatusController
345344
else
@@ -353,7 +352,7 @@ def controller_for_current_step
353352
else
354353
StateFile::Questions::TermsAndConditionsController
355354
end
356-
355+
357356
end
358357

359358
def self.opted_out_state_file_intakes(email)

app/models/state_file_nc_intake.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
# date_electronic_withdrawal :date
1515
# df_data_import_succeeded_at :datetime
1616
# df_data_imported_at :datetime
17+
# eligibility_ed_loan_cancelled :integer default("no"), not null
18+
# eligibility_ed_loan_emp_payment :integer default("no"), not null
1719
# eligibility_lived_in_state :integer default("unfilled"), not null
1820
# eligibility_out_of_state_income :integer default("unfilled"), not null
1921
# eligibility_withdrew_529 :integer default("unfilled"), not null
@@ -87,12 +89,18 @@ class StateFileNcIntake < StateFileBaseIntake
8789
enum sales_use_tax_calculation_method: { unfilled: 0, automated: 1, manual: 2 }, _prefix: :sales_use_tax_calculation_method
8890
enum untaxed_out_of_state_purchases: { unfilled: 0, yes: 1, no: 2 }, _prefix: :untaxed_out_of_state_purchases
8991
enum tribal_member: { unfilled: 0, yes: 1, no: 2 }, _prefix: :tribal_member
92+
9093
enum eligibility_withdrew_529: { unfilled: 0, yes: 1, no: 2 }, _prefix: :eligibility_withdrew_529
9194
enum eligibility_lived_in_state: { unfilled: 0, yes: 1, no: 2 }, _prefix: :eligibility_lived_in_state
9295
enum eligibility_out_of_state_income: { unfilled: 0, yes: 1, no: 2 }, _prefix: :eligibility_out_of_state_income
9396
enum email_notification_opt_in: { unfilled: 0, yes: 1, no: 2 }, _prefix: :email_notification_opt_in
9497
enum sms_notification_opt_in: { unfilled: 0, yes: 1, no: 2 }, _prefix: :sms_notification_opt_in
9598

99+
enum eligibility_ed_loan_cancelled: { no: 0, yes: 1 }, _prefix: :eligibility_ed_loan_cancelled
100+
enum eligibility_ed_loan_emp_payment: { no: 0, yes: 1 }, _prefix: :eligibility_ed_loan_emp_payment
101+
102+
attr_accessor :nc_eligiblity_none
103+
96104
def calculate_sales_use_tax
97105
nc_taxable_income = calculator.lines[:NCD400_LINE_14].value
98106
calculator.calculate_use_tax(nc_taxable_income)
@@ -107,9 +115,8 @@ def disqualifying_df_data_reason
107115

108116
def disqualifying_eligibility_rules
109117
{
110-
eligibility_lived_in_state: "no",
111-
eligibility_out_of_state_income: "yes",
112-
eligibility_withdrew_529: "yes"
118+
eligibility_ed_loan_cancelled: "yes",
119+
eligibility_ed_loan_emp_payment: "yes"
113120
}
114121
end
115122
end
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<% title = t(".title", filing_year: current_tax_year) %>
2+
3+
<% content_for :page_title, title %>
4+
<% content_for :card do %>
5+
<h1 class="h2 spacing-below-5"><%= t(".title", filing_year: current_tax_year) %></h1>
6+
<p class="spacing-below-15 spacing-above-0"><%= t(".subtitle") %></p>
7+
8+
<%= form_with model: @form, url: { action: :update }, local: true, method: "put", builder: VitaMinFormBuilder do |f| %>
9+
<div class="white-group">
10+
<p class="text--bold"><%= t('.question', filing_year: current_tax_year) %></p>
11+
<div class="tight-checkboxes spacing-above-0 spacing-below-0">
12+
<%= f.cfa_checkbox(:eligibility_ed_loan_emp_payment, t(".eligibility_ed_loan_emp_payment"), options: { checked_value: "yes", unchecked_value: "no" }) %>
13+
<%= f.cfa_checkbox(:eligibility_ed_loan_cancelled, t(".eligibility_ed_loan_cancelled"), options: { checked_value: "yes", unchecked_value: "no" }) %>
14+
<%= f.cfa_checkbox(:nc_eligiblity_none, t(".none"), options: { checked_value: "yes", unchecked_value: "no" }) %>
15+
</div>
16+
</div>
17+
18+
<%= f.continue %>
19+
<% end %>
20+
21+
<script>
22+
document.addEventListener("DOMContentLoaded", function() {
23+
let noneCheckbox = document.getElementById("state_file_nc_eligibility_form_nc_eligiblity_none");
24+
let checkboxes = [
25+
document.getElementById("state_file_nc_eligibility_form_eligibility_ed_loan_cancelled"),
26+
document.getElementById("state_file_nc_eligibility_form_eligibility_ed_loan_emp_payment")
27+
]
28+
noneCheckbox.addEventListener("change", function() {
29+
if(this.checked) {
30+
checkboxes.forEach(function(checkbox) {
31+
checkbox.checked = false;
32+
})
33+
}
34+
})
35+
36+
checkboxes.forEach(function(checkbox) {
37+
checkbox.addEventListener("change", function() {
38+
if(this.checked) {
39+
noneCheckbox.checked = false;
40+
}
41+
})
42+
})
43+
})
44+
</script>
45+
<% end %>

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

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)