Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
push:
branches:
- 'trunk'
tags:
- 'v*'
pull_request:
branches:
- 'trunk'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ def update_person(person, applicant)
middle_name: applicant.middle_name,
last_name: applicant.last_name,
name_sfx: applicant.name_sfx,
encrypted_ssn: applicant.encrypted_ssn,
no_ssn: applicant.no_ssn,
gender: applicant.gender,
dob: applicant.dob,
Expand All @@ -116,6 +115,12 @@ def update_person(person, applicant)
is_temporarily_out_of_state: applicant.is_temporarily_out_of_state
)

if applicant.encrypted_ssn.blank?
person.unset(:encrypted_ssn)
else
person.encrypted_ssn = applicant.encrypted_ssn
end

Success(person)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="mt-4 mb-4">
<%= v.label :country_of_citizenship, l10n("insured.consumer_roles.docs_shared.country_of_citizenship"), class: "weight-n" %>
<%= v.select :country_of_citizenship,
options_for_select(::VlpDocument::COUNTRIES_LIST, @country ||= l10n("insured.consumer_roles.docs_shared.country_of_citizenship")),
::VlpDocument::COUNTRIES_LIST,
{ prompt: l10n("insured.consumer_roles.docs_shared.country_of_citizenship") },
{ class: "select_tag", id: "country_of_citizenship" } %>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ def call(params)
event = yield build_event(cv3_application)
publish(event)

Success("Successfully published payload for rrv ifsv and created history event | family_eligibility_determination: #{determination_result}")
Success("RRV INCOME: Successfully published payload for rrv ifsv and created history event | family_eligibility_determination: #{determination_result}")
end

private

def validate(params)
return Failure('application_hbx_id is missing') unless params[:application_hbx_id].present?
return Failure('RRV INCOME: application_hbx_id is missing') unless params[:application_hbx_id].present?

Success(params[:application_hbx_id])
end
Expand All @@ -41,17 +41,15 @@ def fetch_application(application_hbx_id)
if application.present?
Success(application)
else
rrv_logger.info("No application found with hbx_id #{application_hbx_id}")
Failure("No application found with hbx_id #{application_hbx_id}")
Failure("RRV INCOME: No application found with hbx_id #{application_hbx_id}")
end
end

def is_application_valid?(application)
if application.valid?
Success(true)
else
rrv_logger.error("Application with hbx_id #{application.hbx_id} is invalid: #{application.errors.full_messages.join(', ')}")
Failure("Application with hbx_id #{application.hbx_id} is invalid")
Failure("RRV INCOME: Application with hbx_id #{application.hbx_id} is invalid")
end
end

Expand All @@ -68,18 +66,21 @@ def transform_and_validate_application(application)
if result.any?(Failure)
errors = result.select { |r| r.is_a?(Failure) }.map(&:failure)
record_application_failure(application, errors)
rrv_logger.error("RRV INCOME: Failed to publish: Applicants validation failed with hbx_id #{application.hbx_id} due to #{errors}")
update_family_determination(application)
return Failure(errors)
else
application.save!
end
else
record_application_failure(application, payload_entity.failure.messages)
rrv_logger.error("RRV INCOME: Failed to publish: Application validation failed with hbx_id #{application.hbx_id} due to #{payload_entity.failure.messages}")
update_family_determination(application)
end

payload_entity
rescue StandardError => e
rrv_logger.error("Failed to transform application with hbx_id #{application.hbx_id} due to #{e.inspect}")
Failure("Failed to transform application with hbx_id #{application.hbx_id} due to #{e.inspect}")
Failure("RRV INCOME: Failed to transform application with hbx_id #{application.hbx_id} due to #{e.inspect}")
end

def validate_applicants(payload_entity)
Expand Down Expand Up @@ -114,11 +115,9 @@ def record_histories(application, action, update_reason, update_by)
end

def update_family_determination(application)
family = application.family
unless family.present?
rrv_logger.error("RRV INCOME: Family not found for application hbx_id: #{application.hbx_id}")
return Failure("RRV INCOME: Family not found for application hbx_id: #{application.hbx_id}")
end
family_id = application.family_id
family = Family.where(id: family_id).first
return Failure("RRV INCOME: Family not found for application hbx_id: #{application.hbx_id}") unless family.present?

if family.latest_application_gid == application.to_global_id&.uri&.to_s
::Operations::Eligibilities::BuildFamilyDetermination.new.call({family: family})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def fetch_application(params)
if application.present?
application.valid? ? Success(application) : Failure("Invalid application: #{params[:application_hbx_id]}")
else
logger.error("No application found with hbx_id #{params[:application_hbx_id]}")
Failure("No application found with hbx_id #{params[:application_hbx_id]}")
end
end
Expand All @@ -52,17 +51,19 @@ def transform_and_validate_application(application)
move_applicant_eligibility_state(application)
save_application(application)
return payload_entity if all_applicants_valid.any?(&:last)
update_family_determination(application)
return Failure("Failed to transform application with hbx_id #{application.hbx_id} due to all applicants are invalid")
elsif payload_entity.failure?
move_applicant_eligibility_state(application)
record_application_failure(application, payload_entity.failure.messages)
move_applicant_eligibility_state(application)
save_application(application)
update_family_determination(application)
return Failure("Failed at validation for application with hbx_id #{application.hbx_id} due to #{payload_entity.failure.messages}")
end

payload_entity
rescue StandardError => e
logger.error("#{process_name} process failed to publish event for the application with hbx_id #{application.hbx_id} due to #{e.inspect}")
Failure("#{process_name} process failed to publish event for the application with hbx_id #{application.hbx_id} due to #{e.inspect}")
Failure("Failed to publish event for the application with hbx_id #{application.hbx_id} due to #{e.inspect}")
end

