Skip to content

Commit

Permalink
Merge branch 'main' into TBE-26-automated-messages-locales
Browse files Browse the repository at this point in the history
  • Loading branch information
tofarr committed Jun 20, 2024
2 parents f4bb24b + bd72e05 commit 46e3c98
Show file tree
Hide file tree
Showing 203 changed files with 1,045 additions and 548 deletions.
2 changes: 1 addition & 1 deletion app/channels/application_cable/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def current_user

def current_state_file_intake
warden = env['warden']
@current_state_file_intake = StateFileBaseIntake::STATE_CODES.lazy.map{|c| warden.user("state_file_#{c}_intake".to_sym) }.find(&:itself)
@current_state_file_intake = StateFile::StateInformationService.active_state_codes.lazy.map{|c| warden.user("state_file_#{c}_intake".to_sym) }.find(&:itself)
rescue UncaughtThrowError => e
raise unless e.tag == :warden

Expand Down
1 change: 1 addition & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ def before_withdrawal_date_deadline?
helper_method :before_withdrawal_date_deadline?

def post_deadline_withdrawal_date
# after the tax deadline we automatically set the bank withdrawal date to be the current day
if params[:us_state] == 'ny'
app_time.in_time_zone('America/New_York')
else
Expand Down
26 changes: 26 additions & 0 deletions app/controllers/concerns/client_sortable.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
module ClientSortable
extend ActiveSupport::Concern

def self.included(base)
base.helper_method :vita_partners_for_tagify
end

private

def setup_sortable_client
Expand All @@ -24,4 +28,26 @@ def cookie_filters

cookies[filter_cookie_name] ? HashWithIndifferentAccess.new(JSON.parse(cookies[filter_cookie_name])) : {}
end

def vita_partners_for_tagify
# This returns the vita partners in a format that the tagify js library can understand
vita_partners = @client_sorter.active_filters[:vita_partners]
return if vita_partners.blank?
vita_partners = JSON.parse(vita_partners)
result = vita_partners.map do |id|

# This will only be applicable for a short while after the deploy to production, when we
# may still have cookies defined in the old more verbose format. After a few
id = id["id"] if id.instance_of?(Hash)

vita_partner = @vita_partners.find { |p| p.id == id }
{
id: vita_partner.id,
name: vita_partner.name,
parentName: vita_partner.parent_organization&.name,
value: vita_partner.id
}
end
result.to_json
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module EligibilityOffboardingConcern
private

def offboarding_path
StateFile::Questions::EligibilityOffboardingController.to_path_helper(us_state: params[:us_state])
StateFile::Questions::EligibilityOffboardingController.to_path_helper(us_state: current_state_code)
end

def next_path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module OtherOptionsLinksConcern
extend ActiveSupport::Concern

def vita_link
case params[:us_state]
case current_state_code
when 'ny'
'https://airtable.com/appQS3abRZGjT8wII/pagtpLaX0wokBqnuA/form'
when 'az'
Expand All @@ -14,9 +14,9 @@ def vita_link
end

def faq_state_filing_options_link
product_type = FaqCategory.state_to_product_type(params[:us_state])
product_type = FaqCategory.state_to_product_type(current_state_code)
if FaqCategory.where(slug: "other_state_filing_options", product_type: product_type).present?
state_faq_section_path(section_key: "other_state_filing_options", us_state: params[:us_state])
state_faq_section_path(section_key: "other_state_filing_options", us_state: current_state_code)
else
state_faq_path
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,30 @@ module StateFileControllerConcern
extend ActiveSupport::Concern

included do
helper_method(
:current_tax_year, :filer_count, :state_name, :state_abbr, :ny?, :az?, :state_param
)
helper_method :current_intake, :current_state_code, :current_state_name, :current_tax_year
end

private

def state_name
States.name_for_key(state_abbr)
end

def state_abbr
state_param&.upcase
def current_intake
StateFile::StateInformationService.active_state_codes
.lazy
.map{ |c| send("current_state_file_#{c}_intake".to_sym) }
.find(&:itself)
end

def state_param
params[:us_state]
end

def ny?
state_param == "ny"
end

