Skip to content

Commit

Permalink
Merge branch 'main' into jnf/fyst-1727/special-program-az
Browse files Browse the repository at this point in the history
  • Loading branch information
jnf committed Jan 30, 2025
2 parents 4e13101 + fbb491d commit 5c8343e
Show file tree
Hide file tree
Showing 64 changed files with 1,397 additions and 163 deletions.
51 changes: 51 additions & 0 deletions app/controllers/concerns/state_file/repeated_question_concern.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
module StateFile
# This concern can be used by any StateFile::Questions::QuestionsController that needs to show a page repeatedly for each of a list of items
# It requires you to add a hidden `index` input to your edit template
module RepeatedQuestionConcern
extend ActiveSupport::Concern

included do
before_action :set_index_and_load_item
end

attr_reader :current_index

def prev_path
prev_index = current_index - 1
if prev_index.negative?
super
else
options = { index: prev_index }
self.class.to_path_helper(options)
end
end

def next_path
next_index = current_index + 1
if next_index >= num_items
super
else
options = {index: next_index}
self.class.to_path_helper(options)
end
end

private

def set_index_and_load_item
@current_index = params[:index].present? ? params[:index].to_i : 0
load_item(@current_index)
end

def num_items
# define in controller
raise NotImplementedError
end

def load_item(index)
# define in controller
raise NotImplementedError
end

end
end
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class AutomatedMessagesController < Hub::StateFile::BaseController

def index
Rails.application.eager_load!
@messages = StateFile::AutomatedMessage::BaseAutomatedMessage.descendants
@messages = StateFile::AutomatedMessage::BaseAutomatedMessage.descendants.excluding(StateFile::AutomatedMessage::DfTransferIssueMessage)
@locales = [:en, :es]
@us_state = StateFile::StateInformationService.active_state_codes.include?(params[:us_state]) ? params[:us_state] : "az"
get_intake
Expand Down
27 changes: 24 additions & 3 deletions app/controllers/hub/state_file/efile_errors_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,16 @@ def update

def reprocess
if @efile_error.present? && (@efile_error.auto_wait || @efile_error.auto_cancel)
auto_transition_to_state = @efile_error.auto_wait ? :waiting : :cancelled
submission_ids = EfileSubmissionTransitionError.accessible_by(current_ability).includes(:efile_error, :efile_submission_transition).where(efile_error: @efile_error, efile_submission_transitions: { most_recent: true, to_state: ["rejected", "failed"] }).pluck(:efile_submission_id)
EfileSubmission.accessible_by(current_ability).where(id: submission_ids).find_each { |submission| submission.transition_to(auto_transition_to_state) }
submission_ids = EfileSubmissionTransitionError.accessible_by(current_ability)
.includes(:efile_error, :efile_submission_transition)
.where(
efile_error: @efile_error,
efile_submission_transitions: { most_recent: true, to_state: ["rejected", "failed"] }
)
.pluck(:efile_submission_id)
EfileSubmission.accessible_by(current_ability).where(id: submission_ids).find_each do |submission|
submission.transition_to(auto_transition_to_state(@efile_error, submission))
end

flash[:notice] = "Successfully reprocessed #{submission_ids.count} submission(s) with #{@efile_error.code} error!"
else
Expand All @@ -56,5 +63,19 @@ def reprocess
def permitted_params
params.require(:efile_error).permit(:expose, :auto_cancel, :auto_wait, :correction_path, :description_en, :description_es, :resolution_en, :resolution_es)
end

private

def auto_transition_to_state(efile_error, submission)
return :cancelled if efile_error.auto_cancel

transition = submission.last_transition
all_errors_auto_wait = transition.efile_errors.all?(&:auto_wait)
if submission.current_state == "rejected"
all_errors_auto_wait ? :notified_of_rejection : :waiting
elsif all_errors_auto_wait # failed current_state
:waiting
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module StateFile
module Questions
class MdPermanentlyDisabledController < QuestionsController
def self.show?(intake)
Flipper.enabled?(:show_retirement_ui) && intake.state_file1099_rs.length.positive?
end

private

def form_params
params.require(:state_file_md_permanently_disabled_form).permit(:mfj_disability, :primary_disabled, :spouse_disabled, :proof_of_disability_submitted)
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module StateFile
module Questions
class MdRetirementIncomeSubtractionController < RetirementIncomeSubtractionController

