Skip to content

Commit

Permalink
Add page routing functionality to auto wait #187091623 (#4371)
Browse files Browse the repository at this point in the history
* No longer throwing error if a rejected return doesn't have an error
* Make W2 controller return-to-review-able
* NyPermanentAddress can now return to review
* Spouse state id can now return to review
* Primary state id can now return to review
* W2 can now return to review
* 1099G now supports return to review
* All controllers now have return to review
* Updated annotations
* Add validation to NY 1099-G Payer's TIN #187222366

Co-authored-by: Jenny Heath <[email protected]>
  • Loading branch information
tofarr and jenny-heath authored Mar 21, 2024
1 parent 4a917f8 commit 4ced7a6
Show file tree
Hide file tree
Showing 29 changed files with 272 additions and 63 deletions.
15 changes: 7 additions & 8 deletions app/controllers/concerns/state_file/return_to_review_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@ module ReturnToReviewConcern
# to the review page rather than the usual next page in the flow
extend ActiveSupport::Concern

private

def review_step
case params[:us_state]
when 'az'
StateFile::Questions::AzReviewController
when 'ny'
StateFile::Questions::NyReviewController
end
"StateFile::Questions::#{current_intake.state_code.titleize}ReviewController".constantize
end

private

def next_step
params[:return_to_review].nil? ? super : review_step
end

def prev_step
params[:return_to_review].nil? ? super : review_step
end
end
end
11 changes: 9 additions & 2 deletions app/controllers/hub/state_file/efile_errors_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ def index
@efile_errors = @efile_errors.where.not(service_type: "ctc").order(:source, :code)
end

def edit; end
def edit
@correction_path_options_for_select = EfileError.paths
unless @efile_error.correction_path.present?
@efile_error.correction_path = EfileError.controller_to_path(
EfileError.default_controller
)
end
end

def show; end

Expand All @@ -34,7 +41,7 @@ def reprocess
end

def permitted_params
params.require(:efile_error).permit(:expose, :auto_cancel, :auto_wait, :description_en, :description_es, :resolution_en, :resolution_es)
params.require(:efile_error).permit(:expose, :auto_cancel, :auto_wait, :correction_path, :description_en, :description_es, :resolution_en, :resolution_es)
end
end
end
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module StateFile
module Questions
class AzPrimaryStateIdController < AuthenticatedQuestionsController
include ReturnToReviewConcern
end
end
end
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module StateFile
module Questions
class AzSeniorDependentsController < AuthenticatedQuestionsController
include ReturnToReviewConcern

def self.show?(intake)
intake.dependents.count(&:ask_senior_questions?).positive?
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module StateFile
module Questions
class AzSpouseStateIdController < AuthenticatedQuestionsController
include ReturnToReviewConcern

def self.show?(intake)
intake.filing_status_mfj?
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module StateFile
module Questions
class NyPermanentAddressController < AuthenticatedQuestionsController
include ReturnToReviewConcern
include EligibilityOffboardingConcern
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module StateFile
module Questions
class NyPrimaryStateIdController < AuthenticatedQuestionsController
include ReturnToReviewConcern
end
end
end
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module StateFile
module Questions
class NySpouseStateIdController < AuthenticatedQuestionsController
include ReturnToReviewConcern

def self.show?(intake)
intake.filing_status_mfj?
end
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/state_file/questions/questions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,12 @@ def next_path
step_for_next_path.to_path_helper(options)
end

def prev_step
form_navigation.prev
end

def prev_path
path_for_step(form_navigation.prev)
path_for_step(prev_step)
end

def path_for_step(step)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module StateFile
module Questions
class UnemploymentController < AuthenticatedQuestionsController
include ReturnToReviewConcern
include OtherOptionsLinksConcern
before_action :load_faq_link, only: [:new, :edit]

Expand Down Expand Up @@ -34,12 +35,12 @@ def update

