Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
jenny-heath committed Apr 15, 2024
2 parents 59bb3d1 + a6163f7 commit 3025868
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 22 deletions.
18 changes: 15 additions & 3 deletions app/controllers/state_file/questions/return_status_controller.rb
Expand Up @@ -7,6 +7,7 @@ class ReturnStatusController < AuthenticatedQuestionsController
skip_before_action :redirect_if_in_progress_intakes_ended

def edit
@submission_to_show = submission_to_show
@error = submission_error
@return_status = return_status
@refund_url = refund_url
Expand All @@ -23,16 +24,28 @@ def prev_path

private

def submission_to_show
is_az_intake = current_intake.is_a?(StateFileAzIntake)
latest_submission_has_901_error = current_intake.latest_submission&.efile_submission_transitions&.where(to_state: "rejected")&.last&.efile_errors&.pluck(:code)&.include?("901")
accepted_submissions = current_intake.efile_submissions.filter { |submission| submission.in_state?(:accepted) }

if is_az_intake && latest_submission_has_901_error && accepted_submissions.present?
accepted_submissions.last
else
current_intake.latest_submission
end
end

def submission_error
return nil unless return_status == 'rejected'
# in the case that its in the notified_of_rejection or waiting state
# we can't just grab the efile errors from the last transition
current_intake.latest_submission&.efile_submission_transitions&.where(to_state: 'rejected')&.last&.efile_errors&.last
submission_to_show&.efile_submission_transitions&.where(to_state: 'rejected')&.last&.efile_errors&.last
end

def return_status
# return status for display
case current_intake.latest_submission.current_state
case submission_to_show.current_state
when 'accepted'
'accepted'
when 'notified_of_rejection', 'waiting'
Expand Down Expand Up @@ -118,7 +131,6 @@ def redirect_if_from_efile
redirect_to StateFile::Questions::PendingFederalReturnController.to_path_helper(us_state: current_intake.state_code)
end
end

end
end
end
2 changes: 1 addition & 1 deletion app/state_machines/efile_submission_state_machine.rb
Expand Up @@ -34,7 +34,7 @@ class EfileSubmissionStateMachine
transition from: :rejected, to: [:resubmitted, :cancelled, :investigating, :waiting, :fraud_hold, :notified_of_rejection]
transition from: :notified_of_rejection, to: [:resubmitted, :cancelled, :investigating, :waiting, :fraud_hold]
transition from: :investigating, to: [:resubmitted, :cancelled, :waiting, :fraud_hold]
transition from: :waiting, to: [:resubmitted, :cancelled, :investigating, :fraud_hold]
transition from: :waiting, to: [:resubmitted, :cancelled, :investigating, :fraud_hold, :notified_of_rejection]
transition from: :fraud_hold, to: [:investigating, :resubmitted, :waiting, :cancelled]
transition from: :cancelled, to: [:investigating, :waiting]