def move_applicant_eligibility_state(application)
Expand Down Expand Up @@ -157,17 +158,13 @@ def save_application(application)
Success(application)
else
error_msg = "Failed to save application: #{application.errors.full_messages.join(', ')}"
logger.error(error_msg)
Failure(error_msg)
end
end

def update_family_determination(application)
family = application.family
unless family.present?
logger.error("#{process_name} Non ESI: Family not found for application hbx_id: #{application.hbx_id}")
return Failure("#{process_name} Non ESI: Family not found for application hbx_id: #{application.hbx_id}")
end
return Failure("#{process_name} Non ESI: Family not found for application hbx_id: #{application.hbx_id}") unless family.present?

if family.latest_application_gid == application.to_global_id&.uri&.to_s
::Operations::Eligibilities::BuildFamilyDetermination.new.call({family: family})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="mt-4 mb-4">
<%= v.label :country_of_citizenship, l10n("insured.consumer_roles.docs_shared.country_of_citizenship"), class: "weight-n" %>
<%= v.select :country_of_citizenship,
options_for_select(::VlpDocument::COUNTRIES_LIST, @country ||= l10n("insured.consumer_roles.docs_shared.country_of_citizenship")),
::VlpDocument::COUNTRIES_LIST,
{ prompt: l10n("insured.consumer_roles.docs_shared.country_of_citizenship") },
{ class: "select_tag", id: "country_of_citizenship" } %>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,37 @@
let(:person2) { FactoryBot.create(:person, :with_consumer_role, :with_active_consumer_role) }
let(:person3) { FactoryBot.create(:person, :with_consumer_role, :with_active_consumer_role) }
let(:family) { FactoryBot.create(:family, :with_primary_family_member, person: person) }
let!(:system_date) { Date.today }
let!(:application2) do
result = FactoryBot.create(:financial_assistance_application, hbx_id: '300000126', aasm_state: "determined", family_id: family.id, submitted_at: DateTime.new(system_date.year, system_date.month, system_date.day) - 30.minutes)
member = FactoryBot.create(:financial_assistance_applicant,
eligibility_determination_id: nil,
person_hbx_id: person.hbx_id,
is_primary_applicant: true,
first_name: 'esi',
last_name: 'evidence',
ssn: "123456789",
dob: Date.new(1994,11,17),
family_member_id: family.primary_family_member.id,
application: result)
member.build_aptc_eligibilities_evidences
member.build_ivl_eligibility_with_evidences
member.save!
family.assign_latest_application_gid
family.save!
::Operations::Eligibilities::BuildFamilyDetermination.new.call({family: family})

result
end

let(:application) do
FactoryBot.create(
:financial_assistance_application,
family_id: family.id,
aasm_state: 'determined',
assistance_year: TimeKeeper.date_of_record.year,
effective_date: TimeKeeper.date_of_record.beginning_of_year,
created_at: Date.new(2021, 10, 1)
submitted_at: DateTime.new(system_date.year, system_date.month, system_date.day)
)
end

Expand Down Expand Up @@ -122,6 +145,7 @@
end

before do
allow(EnrollRegistry).to receive(:feature_enabled?).with(:qhp_application).and_return(true)
allow(FinancialAssistanceRegistry).to receive(:feature_enabled?).with(:full_medicaid_determination_step).and_return(false)
allow(FinancialAssistanceRegistry).to receive(:feature_enabled?).with(:indian_alaskan_tribe_details).and_return(false)
allow(FinancialAssistanceRegistry).to receive(:feature_enabled?).with(:non_esi_mec_determination).and_return(true)
Expand All @@ -144,6 +168,7 @@
applicant.build_aptc_eligibilities_evidences
end
application.save!
family.update_attributes(latest_application_gid: application.to_global_id.uri.to_s)
end

it 'should return success if application hbx_id is passed' do
Expand Down Expand Up @@ -338,14 +363,9 @@
it 'handles the exception and returns failure' do
result = subject.call({ application_hbx_id: application.hbx_id })
expect(result).to be_failure
expect(result.failure).to include('PVC process failed to publish event')
expect(result.failure).to match(/Failed to publish event for the application/)
expect(result.failure).to include('Unexpected error')
end

it 'logs the error' do
expect_any_instance_of(Logger).to receive(:error).with(/PVC process failed to publish event/)
subject.call({ application_hbx_id: application.hbx_id })
end
end
end
end
Expand Down Expand Up @@ -447,11 +467,6 @@
expect(result).to be_failure
expect(result.failure).to include('Failed to save application: Validation failed: Field is required')
end

it 'logs the error' do
expect(subject.send(:pvc_logger)).to receive(:error).with(/Failed to save application/)
subject.send(:save_application, test_application)
end
end
end
end
Expand Down Expand Up @@ -579,6 +594,11 @@
# Make one applicant valid and one invalid
applicant.update_attributes!(ssn: "123456789")
applicant2.update_attributes!(ssn: nil) # Invalid
application.applicants.each do |applicant|
allow(applicant).to receive(:is_applying_coverage).and_return(true)
applicant.build_aptc_eligibilities_evidences
end
application.save!
end

it 'handles mixed scenarios correctly' do
Expand Down Expand Up @@ -613,7 +633,7 @@
result = subject.call({ application_hbx_id: application.hbx_id })

expect(result).to be_failure
expect(result.failure).to include('PVC process failed to publish event')
expect(result.failure).to match(/Failed to publish event for the application with hbx_id/)
expect(result.failure).to include('Event building failed')

# Since the error occurs during transform_and_validate_application (before evidence creation),
Expand Down
Loading
Loading