def followup_class = StateFileMd1099RFollowup

end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ class NjDependentsHealthInsuranceController < QuestionsController
include ReturnToReviewConcern

def self.show?(intake)
return false unless intake.dependents.any?
intake.has_health_insurance_requirement_exception? || intake.eligibility_all_members_health_insurance_no?
intake.dependents.any? && intake.has_health_insurance_requirement_exception?
end

def form_params
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
module StateFile
module Questions
class RetirementIncomeSubtractionController < QuestionsController
include RepeatedQuestionConcern

attr_reader :state_file_1099r

def initialized_edit_form
attribute_keys = Attributes.new(form_class.attribute_names).to_sym
state_specific_followup = find_or_create_state_specific_followup
form_class.new(state_specific_followup, form_class.existing_attributes(state_specific_followup).slice(*attribute_keys))
end

def initialized_update_form
form_class.new(find_or_create_state_specific_followup, form_params)
end

def self.show?(intake)
Flipper.enabled?(:show_retirement_ui) && intake.state_file1099_rs.length.positive?
end

private

def num_items
current_intake.state_file1099_rs.count
end

def load_item(index)
@state_file_1099r = current_intake.state_file1099_rs[index]
if @state_file_1099r.nil?
render "public_pages/page_not_found", status: 404
end
end

def find_or_create_state_specific_followup
unless @state_file_1099r.state_specific_followup.present?
@state_file_1099r.update(state_specific_followup: followup_class.create)
end
@state_file_1099r.state_specific_followup
end

def followup_class
raise NotImplementedError, "Implement Subclass#followup_class to return the state-specific 1099R followup model class"
end
end
end
end
39 changes: 39 additions & 0 deletions app/forms/state_file/md_permanently_disabled_form.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module StateFile
class MdPermanentlyDisabledForm < QuestionsForm
set_attributes_for :intake, :primary_disabled, :spouse_disabled, :proof_of_disability_submitted

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 :proof_of_disability_submitted, inclusion: { in: %w[yes no], message: :blank }, if: :disability_selected?


def save
if intake.filing_status_mfj?
case mfj_disability
when "me"
@intake.update(primary_disabled: "yes", spouse_disabled: "no", proof_of_disability_submitted: proof_of_disability_submitted)
when "spouse"
@intake.update(primary_disabled: "no", spouse_disabled: "yes", proof_of_disability_submitted: proof_of_disability_submitted)
when "both"
@intake.update(primary_disabled: "yes", spouse_disabled: "yes", proof_of_disability_submitted: proof_of_disability_submitted)
when "none"
@intake.update(primary_disabled: "no", spouse_disabled: "no", proof_of_disability_submitted: nil)
end
elsif primary_disabled == "no"
@intake.update(
primary_disabled: "no",
proof_of_disability_submitted: nil
)
else
@intake.update(attributes_for(:intake))
end
end

private

def disability_selected?
mfj_disability.in?(%w[me spouse both]) || primary_disabled == "yes"
end
end
end
21 changes: 21 additions & 0 deletions app/forms/state_file/md_retirement_income_subtraction_form.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module StateFile
class MdRetirementIncomeSubtractionForm < Form
include FormAttributes

set_attributes_for :state_file_md1099_r_followup, :income_source, :service_type

attr_accessor :state_file_md1099_r_followup

validates :income_source, presence: true
validates :service_type, presence: true

def initialize(state_file_md1099_r_followup = nil, params = {})
@state_file_md1099_r_followup = state_file_md1099_r_followup
super(params)
end

def save
state_file_md1099_r_followup.update(attributes_for(:state_file_md1099_r_followup))
end
end
end
2 changes: 1 addition & 1 deletion app/helpers/state_file/nj_2450_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def get_wages(w2)
end

def get_column_a(w2)
column_a = w2.box14_ui_wf_swf&.positive? ? w2.box14_ui_wf_swf : w2.box14_ui_hc_wd
column_a = w2.get_box14_ui_overwrite || 0
column_a&.round || 0
end

