Skip to content

Commit

Permalink
Merge branch 'master' into dbx-82245/implement-backup-submission-lh-a…
Browse files Browse the repository at this point in the history
…pi-factory
  • Loading branch information
tblackwe authored Jun 13, 2024
2 parents 560bc3c + c7983bc commit a727b5c
Show file tree
Hide file tree
Showing 31 changed files with 445 additions and 168 deletions.
5 changes: 5 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,7 @@ spec/factories/appeal_submission_uploads.rb @department-of-veterans-affairs/vfs-
spec/factories/ask.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/factories/async_transactions.rb @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/factories/attachments.rb @department-of-veterans-affairs/vfs-mhv-secure-messaging @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/factories/backend_statuses.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/factories/bank_name.rb @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/factories/burial_claim.rb @department-of-veterans-affairs/mbs-core-team @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/factories/caregivers_assistance_claim.rb @department-of-veterans-affairs/vfs-10-10 @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
Expand Down Expand Up @@ -1652,6 +1653,10 @@ spec/routing/v0/map_services_routing_spec.rb @department-of-veterans-affairs/oct
spec/rswag_override.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/serializers/appointment_serializer_spec.rb @department-of-veterans-affairs/vfs-vaos @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/serializers/async_transaction/base_serializer_spec.rb @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/serializers/attachment_serializer_spec.rb @department-of-veterans-affairs/vfs-10-10 @department-of-veterans-affairs/backend-review-group @department-of-veterans-affairs/va-api-engineers
spec/serializers/backend_status_serializer_spec.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/serializers/backend_statuses_serializer_spec.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/serializers/category_serializer_spec.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/serializers/cemetery_serializer_spec.rb @department-of-veterans-affairs/mbs-core-team @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/serializers/dependents_verifications_serializer_spec.rb @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/serializers/education_benefits_claim_serializer_spec.rb @department-of-veterans-affairs/my-education-benefits @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
Expand Down
4 changes: 4 additions & 0 deletions app/controllers/v0/benefits_claims_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ def show
claim_type_code: claim_info['claimTypeCode'],
num_contentions: claim_info['contentions'].count,
ep_code: claim_info['endProductCode'],
current_phase_back: claim_info['claimPhaseDates']['currentPhaseBack'],
latest_phase_type: claim_info['claimPhaseDates']['latestPhaseType'],
decision_letter_sent: claim_info['decisionLetterSent'],
development_letter_sent: claim_info['developmentLetterSent'],
claim_id: params[:id] })
log_evidence_requests(params[:id], claim_info)

Expand Down
58 changes: 30 additions & 28 deletions app/models/form526_submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -477,30 +477,21 @@ def format_creation_time_for_mailers
# NOTE: This is a synchronous access to an external API
# so should not be used within a request/response workflow.
#

def form_content_valid?
begin
transform_service = EVSS::DisabilityCompensationForm::Form526ToLighthouseTransform.new
body = transform_service.transform(form['form526'])

@lighthouse_validation_response = lighthouse_service.validate526(body)
rescue => e
errors = e.errors if e.respond_to?(:errors)
detail = errors&.dig(0, :detail)
status = errors&.dig(0, :status)

if detail
match_data = detail.match(/"description"=>"([^"]+)"/)
description = match_data ? match_data[1] : nil
end

error_msg = "#{description || e} -- #{e.backtrace[0]}"
mock_lighthouse_response(status:, error: error_msg)
return false
end
transform_service = EVSS::DisabilityCompensationForm::Form526ToLighthouseTransform.new
body = transform_service.transform(form['form526'])

return true if lighthouse_validation_response&.status == 200
@lighthouse_validation_response = lighthouse_service.validate526(body)

mock_lighthouse_response(status: lighthouse_validation_response&.status)
if lighthouse_validation_response&.status == 200
true
else
mock_lighthouse_response(status: lighthouse_validation_response&.status)
false
end
rescue => e
handle_validation_error(e)
false
end

Expand Down Expand Up @@ -537,14 +528,25 @@ def lighthouse_service
BenefitsClaims::Service.new(user_account.icn)
end

def handle_validation_error(e)
errors = e.errors if e.respond_to?(:errors)
detail = errors&.dig(0, :detail)
status = errors&.dig(0, :status)
error_msg = "#{detail || e} -- #{e.backtrace[0]}"
mock_lighthouse_response(status:, error: error_msg)
end

def mock_lighthouse_response(status:, error: 'Unknown')
mock_response = Struct.new(:status, :body).new(609, nil)
mock_response.status = status if status
mock_response.body = { 'errors' => [
{
'title' => "Response Status Code '#{status}' - #{error}"
}
] }
response_struct = Struct.new(:status, :body)
mock_response = response_struct.new(status || 609, nil)

mock_response.body = {
'errors' => [
{
'title' => "Response Status Code '#{mock_response.status}' - #{error}"
}
]
}

@lighthouse_validation_response = mock_response
end
Expand Down
10 changes: 0 additions & 10 deletions app/serializers/address_serializer.rb

This file was deleted.

11 changes: 0 additions & 11 deletions app/serializers/appeal_serializer.rb

This file was deleted.

9 changes: 0 additions & 9 deletions app/serializers/countries_serializer.rb

This file was deleted.

9 changes: 0 additions & 9 deletions app/serializers/states_serializer.rb

This file was deleted.