def az?
state_param == "az"
end

def service_type
case state_param
when "az" then :statefile_az
when "ny" then :statefile_ny
def current_state_code
if current_intake
current_intake.state_code
else
params[:us_state]
end
end

def tenant_service
MultiTenantService.new(service_type)
def current_state_name
StateFile::StateInformationService.state_name(current_state_code)
end

def current_tax_year
tenant_service.current_tax_year
end

def filer_count
current_intake&.filer_count
MultiTenantService.new(:statefile).current_tax_year
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ class EfileSubmissionsController < Hub::StateFile::BaseController
before_action :load_efile_submissions, only: [:index]

def index
join_sql = StateFileBaseIntake::STATE_CODES.map do |state_code|
"SELECT state_file_#{state_code}_intakes.id as intake_id, 'StateFile#{state_code.to_s.titleize}Intake' as ds_type, '#{state_code}' as data_source_state_code, state_file_#{state_code}_intakes.email_address FROM state_file_#{state_code}_intakes"
join_sql = ::StateFile::StateInformationService.active_state_codes.map do |_state_code|
"SELECT state_file_#{_state_code}_intakes.id as intake_id, 'StateFile#{_state_code.to_s.titleize}Intake' as ds_type, '#{_state_code}' as data_source_state_code, state_file_#{_state_code}_intakes.email_address FROM state_file_#{_state_code}_intakes"
end
join_sql = "INNER JOIN (#{join_sql.join(" UNION ")}) data_source ON efile_submissions.data_source_id = data_source.intake_id and efile_submissions.data_source_type = data_source.ds_type"
@efile_submissions = EfileSubmission.joins(join_sql).select("efile_submissions.*, data_source.*")
Expand Down
11 changes: 4 additions & 7 deletions app/controllers/state_file/faq_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ class StateFile::FaqController < ApplicationController
layout "state_file"