Expand Down
25 changes: 25 additions & 0 deletions app/jobs/send_df_transfer_issue_message_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
class SendDfTransferIssueMessageJob < ApplicationJob
def perform(email: false, sms: false, contact_info: nil, state_code: nil)
message_instance = StateFile::AutomatedMessage::DfTransferIssueMessage.new

if email
StateFileNotificationEmail.create!(
data_source: nil, # we have no data source because the intakes have been deleted
to: contact_info,
body: message_instance.email_body(state_code: state_code),
subject: message_instance.email_subject(state_code: state_code)
)
end
if sms
StateFileNotificationTextMessage.create!(
data_source: nil, # we have no data source because the intakes have been deleted
to_phone_number: contact_info,
body: message_instance.sms_body(state_code: state_code),
)
end
end

def priority
PRIORITY_MEDIUM
end
end
12 changes: 0 additions & 12 deletions app/jobs/send_reminder_apology_message_job.rb

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ def perform(submission, transition)
if transition.efile_errors.any?(&:auto_cancel)
submission.transition_to!(:notified_of_rejection)
submission.transition_to!(:cancelled)
elsif transition.efile_errors.all?(&:auto_wait)
submission.transition_to!(:notified_of_rejection)
end

submission.transition_to!(:waiting) if transition.efile_errors.all?(&:auto_wait)
if transition.efile_errors.all? { |efile_error| EfileError.error_codes_to_retry_once.include?(efile_error.code) }
already_auto_resubmitted = submission.previously_transmitted_submission && submission.previously_transmitted_submission.efile_submission_transitions.where(to_state: :resubmitted
).any? { |transition| transition.metadata.dig("auto_resubmitted") }
Expand Down
2 changes: 1 addition & 1 deletion app/lib/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def initialize(user)
cannot :manage, StateId
cannot :manage, EfileSubmission, data_source_type: StateFile::StateInformationService.state_intake_class_names
cannot :manage, EfileError do |error|
error.service_type == "state_file" || error.service_type == "unfilled"
%w[state_file unfilled state_file_az state_file_ny state_file_md state_file_nc state_file_id].include?(error.service_type)
end
end
unless user.email.include?("@codeforamerica.org")
Expand Down
2 changes: 2 additions & 0 deletions app/lib/navigation/state_file_md_question_navigation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class StateFileMdQuestionNavigation < Navigation::StateFileBaseQuestionNavigatio
Navigation::NavigationStep.new(StateFile::Questions::IncomeReviewController),
Navigation::NavigationStep.new(StateFile::Questions::UnemploymentController),
Navigation::NavigationStep.new(StateFile::Questions::MdSocialSecurityBenefitsController),
Navigation::NavigationStep.new(StateFile::Questions::MdRetirementIncomeSubtractionController),
Navigation::NavigationStep.new(StateFile::Questions::MdPermanentlyDisabledController),
Navigation::NavigationStep.new(StateFile::Questions::MdTwoIncomeSubtractionsController),
Navigation::NavigationStep.new(StateFile::Questions::PrimaryStateIdController),
Navigation::NavigationStep.new(StateFile::Questions::SpouseStateIdController),
Expand Down
1 change: 1 addition & 0 deletions app/lib/pdf_filler/f13614c_pdf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,7 @@ def single_dependent_params(dependent, index:)
"form1[0].page1[0].namesOf[0].Row#{index}[0].residentUSCandaMexico[0]" => yes_no_unfilled_to_YN(dependent.north_american_resident),
"form1[0].page1[0].namesOf[0].Row#{index}[0].fullTimeStudent[0]" => yes_no_unfilled_to_YN(dependent.was_student),
"form1[0].page1[0].namesOf[0].Row#{index}[0].totallyPermanentlyDisabled[0]" => yes_no_unfilled_to_YN(dependent.disabled),
"form1[0].page1[0].namesOf[0].Row#{index}[0].issuedIPPIN[0]" => yes_no_unfilled_to_YN(dependent.has_ip_pin),
# certified volunteer section
"form1[0].page1[0].namesOf[0].Row#{index}[0].qualifyingChildDependent[0]" => yes_no_na_unfilled_to_Yes_No_NA(dependent.can_be_claimed_by_other),
"form1[0].page1[0].namesOf[0].Row#{index}[0].ownSupport[0]" => yes_no_na_unfilled_to_Yes_No_NA(dependent.provided_over_half_own_support),
Expand Down
8 changes: 8 additions & 0 deletions app/lib/submission_builder/formatting_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ def sanitize_zipcode(zipcode_str)
sanitized_zipcode.gsub("-", "")
end

