automate employer setup import from word and manual entry working

This commit is contained in:
Jason Jordan
2025-12-03 11:42:15 -05:00
parent 3fbece7da6
commit 78ce415b94
44 changed files with 1012 additions and 339 deletions
+44 -21
View File
@@ -5,19 +5,33 @@ class EmployerSetupForm
FIRST_STEP = "general_information"
attribute :current_step, :string, default: FIRST_STEP
attribute :general_information_data
attribute :plans_data
attribute :network_exceptions_data
attribute :pl_plan_key, :string
def initialize(params = {})
# if params.present?
# params = permitted_params(params)
# end
super(params)
unless self.steps.first == FIRST_STEP
raise StepMisalignmentError, "FIRST_STEP does not match first entry in steps"
end
@general_information_data = EmployerSetupGeneralInformationForm.new(attributes[:general_information_data])
@plans_data = EmployerSetupPlansForm.new(attributes[:plans_data])
@network_exceptions_data = EmployerSetupNetworkExceptionsForm.new(attributes[:network_exceptions_data])
# @general_information_data = EmployerSetupGeneralInformationForm.new(attributes[:general_information_data])
# @plans_data = EmployerSetupPlansForm.new(attributes[:plans_data])
# @network_exceptions_data = EmployerSetupNetworkExceptionsForm.new(attributes[:network_exceptions_data])
end
# def self.form_session_init
# {
# general_information_data: {},
# plans_data: {},
# network_exceptions_data: {}
# }
# end
# def steps
# %w[general_information plans network_exceptions summary]
# end
def steps
%w[general_information plans network_exceptions summary]
end
@@ -29,11 +43,7 @@ class EmployerSetupForm
def next_step
index = steps.index(current_step)
if index && index < steps.length - 1
if steps[index + 1] == 'network_exceptions' && general_information_data.number_of_additional_network_logos == 0
steps[index + 2]
else
steps[index + 1]
end
steps[index + 1]
end
end
@@ -42,16 +52,29 @@ class EmployerSetupForm
steps[index - 1] if index && index > 0
end
def save
if valid?
pl_plan_key = attributes[:general_information_data][:pl_plan_key]
EmployerSetupGeneralInformationForm.new(attributes[:general_information_data]).save
EmployerSetupPlansForm.new(attributes[:plans_data]).save(pl_plan_key)
EmployerSetupNetworkExceptionsForm.new(attributes[:network_exceptions_data]).save(pl_plan_key)
true
else
false
end
def permitted_params(params)
params.require(:employer_setup_data).permit(
:pl_plan_key,
:current_step
)
end
def self.permitted_params
[
:pl_plan_key,
:current_step
]
end
# def save
# if valid?
# EmployerSetupGeneralInformationForm.new(attributes[:general_information_data]).save
# EmployerSetupPlansForm.new(attributes[:plans_data]).save
# EmployerSetupNetworkExceptionsForm.new(attributes[:network_exceptions_data]).save
# true
# else
# false
# end
# end
end