if @state_file1099_g.had_box_11_no?
@state_file1099_g.destroy
return redirect_to action: :index
return redirect_to action: :index, return_to_review: params[:return_to_review]
end

if @state_file1099_g.valid?
@state_file1099_g.save
redirect_to action: :index
redirect_to action: :index, return_to_review: params[:return_to_review]
else
render :edit
end
Expand All @@ -53,7 +54,7 @@ def create

if @state_file1099_g.valid?
@state_file1099_g.save
redirect_to action: :index
redirect_to action: :index, return_to_review: params[:return_to_review]
else
render :new
end
Expand All @@ -64,7 +65,7 @@ def destroy
if @state_file1099_g.destroy
flash[:notice] = I18n.t("state_file.questions.unemployment.destroy.removed", name: @state_file1099_g.recipient_name)
end
redirect_to action: :index
redirect_to action: :index, return_to_review: params[:return_to_review]
end

private
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/state_file/questions/w2_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module StateFile
module Questions
class W2Controller < AuthenticatedQuestionsController
include ReturnToReviewConcern
before_action :load_w2s
before_action :load_w2, only: [:edit, :update]

Expand Down Expand Up @@ -35,7 +36,7 @@ def update
if @w2.valid?
@w2.save
redirect_to next_path and return if @w2s.length == 1
redirect_to action: :index
redirect_to action: :index, return_to_review: params[:return_to_review]
else
render :edit
end
Expand Down Expand Up @@ -76,7 +77,7 @@ def load_w2

def prev_path
if @w2s.length > 1 && ["update", "edit"].include?(action_name)
return path_for_step(self.class)
return self.class.to_path_helper(action: :index, us_state: params[:us_state], return_to_review: params[:return_to_review])
end
super
end
Expand Down
49 changes: 37 additions & 12 deletions app/models/efile_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@
#
# Table name: efile_errors
#
# id :bigint not null, primary key
# auto_cancel :boolean default(FALSE)
# auto_wait :boolean default(FALSE)
# category :string
# code :string
# expose :boolean default(FALSE)
# message :text
# service_type :integer default("unfilled"), not null
# severity :string
# source :string
# created_at :datetime not null
# updated_at :datetime not null
# id :bigint not null, primary key
# auto_cancel :boolean default(FALSE)
# auto_wait :boolean default(FALSE)
# category :string
# code :string
# correction_path :string
# expose :boolean default(FALSE)
# message :text
# service_type :integer default("unfilled"), not null
# severity :string
# source :string
# created_at :datetime not null
# updated_at :datetime not null
#
class EfileError < ApplicationRecord
has_rich_text :description_en
Expand Down Expand Up @@ -47,4 +48,28 @@ def resolution(locale)
resolution_es.present? ? resolution_es : resolution_en
end
end

def self.path_to_controller(path)
"StateFile::Questions::#{path.gsub("-", "_").camelize}Controller".constantize
end

def self.controller_to_path(controller)
controller.name.split("::")[-1][0..-11].underscore.gsub("_", "-")
end

def self.default_controller
StateFile::Questions::NameDobController
end

def self.paths
paths = Set.new
StateFileBaseIntake::STATE_CODES.each do |state_code|
navigation = "Navigation::StateFile#{state_code.titleize}QuestionNavigation".constantize
navigation.controllers.each do |controller|
paths << EfileError.controller_to_path(controller)
end
end
paths.to_a.sort
end

end
5 changes: 4 additions & 1 deletion app/views/hub/state_file/efile_errors/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
<%= f.hub_checkbox :expose, "Exposed to client? (exposes reject code and description on return-status page)" %>
<%= f.hub_checkbox :auto_cancel, "Auto-cancel?" %>
<%= f.hub_checkbox :auto_wait, "Auto-wait? (shows terminal reject state on return-status page)" %>