1 change: 1 addition & 0 deletions lib/pagerduty/external_services/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'common/models/attribute_types/iso8601_time'
require 'pagerduty/response'
require 'pagerduty/models/service'
require_relative 'service'

module PagerDuty
module ExternalServices
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ module DebtsApi
module V0
module FsrFormTransform
class DiscretionaryIncomeCalculator
include ::FsrFormTransform::Utils

def initialize(form)
@form = form
income_calculator = DebtsApi::V0::FsrFormTransform::IncomeCalculator.new(form)
Expand Down Expand Up @@ -35,16 +37,6 @@ def amount_can_be_paid_toward_debt

format_number(amount_paid)
end

def str_to_num(str)
return 0 unless str.instance_of?(String)

str.gsub(/[^0-9.-]/, '').to_i || 0
end

def format_number(number)
format('%.2f', number).to_s
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ module DebtsApi
module V0
module FsrFormTransform
class InstallmentContractsOtherDebtsCalculator
include ::FsrFormTransform::Utils

def initialize(form)
@form = form
end
Expand Down Expand Up @@ -82,23 +84,6 @@ def format_installment_debt_number(number)
number
end
end

def str_to_num(str)
return str if str.is_a? Numeric
return 0 unless str.instance_of?(String)

str.gsub(/[^0-9.-]/, '').to_i || 0
end

def sanitize_date_string(date)
return '' if date.empty?

date_string = date.gsub('XX', '01')
date_string << '-01' if date_string.split('-').length == 2
year, month = date_string.split('-')
month = "0#{month}" if month.length == 1
"#{month}/#{year}"
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ module DebtsApi
module V0
module FsrFormTransform
class PersonalDataCalculator
include ::FsrFormTransform::Utils

def initialize(form)
@form = form
@personal_data = form['personal_data']
Expand Down Expand Up @@ -109,16 +111,6 @@ def dependents_ages
end
end

def sanitize_date_string(date)
return '' if date.empty?

date_string = date.gsub('XX', '01')
date_string << '-01' if date_string.split('-').length == 2
year, month = date_string.split('-')
month = "0#{month}" if month.length == 1
"#{month}/#{year}"
end

def married?
@form['questions']['is_married']
end
Expand Down
21 changes: 21 additions & 0 deletions modules/debts_api/lib/debts_api/v0/fsr_form_transform/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,26 @@ def re_camel_hash(x)
end
result
end

def sanitize_date_string(date)
return '' if date.empty?

date_string = date.gsub('XX', '01')
date_string << '-01' if date_string.split('-').length == 2
year, month = date_string.split('-')
month = "0#{month}" if month.length == 1
"#{month}/#{year}"
end

def str_to_num(str)
return str if str.is_a? Numeric
return 0 unless str.instance_of?(String)

str.gsub(/[^0-9.-]/, '').to_i || 0
end

def format_number(number)
format('%.2f', number).to_s
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@

module Vye
module NeedsEnrollmentVerification
def enrollments
return [] if queued_verifications?
return @enrollments if defined?(@enrollments)

setup
awards.each do |award|
@award = award

eval_case_eom
flag_open_cert || eval_case1a || eval_case1b || eval_case2 || eval_case3
eval_case4 || eval_case5
eval_case6 || eval_case7 || eval_case8
eval_case9
end

@enrollments
end

alias pending_verifications enrollments

private

attr_accessor :award
Expand Down Expand Up @@ -297,27 +317,5 @@ def eval_case9

true
end

public

def enrollments
return [] if queued_verifications?
return @enrollments if defined?(@enrollments)

setup
awards.each do |award|
@award = award

eval_case_eom
flag_open_cert || eval_case1a || eval_case1b || eval_case2 || eval_case3
eval_case4 || eval_case5
eval_case6 || eval_case7 || eval_case8
eval_case9
end

@enrollments
end

alias pending_verifications enrollments
end
end
2 changes: 2 additions & 0 deletions modules/vye/spec/factories/vye/address_changes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

FactoryBot.define do
factory :vye_address_change, class: 'Vye::AddressChange' do
association :user_info, factory: :vye_user_info
veteran_name { Faker::Name.name }
address1 { Faker::Address.street_address }
city { Faker::Address.city }
Expand All @@ -11,6 +12,7 @@
end

factory :vye_address_backend, class: 'Vye::AddressChange' do
association :user_info, factory: :vye_user_info
veteran_name { Faker::Name.name }
address1 { Faker::Address.street_address }
city { Faker::Address.city }
Expand Down
4 changes: 4 additions & 0 deletions modules/vye/spec/factories/vye/user_infos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,9 @@
payment_amt { Faker::Number.decimal(l_digits: 4, r_digits: 2) }
indicator { 'A' }
bdn_clone_active { true }

after(:create) do |user_info|
create_list(:vye_address_change, 3, user_info:)
end
end
end
4 changes: 4 additions & 0 deletions modules/vye/spec/factories/vye/user_profiles.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@
ssn { (1..9).map(&digit).join }
file_number { (1..9).map(&digit).join }
icn { SecureRandom.uuid }

after(:create) do |user_profile|
create_list(:vye_pending_document, 3, user_profile:)
end
end
end
2 changes: 1 addition & 1 deletion modules/vye/spec/factories/vye/verifications.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
association :award, factory: :vye_award

transact_date { Time.zone.now }
source_ind { Vye::Verification.source_inds.values.sample }
source_ind { 'web' }
end
end
Loading

0 comments on commit a727b5c

Please sign in to comment.