def sanitize_middle_initial(middle_initial)
return if middle_initial.blank?

sanitized_middle_initial = sanitize_for_xml(middle_initial)
sanitized_middle_initial = sanitized_middle_initial.tr('^A-Za-z', '')
sanitized_middle_initial&.first(1)
end

def datetime_type(datetime)
return nil unless datetime.present?

Expand Down
4 changes: 2 additions & 2 deletions app/lib/submission_builder/return_header.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def document
xml.Primary do
xml.TaxpayerName do
xml.FirstName sanitize_for_xml(@submission.data_source.primary.first_name, 16) if @submission.data_source.primary.first_name.present?
xml.MiddleInitial sanitize_for_xml(@submission.data_source.primary.middle_initial, 1) if @submission.data_source.primary.middle_initial.present?
xml.MiddleInitial sanitize_middle_initial(@submission.data_source.primary.middle_initial) if sanitize_middle_initial(@submission.data_source.primary.middle_initial).present?
xml.LastName sanitize_for_xml(@submission.data_source.primary.last_name, 32) if @submission.data_source.primary.last_name.present?
xml.NameSuffix @submission.data_source.primary.suffix.upcase if @submission.data_source.primary.suffix.present?
end
Expand All @@ -47,7 +47,7 @@ def document
xml.Secondary do
xml.TaxpayerName do
xml.FirstName sanitize_for_xml(@submission.data_source.spouse.first_name, 16) if @submission.data_source.spouse.first_name.present?
xml.MiddleInitial sanitize_for_xml(@submission.data_source.spouse.middle_initial, 1) if @submission.data_source.spouse.middle_initial.present?
xml.MiddleInitial sanitize_middle_initial(@submission.data_source.spouse.middle_initial) if sanitize_middle_initial(@submission.data_source.spouse.middle_initial).present?
xml.LastName sanitize_for_xml(@submission.data_source.spouse.last_name, 32) if @submission.data_source.spouse.last_name.present?
xml.NameSuffix @submission.data_source.spouse.suffix.upcase if @submission.data_source.spouse.suffix.present?
end
Expand Down
6 changes: 3 additions & 3 deletions app/lib/submission_builder/ty2022/states/az/az_return_xml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def documents_wrapper
xml_doc = build_xml_doc("Form140") do |xml|
xml.LNPriorYrs sanitize_for_xml(@submission.data_source.prior_last_names)
xml.FilingStatus filing_status
if hoh_qualifying_person.present?
if hoh_qualifying_person.present? && @submission.data_source.filing_status_hoh?
xml.QualChildDependentName do
xml.FirstName sanitize_for_xml(hoh_qualifying_person[:first_name], 16)
xml.LastName sanitize_for_xml(hoh_qualifying_person[:last_name], 32)
Expand All @@ -65,7 +65,7 @@ def documents_wrapper
xml.DependentDetails do
xml.Name do
xml.FirstName sanitize_for_xml(dependent.first_name, 16)
xml.MiddleInitial sanitize_for_xml(dependent.middle_initial, 1) if dependent.middle_initial.present?
xml.MiddleInitial sanitize_middle_initial(dependent.middle_initial) if sanitize_middle_initial(dependent.middle_initial).present?
xml.LastName sanitize_for_xml(dependent.last_name, 32)
end
unless dependent.ssn.nil?
Expand All @@ -84,7 +84,7 @@ def documents_wrapper
xml.QualParentsAncestors do
xml.Name do
xml.FirstName sanitize_for_xml(dependent.first_name, 16)
xml.MiddleInitial sanitize_for_xml(dependent.middle_initial, 1) if dependent.middle_initial.present?
xml.MiddleInitial sanitize_middle_initial(dependent.middle_initial) if sanitize_middle_initial(dependent.middle_initial).present?
xml.LastName sanitize_for_xml(dependent.last_name, 32)
end
unless dependent.ssn.nil?
Expand Down
Loading

0 comments on commit 5c8343e

Please sign in to comment.