def index
@state_code_names = case params[:us_state]
when 'us'
StateFileBaseIntake::STATE_CODE_AND_NAMES
when 'ny'
StateFileNyIntake::STATE_CODE_AND_NAME
when 'az'
StateFileAzIntake::STATE_CODE_AND_NAME
@state_code_names = if params[:us_state] == 'us'
StateFile::StateInformationService.state_code_to_name_map
else
StateFile::StateInformationService.state_code_to_name_map.slice(params[:us_state])
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def edit
)
@fake_data_transfer_link = fake_data_transfer_link
@irs_df_transfer_link = irs_df_transfer_link
@go_back_link = case current_intake.state_code
@go_back_link = case current_state_code
when "ny"
ny_questions_initiate_data_transfer_path
when "az"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Questions
class ConfirmationController < QuestionsController
def show_xml
submission = EfileSubmission.where(data_source: current_intake).first
builder_response = case params[:us_state]
builder_response = case current_state_code
when "ny"
SubmissionBuilder::Ty2022::States::Ny::IndividualReturn.build(submission)
when "az"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def edit
redirect_to next_path and return
end
if current_intake&.df_data_import_failed_at.present?
redirect_to StateFilePagesController.to_path_helper(action: :data_import_failed, us_state: params[:us_state]) and return
redirect_to StateFilePagesController.to_path_helper(action: :data_import_failed, us_state: current_state_code) and return
end
StateFileEfileDeviceInfo.find_or_create_by!(
event_type: "initial_creation",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def ineligible_reason
if key.present?
I18n.t(
"state_file.questions.data_transfer_offboarding.edit.ineligible_reason.#{key}",
state: States.name_for_key(params[:us_state].upcase)
state: current_state_name
)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def ineligible_reason
if key.present?
I18n.t(
"state_file.questions.eligibility_offboarding.edit.ineligible_reason.#{key}",
state: States.name_for_key(params[:us_state].upcase)
state: current_state_name
)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class EligibilityOutOfStateIncomeController < QuestionsController
include EligibilityOffboardingConcern

def form_class
case params[:us_state]
case current_state_code
when 'az'
StateFile::AzEligibilityOutOfStateIncomeForm
when 'ny'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class EligibilityResidenceController < QuestionsController
include EligibilityOffboardingConcern

def form_class
case params[:us_state]
case current_state_code
when 'az'
StateFile::AzEligibilityResidenceForm
when 'ny'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class LandingPageController < QuestionsController
skip_before_action :redirect_if_in_progress_intakes_ended

def edit
@state_name = StateFileBaseIntake::STATE_CODE_AND_NAMES[params[:us_state]]
@closed = app_time.after?(Rails.configuration.state_file_end_of_in_progress_intakes)
if current_intake.present?
if current_intake.primary_first_name.present?
Expand All @@ -16,10 +15,7 @@ def edit
end

def update
StateFileBaseIntake::STATE_CODES.each do |state_code|
intake = send("current_state_file_#{state_code}_intake")
sign_out intake if intake
end
sign_out current_intake if current_intake
intake = question_navigator.intake_class.new(
visitor_id: cookies.encrypted[:visitor_id],
source: session[:source],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def edit
private

def next_path
options = { us_state: params[:us_state], action: :edit }
options = { us_state: current_state_code, action: :edit }
options[:return_to_review] = params[:return_to_review] if params[:return_to_review].present?
NySchoolDistrictController.to_path_helper(options)
end
Expand Down
34 changes: 6 additions & 28 deletions app/controllers/state_file/questions/questions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ module StateFile
module Questions
class QuestionsController < ::Questions::QuestionsController
include StateFile::StateFileControllerConcern
before_action :redirect_if_no_intake
before_action :redirect_if_in_progress_intakes_ended
before_action :redirect_if_no_intake, :redirect_if_in_progress_intakes_ended
helper_method :card_postscript

# default layout for all state file questions
Expand All @@ -19,36 +18,15 @@ def ip_for_irs

private

def current_intake
state_code = question_navigator.intake_class::STATE_CODE
send("current_state_file_#{state_code}_intake")
end

def question_navigator
@navigator ||= "Navigation::StateFile#{state_code.titleize}QuestionNavigation".constantize
@navigator ||= "Navigation::StateFile#{current_state_code.titleize}QuestionNavigation".constantize
end
helper_method :question_navigator

def state_code
state_code_ = params[:us_state].downcase
unless StateFileBaseIntake::STATE_CODES.include?(state_code_)
raise StandardError, state_code_
end
state_code_
end

def state_name
state_code_ = params[:us_state]
unless StateFileBaseIntake::STATE_CODES.include?(state_code_)
raise StandardError, state_code_
end
States.name_for_key(state_code_.upcase)
end

def redirect_if_no_intake
unless current_intake.present?
flash[:notice] = 'Your session expired. Please sign in again to continue.'
redirect_to StateFile::StateFilePagesController.to_path_helper(action: :login_options, us_state: state_code)
redirect_to StateFile::StateFilePagesController.to_path_helper(action: :login_options, us_state: current_state_code)
end
end

Expand All @@ -57,7 +35,7 @@ def redirect_if_in_progress_intakes_ended
if current_intake.efile_submissions.empty?
redirect_to root_path
else
redirect_to StateFile::Questions::ReturnStatusController.to_path_helper(action: :edit, us_state: state_code)
redirect_to StateFile::Questions::ReturnStatusController.to_path_helper(action: :edit, us_state: current_state_code)
end
end
end
Expand All @@ -68,7 +46,7 @@ def next_step

def next_path
step_for_next_path = next_step
options = { us_state: params[:us_state], action: step_for_next_path.navigation_actions.first }
options = { us_state: current_state_code, action: step_for_next_path.navigation_actions.first }
if step_for_next_path.resource_name.present? && step_for_next_path.resource_name == self.class.resource_name
options[:id] = current_resource.id
end
Expand All @@ -85,7 +63,7 @@ def prev_path

def path_for_step(step)
return unless step
options = { us_state: params[:us_state], action: step.navigation_actions.first }
options = { us_state: current_state_code, action: step.navigation_actions.first }
if step.resource_name
options[:id] = step.model_for_show_check(self)&.id
end
Expand Down
Loading

0 comments on commit 46e3c98

Please sign in to comment.