Expand Down
2 changes: 1 addition & 1 deletion app/views/hub/state_file/efile_submissions/show.html.erb
Expand Up @@ -62,7 +62,7 @@
%>
</div>
<% end %>
<% if @efile_submission.in_state?(:rejected) %>
<% if @efile_submission.in_state?(:rejected) || @efile_submission.in_state?(:waiting) %>
<div style="margin-left: 10px;">
<%= button_to("Notify of Rejection",
notify_of_rejection_hub_efile_submission_path(id: @efile_submission.id),
Expand Down
4 changes: 2 additions & 2 deletions app/views/state_file/questions/return_status/edit.html.erb
Expand Up @@ -2,8 +2,8 @@
<% content_for :card do %>
<%= render @return_status %>
<% if !@error&.auto_wait || app_time.after?(Rails.configuration.state_file_end_of_in_progress_intakes) %>
<%= link_to t('.download_state_return_pdf'), StateFile::Questions::SubmissionPdfsController.to_path_helper(us_state: params[:us_state], action: :show, id: EfileSubmission.where(data_source: current_intake).last), class: "button button--primary button--wide spacing-above-60" %>
<% if !@error&.auto_wait || app_time.after?(Rails.configuration.state_file_end_of_in_progress_intakes) && @submission_to_show.present? %>
<%= link_to t('.download_state_return_pdf'), StateFile::Questions::SubmissionPdfsController.to_path_helper(us_state: params[:us_state], action: :show, id: @submission_to_show.id), class: "button button--primary button--wide spacing-above-60" %>
<% end %>
<% if show_xml? %>
Expand Down
5 changes: 3 additions & 2 deletions crontab
Expand Up @@ -9,8 +9,9 @@
*/10 * * * * bundle exec rake efile:poll_and_get_acknowledgments
0 17 * * * bundle exec rake state_file:reminder_to_finish_state_return
0 21 13 4 * bundle exec rake state_file:pre_deadline_reminder
0 21 16 4 * bundle exec rake state_file:post_deadline_reminder
0 21 17 4 * bundle exec rake state_file:post_deadline_reminder
0 21 22 4 * bundle exec rake state_file:post_deadline_reminder
0 21 13 4 * bundle exec rake send_reject_resolution_reminder_notifications:send
0 21 22 4 * bundle exec rake send_reject_resolution_reminder_notifications:send
0 21 23 4 * bundle exec rake send_reject_resolution_reminder_notifications:send
40 19 12 4 * bundle exec rake send_reject_resolution_reminder_notifications:send
0 11 14 4 * bundle exec rake state_file:send_reminder_apology_message
@@ -0,0 +1,71 @@
require "rails_helper"

RSpec.describe StateFile::Questions::ReturnStatusController do
describe "#edit" do
context "AZ" do
render_views
let(:az_intake) { create :state_file_az_intake }
before do
sign_in az_intake
end

context "happy path" do
let!(:efile_submission) { create(:efile_submission, :notified_of_rejection, :for_state, data_source: az_intake) }

it "shows the most recent submission" do
get :edit, params: { us_state: "az" }

expect(assigns(:submission_to_show)).to eq efile_submission
end
end

context "unhappy path" do
let!(:previous_efile_submission) { create(:efile_submission, :accepted, :for_state, data_source: az_intake) }
let!(:latest_efile_submission) { create(:efile_submission, :transmitted, :for_state, data_source: az_intake) }

before do
latest_efile_submission.transition_to!(:rejected)
create(:efile_submission_transition_error, efile_error: efile_error, efile_submission_transition: latest_efile_submission.last_transition, efile_submission_id: latest_efile_submission.id)
latest_efile_submission.transition_to!(:cancelled)
end

context "client got accepted and then submitted another return which got reject 901" do
let(:efile_error) { create(:efile_error, code: "901", service_type: :state_file, expose: true) }

it "shows the most recent accepted submission" do
get :edit, params: { us_state: "az" }

expect(assigns(:submission_to_show)).to eq previous_efile_submission
end
end

context "client got accepted and then submitted another return which got a different rejection" do
let(:efile_error) { create(:efile_error, code: "A LEGIT REJECTION I GUESS", service_type: :state_file, expose: true) }

it "shows the most recent submission" do
get :edit, params: { us_state: "az" }

expect(assigns(:submission_to_show)).to eq latest_efile_submission
end
end
end
end

context "NY" do
let(:ny_intake) { create :state_file_ny_intake }
before do
sign_in ny_intake
end

context "happy path" do
let!(:efile_submission) { create(:efile_submission, :notified_of_rejection, :for_state, data_source: ny_intake) }

it "shows the most recent submission" do
get :edit, params: { us_state: "ny" }

expect(assigns(:submission_to_show)).to eq efile_submission
end
end
end
end
end
8 changes: 4 additions & 4 deletions spec/features/state_file/complete_intake_spec.rb
Expand Up @@ -83,8 +83,8 @@
expect(page).to have_text I18n.t('state_file.questions.primary_state_id.edit.title')
choose I18n.t('state_file.questions.primary_state_id.state_id.id_type_question.dmv')
fill_in I18n.t('state_file.questions.primary_state_id.state_id.id_details.number'), with: "012345678"
select_cfa_date "state_file_ny_primary_state_id_form_issue_date", Time.now - 4.year
select_cfa_date "state_file_ny_primary_state_id_form_expiration_date", Time.now + 4.year
select_cfa_date "state_file_ny_primary_state_id_form_issue_date", 4.years.ago.beginning_of_year
select_cfa_date "state_file_ny_primary_state_id_form_expiration_date", 4.years.from_now.beginning_of_year
select("New York", from: I18n.t('state_file.questions.primary_state_id.state_id.id_details.issue_state'))
fill_in "For New York IDs: First three characters of the document number (located on the back of your ID)", with: "ABC"
click_on I18n.t("general.continue")
Expand Down Expand Up @@ -230,8 +230,8 @@
expect(page).to have_text I18n.t('state_file.questions.primary_state_id.edit.title')
choose I18n.t('state_file.questions.primary_state_id.state_id.id_type_question.dmv')
fill_in I18n.t('state_file.questions.primary_state_id.state_id.id_details.number'), with: "012345678"
select_cfa_date "state_file_az_primary_state_id_form_issue_date", Time.now - 4.year
select_cfa_date "state_file_az_primary_state_id_form_expiration_date", Time.now + 4.year
select_cfa_date "state_file_az_primary_state_id_form_issue_date", 4.years.ago.beginning_of_year
select_cfa_date "state_file_az_primary_state_id_form_expiration_date", 4.years.from_now.beginning_of_year
select("Arizona", from: I18n.t('state_file.questions.primary_state_id.state_id.id_details.issue_state'))
click_on I18n.t("general.continue")

Expand Down
31 changes: 22 additions & 9 deletions spec/state_machines/efile_submission_state_machine_spec.rb
Expand Up @@ -308,16 +308,29 @@
end

context "to notified_of_rejection" do
let(:submission) { create(:efile_submission, :rejected) }
let!(:submission) { create(:efile_submission, :rejected, :for_state) }
let!(:other_submisssion) { create(:efile_submission, :waiting, :for_state) }
let(:after_transition_messaging_service) { StateFile::AfterTransitionMessagingService.new(submission)}

it "enqueues an AfterTransitionTasksForRejectedReturnJob" do
after_transition_messaging_service = instance_double(StateFile::AfterTransitionMessagingService)
allow(StateFile::AfterTransitionMessagingService)
.to receive(:new)
.and_return(after_transition_messaging_service)
allow(after_transition_messaging_service)
.to receive(:send_efile_submission_rejected_message)
submission.transition_to!(:notified_of_rejection)
before do
allow(StateFile::AfterTransitionMessagingService).to receive(:new).with(submission).and_return(after_transition_messaging_service)
allow(after_transition_messaging_service).to receive(:send_efile_submission_rejected_message)
end

context "currently in rejected state" do
it "enqueues an AfterTransitionTasksForRejectedReturnJob" do
submission.transition_to!(:notified_of_rejection)
expect(StateFile::AfterTransitionMessagingService).to have_received(:new).with(submission)
end
end

context "currently in waiting state" do
let!(:submission) { create(:efile_submission, :waiting, :for_state) }

it "enqueues an AfterTransitionTasksForRejectedReturnJob" do
submission.transition_to!(:notified_of_rejection)
expect(StateFile::AfterTransitionMessagingService).to have_received(:new).with(submission)
end
end
end

Expand Down

0 comments on commit 3025868

Please sign in to comment.