<div>
<%= f.label "Correction Path" %><br />
<%= f.select :correction_path, @correction_path_options_for_select, selected: @efile_error.correction_path %>
</div>
<div class="spacing-above-25">
<%= f.label :description_en, "Description [English] (overwrites default reject description on return-status page)", class: "h4" %>
<%= f.rich_text_area :description_en %>
Expand Down
5 changes: 5 additions & 0 deletions app/views/hub/state_file/efile_errors/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
<%= image_tag @efile_error.auto_wait ? "icons/check.svg" : "icons/cancelled.svg", alt: @efile_error.auto_wait ? "yes" : "no" %>
</div>

<div class="test-auto-wait spacing-below-25">
<h4 class="spacing-below-5">Correction Path</h4>
<%= @efile_error.correction_path.present? ? @efile_error.correction_path : "N/A" %>
</div>

<h4 class="spacing-below-5">Description (English)</h4>
<%= @efile_error.description_en.present? ? @efile_error.description_en : "N/A" %>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
</p>

<%= form_with model: @form, url: { action: :update }, local: true, method: "put", builder: VitaMinFormBuilder do |f| %>
<% if params[:return_to_review].present? %>
<%= hidden_field_tag "return_to_review", params[:return_to_review] %>
<% end %>
<div class="question-with-follow-up spacing-below-15">
<div class="question-with-follow-up__question">
<div class="blue-group">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<%= form_with model: @form, url: { action: :update }, local: true, method: "put", builder: VitaMinFormBuilder do |f| %>
<% if params[:return_to_review].present? %>
<%= hidden_field_tag "return_to_review", params[:return_to_review] %>
<% end %>
<div class="question-with-follow-up spacing-below-25">
<div class="question-with-follow-up__question spacing-below-15">
<div class="blue-group">
Expand Down
14 changes: 9 additions & 5 deletions app/views/state_file/questions/return_status/_rejected.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
<%= t("state_file.questions.return_status.rejected.title", state_name: States.name_for_key(params[:us_state].upcase)) %>
</h1>

<% if @error.expose %>
<% if @error&.expose %>
<% if @error.code.present? %>
<section class="spacing-below-15">
<strong><%= t('.reject_code') %></strong>
<%= @error.code %>
</section>
<% end %>
<% if @error.message.present? || @error.description(I18n.locale).present? %>
<% if @error&.message.present? || @error&.description(I18n.locale).present? %>
<section class="spacing-below-15">
<strong><%= t('.reject_desc') %></strong>
<%= @error.description(I18n.locale).present? ? @error.description(I18n.locale) : @error.message %>
Expand All @@ -31,7 +31,7 @@
</section>
<% end %>
<% if @error.auto_cancel %>
<% if @error&.auto_cancel %>
<section class="spacing-below-15">
<p class="spacing-below-5"><strong><%= t('.next_steps.no_edit.title') %></strong></p>
<%= t('.next_steps.no_edit.body_html') %>
Expand All @@ -49,6 +49,10 @@
<%= t('.contact_us') %>
</section>

<% edit_return_path = params[:us_state] == 'az' ? az_questions_name_dob_path : ny_questions_name_dob_path %>
<%= link_to t('.edit_return'), edit_return_path, class: "button button--primary spacing-above-60" %>
<% edit_return_controller = @error.correction_path.present? ? EfileError.path_to_controller(@error.correction_path) : EfileError.default_controller %>
<%= link_to t('.edit_return'), edit_return_controller.to_path_helper(
action: edit_return_controller.navigation_actions.first,
return_to_review: :y,
us_state: current_intake.state_code
), class: "button button--primary spacing-above-60" %>
<% end %>
3 changes: 3 additions & 0 deletions app/views/state_file/questions/unemployment/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
<% content_for :card do %>
<h1 class="form-question"><%= @main_heading %></h1>
<%= form_with model: @state_file1099_g, url: { action: @state_file1099_g.persisted? ? :update : :create }, local: true, builder: VitaMinFormBuilder, html: { class: 'form-card form-card--long' } do |f| %>
<% if params[:return_to_review].present? %>
<%= hidden_field_tag "return_to_review", params[:return_to_review] %>
<% end %>
<div class="question-with-follow-up">
<div class="question-with-follow-up__question">
<div class="blue-group">
Expand Down
6 changes: 3 additions & 3 deletions app/views/state_file/questions/unemployment/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<%= t('.unemployment_compensation', amount: form1099.unemployment_compensation) %>
</p>
<div>
<%= link_to t("general.edit"), StateFile::Questions::UnemploymentController.to_path_helper(us_state: params[:us_state], id: form1099), class: "button--small button--inline-action" %>
<%= link_to t("general.delete"), StateFile::Questions::UnemploymentController.to_path_helper(action: :destroy, us_state: params[:us_state], id: form1099), method: :delete, data: {confirm: t(".delete_confirmation")}, class: "button--small button--inline-action last" %>
<%= link_to t("general.edit"), StateFile::Questions::UnemploymentController.to_path_helper(us_state: params[:us_state], id: form1099, return_to_review: params[:return_to_review]), class: "button--small button--inline-action" %>
<%= link_to t("general.delete"), StateFile::Questions::UnemploymentController.to_path_helper(action: :destroy, us_state: params[:us_state], id: form1099, return_to_review: params[:return_to_review]), method: :delete, data: {confirm: t(".delete_confirmation")}, class: "button--small button--inline-action last" %>
</div>
</div>
</div>
Expand All @@ -26,7 +26,7 @@
<%= link_to(next_path, class: "button button--primary button--wide spacing-below-10") do %>
<%= t('general.continue') %>
<% end %>
<%= link_to(StateFile::Questions::UnemploymentController.to_path_helper(action: :new, us_state: params[:us_state]), class: "button button--wide") do %>
<%= link_to(StateFile::Questions::UnemploymentController.to_path_helper(action: :new, us_state: params[:us_state], return_to_review: params[:return_to_review]), class: "button button--wide") do %>
<%= t('.add_another') %>
<% end %>
<% end %>
3 changes: 3 additions & 0 deletions app/views/state_file/questions/w2/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<h1 class="form-question"><%= t(".instructions_1", employer_name: @employer_name , total_wages_amt: number_to_currency(@wages_amt)) %></h1>
<h2 class="form-question"><%= t(".instructions_2") %></h2>
<%= form_with model: @w2, url: { action: :update }, method: :patch, local: true, builder: VitaMinFormBuilder, html: { class: 'form-card form-card--long' } do |f| %>
<% if params[:return_to_review].present? %>
<%= hidden_field_tag "return_to_review", params[:return_to_review] %>
<% end %>
<div class="blue-group">
<div class="form-question spacing-below-25">
<div class="text--bold spacing-below-15"><%=t("general.state") %></div>
Expand Down
5 changes: 4 additions & 1 deletion app/views/state_file/questions/w2/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@
</div>
</div>
<div>
<%= link_to t("general.update"), StateFile::Questions::W2Controller.to_path_helper(us_state: params[:us_state], action: :edit, id: w2.w2_index), class: "button--small button--inline-action" %>
<%= link_to t("general.update"), StateFile::Questions::W2Controller.to_path_helper(us_state: params[:us_state], action: :edit, id: w2.w2_index, return_to_review: params[:return_to_review]), class: "button--small button--inline-action" %>
</div>
</div>
<% end %>
<%= form_with model: @w2, url: { action: :create }, method: :post, local: true, builder: VitaMinFormBuilder, html: { class: 'form-card form-card--long' } do |f| %>
<% if params[:return_to_review].present? %>
<%= hidden_field_tag "return_to_review", params[:return_to_review] %>
<% end %>
<%= f.continue %>
<% if @errors_present %>
<span class="text--error" id="state_file_w2_local_income_tax_amt__errors">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddCorrectionPathToEfileError < ActiveRecord::Migration[7.1]
def change
add_column :efile_errors, :correction_path, :string
end
end
Loading

0 comments on commit 4ced7a6

Please sign in to comment.