Skip to content

Commit

Permalink
Merge branch 'master' into 103936-evidence-request-friendliness
Browse files Browse the repository at this point in the history
  • Loading branch information
iandonovan authored Mar 5, 2025
2 parents 4b76a8d + 0dd250a commit f29aec7
Show file tree
Hide file tree
Showing 380 changed files with 15,302 additions and 4,354 deletions.
45 changes: 28 additions & 17 deletions .github/CODEOWNERS

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
name: Build and Push
env:
BUNDLE_ENTERPRISE__CONTRIBSYS__COM: ${{ secrets.BUNDLE_ENTERPRISE__CONTRIBSYS__COM }}
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ on:

jobs:
prepare-values:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
outputs:
environments: ${{ steps.set-environments.outputs.environments }}
steps:
Expand All @@ -38,7 +38,7 @@ jobs:
release:
needs: [prepare-values]
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ permissions:
pull-requests: write
jobs:
label:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

steps:
- uses: actions/labeler@v5
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,7 @@ GEM
tzinfo (>= 1.0.0)
uber (0.1.0)
unicode-display_width (2.6.0)
uri (1.0.2)
uri (1.0.3)
useragent (0.16.11)
utf8-cleaner (1.0.0)
activesupport
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/v0/education_benefits_claims_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def stem_claim_status
end

def download_pdf
saved_claim = SavedClaim::EducationBenefits.find(params[:id].to_i)
education_claim = EducationBenefitsClaim.find(params[:id].to_i)
saved_claim = SavedClaim.find(education_claim.saved_claim_id)

source_file_path = PdfFill::Filler.fill_form(
saved_claim,
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/v1/gids/lcpe/exams_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ module GIDS
module LCPE
class ExamsController < GIDS::LCPEController
def index
render json: service.get_exams_v1(scrubbed_params)
exams = service.get_exams_v1(scrubbed_params)
set_etag(exams[:version]) unless bypass_versioning?
render json: exams
end

def show
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/v1/gids/lcpe/lacs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ module GIDS
module LCPE
class LacsController < GIDS::LCPEController
def index
render json: service.get_licenses_and_certs_v1(scrubbed_params)
lacs = service.get_licenses_and_certs_v1(scrubbed_params)
set_etag(lacs[:version]) unless bypass_versioning?
render json: lacs
end

def show
Expand Down
40 changes: 39 additions & 1 deletion app/controllers/v1/gids/lcpe_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,45 @@
# frozen_string_literal: true

require 'gi/lcpe/client'

module V1
module GIDS
class LCPEController < GIDSController; end
class LCPEController < GIDSController
rescue_from LCPERedis::ClientCacheStaleError, with: :version_invalid

private

def service
return super if bypass_versioning?

lcpe_client
end

def lcpe_client
GI::LCPE::Client.new(v_client: preload_version_id, lcpe_type: controller_name)
end

def preload_version_id
preload_version_from_enriched_id || request.headers['If-None-Match']&.to_s
end

# '<record id>@<preload version>'
def preload_version_from_enriched_id
params[:id]&.split('@')&.last
end

def set_etag(version)
response.set_header('ETag', version)
end

# If additional filter params present, bypass versioning
def bypass_versioning?
scrubbed_params.except(:id).present?
end

def version_invalid
render json: { error: 'Version invalid' }, status: :conflict
end
end
end
end
16 changes: 9 additions & 7 deletions app/models/bgs_dependents/adult_child_attending_school.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ class AdultChildAttendingSchool < Base

def initialize(dependents_application)
@dependents_application = dependents_application
@ssn = @dependents_application.dig('student_name_and_ssn', 'ssn')
@full_name = @dependents_application['student_name_and_ssn']['full_name']
@birth_date = @dependents_application.dig('student_name_and_ssn', 'birth_date')
@was_married = @dependents_application['student_address_marriage_tuition']['was_married']
@dependent_income = @dependents_application['student_name_and_ssn']['dependent_income']

@is_v2 = v2?
# with v2 handling, dependents_application is one to many hashes within the student_information array
@source = @is_v2 ? @dependents_application : @dependents_application['student_name_and_ssn']
@ssn = @source['ssn']
@full_name = @source['full_name']
@birth_date = @source['birth_date']
@was_married = @is_v2 ? @source['was_married'] : @dependents_application['student_address_marriage_tuition']['was_married'] # rubocop:disable Layout/LineLength
@dependent_income = @is_v2 ? @source['student_income'] : @source['dependent_income']
self.attributes = described_class_attribute_hash
end

Expand All @@ -55,7 +57,7 @@ def format_info
# @return [Hash] the student's address
#
def address
@dependents_application['student_address_marriage_tuition']['address']
@is_v2 ? @source['address'] : @dependents_application['student_address_marriage_tuition']['address']
end

private
Expand Down
39 changes: 30 additions & 9 deletions app/models/bgs_dependents/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module BGSDependents
class Base < Common::Base
include ActiveModel::Validations
MILITARY_POST_OFFICE_TYPE_CODES = %w[APO DPO FPO].freeze

# Gets the person's address based on the lives with veteran flag
#
# @param dependents_application [Hash] the submitted form information
Expand Down Expand Up @@ -91,7 +92,7 @@ def format_date(date)
def generate_address(address)
# BGS will throw an error if we pass in a military postal code in for state
if MILITARY_POST_OFFICE_TYPE_CODES.include?(address['city'])
address['military_postal_code'] = address.delete('state_code')
address['military_postal_code'] = v2? ? address.delete('state') : address.delete('state_code')
address['military_post_office_type_code'] = address.delete('city')
end

Expand All @@ -105,19 +106,26 @@ def generate_address(address)

# BGS will not accept address lines longer than 20 characters
def adjust_address_lines_for!(address:)
all_lines = "#{address['address_line1']} #{address['address_line2']} #{address['address_line3']}"
all_lines = if v2?
"#{address['street']} #{address['street2']} #{address['street3']}"
else
"#{address['address_line1']} #{address['address_line2']} #{address['address_line3']}"
end
new_lines = all_lines.gsub(/\s+/, ' ').scan(/.{1,19}(?: |$)/).map(&:strip)

address['address_line1'] = new_lines[0]
address['address_line2'] = new_lines[1]
address['address_line3'] = new_lines[2]
end

# rubocop:disable Metrics/MethodLength
# This method converts ISO 3166-1 Alpha-3 country codes to ISO 3166-1 country names.
def adjust_country_name_for!(address:)
return if address['international_postal_code'].blank?
# international postal code is only in v1, return if country is usa in v2
return if address['international_postal_code'].blank? || address['country'] == 'USA'

country_name = address['country_name']
# handle v1 and v2 country naming
country_name = address['country_name'] || address['country']
return if country_name.blank? || country_name.size != 3

# The ISO 3166-1 country name for GBR exceeds BIS's (formerly, BGS) 50 char limit. No other country name exceeds
Expand All @@ -143,9 +151,15 @@ def adjust_country_name_for!(address:)
else
IsoCountryCodes.find(country_name).name
end

address['country'] = address['country_name'] if v2?
address
end
# rubocop:enable Metrics/MethodLength

# rubocop:disable Metrics/MethodLength
def create_address_params(proc_id, participant_id, payload)
is_v2 = v2?
address = generate_address(payload)

{
Expand All @@ -158,21 +172,28 @@ def create_address_params(proc_id, participant_id, payload)
addrs_two_txt: address['address_line2'],
addrs_three_txt: address['address_line3'],
city_nm: address['city'],
cntry_nm: address['country_name'],
postal_cd: address['state_code'],
frgn_postal_cd: address['international_postal_code'],
cntry_nm: is_v2 ? address['country'] : address['country_name'],
postal_cd: is_v2 ? address['state'] : address['state_code'],
frgn_postal_cd: is_v2 ? address['postal_code'] : address['international_postal_code'],
mlty_postal_type_cd: address['military_postal_code'],
mlty_post_office_type_cd: address['military_post_office_type_code'],
zip_prefix_nbr: address['zip_code'],
prvnc_nm: address['state_code'],
zip_prefix_nbr: is_v2 ? address['postal_code'] : address['zip_code'],
prvnc_nm: is_v2 ? address['state'] : address['state_code'],
email_addrs_txt: payload['email_address']
}
end
# rubocop:enable Metrics/MethodLength

def formatted_boolean(bool_attribute)
return nil if bool_attribute.nil?

bool_attribute ? 'Y' : 'N'
end

private

def v2?
Flipper.enabled?(:va_dependents_v2)
end
end
end
26 changes: 18 additions & 8 deletions app/models/bgs_dependents/child.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class Child < Base

def initialize(child_info)
@child_info = child_info
@is_v2 = v2?
self.attributes = child_attributes
end

Expand All @@ -77,33 +78,42 @@ def address(dependents_application)
dependent_address(
dependents_application:,
lives_with_vet: @child_info['does_child_live_with_you'],
alt_address: @child_info.dig('child_address_info', 'address')
alt_address: @is_v2 ? @child_info['address'] : @child_info.dig('child_address_info', 'address')
)
end

private

def child_attributes
place_of_birth = @is_v2 ? @child_info['birth_location'] : @child_info['place_of_birth']
{
ssn: @child_info['ssn'],
birth_date: @child_info['birth_date'],
family_relationship_type: child_status,
place_of_birth_country: @child_info.dig('place_of_birth', 'country'),
place_of_birth_state: @child_info.dig('place_of_birth', 'state'),
place_of_birth_city: @child_info.dig('place_of_birth', 'city'),
reason_marriage_ended: @child_info.dig('previous_marriage_details', 'reason_marriage_ended'),
place_of_birth_country: @is_v2 ? place_of_birth.dig('location', 'country') : place_of_birth['country'],
place_of_birth_state: @is_v2 ? place_of_birth.dig('location', 'state') : place_of_birth['state'],
place_of_birth_city: @is_v2 ? place_of_birth.dig('location', 'city') : place_of_birth['city'],
reason_marriage_ended: @is_v2 ? @child_info['marriage_end_reason'] : @child_info.dig('previous_marriage_details', 'reason_marriage_ended'), # rubocop:disable Layout/LineLength
ever_married_ind: marriage_indicator,
child_income: formatted_boolean(@child_info['child_income']),
child_income: formatted_boolean(@is_v2 ? @child_info['income_in_last_year'] : @child_info['child_income']),
not_self_sufficient: formatted_boolean(@child_info['not_self_sufficient'])
}.merge(@child_info['full_name'])
end

def child_status
CHILD_STATUS[@child_info['child_status']&.key(true)]
if @is_v2
CHILD_STATUS[@child_info['relationship_to_child']&.key(true)]
else
CHILD_STATUS[@child_info['child_status']&.key(true)]
end
end

def marriage_indicator
@child_info['previously_married'] == 'Yes' ? 'Y' : 'N'
if @is_v2
@child_info['has_child_ever_been_married'] ? 'Y' : 'N'
else
@child_info['previously_married'] == 'Yes' ? 'Y' : 'N'
end
end
end
end
45 changes: 43 additions & 2 deletions app/models/bgs_dependents/child_school.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ class ChildSchool < Base
attribute :program_information, Hash
attribute :current_term_dates, Hash

def initialize(dependents_application, proc_id, vnp_participant_id)
def initialize(dependents_application, proc_id, vnp_participant_id, student = nil)
@proc_id = proc_id
@vnp_participant_id = vnp_participant_id
self.attributes = dependents_application
@student = student
@is_v2 = v2?
self.attributes = @is_v2 ? student : dependents_application
end

# rubocop:disable Metrics/MethodLength
Expand Down Expand Up @@ -49,5 +51,44 @@ def params_for_686c
}
end
# rubocop:enable Metrics/MethodLength

# this method is duplicated from the above because each line will be parsed
# differently from v1.
# rubocop:disable Metrics/MethodLength
def params_for_686c_v2
{
vnp_proc_id: @proc_id,
vnp_ptcpnt_id: @vnp_participant_id,
last_term_start_dt: format_date(school_information&.dig('last_term_school_information', 'term_begin')),
last_term_end_dt: format_date(school_information&.dig('last_term_school_information', 'date_term_ended')),
prev_hours_per_wk_num: nil,
prev_sessns_per_wk_num: nil,
prev_school_nm: nil,
prev_school_cntry_nm: nil,
prev_school_addrs_one_txt: nil,
prev_school_addrs_two_txt: nil,
prev_school_addrs_three_txt: nil,
prev_school_city_nm: nil,
prev_school_postal_cd: nil,
prev_school_addrs_zip_nbr: nil,
curnt_school_nm: school_information&.dig('name'),
curnt_school_addrs_one_txt: nil,
curnt_school_addrs_two_txt: nil,
curnt_school_addrs_three_txt: nil,
curnt_school_postal_cd: nil,
curnt_school_city_nm: nil,
curnt_school_addrs_zip_nbr: nil,
curnt_school_cntry_nm: nil,
course_name_txt: nil,
curnt_sessns_per_wk_num: nil,
curnt_hours_per_wk_num: nil,
school_actual_expctd_start_dt: school_information&.dig('current_term_dates', 'expected_student_start_date'),
school_term_start_dt: format_date(school_information&.dig('current_term_dates', 'official_school_start_date')),
gradtn_dt: format_date(school_information&.dig('current_term_dates', 'expected_graduation_date')),
full_time_studnt_type_cd: nil,
part_time_school_subjct_txt: nil
}
end
# rubocop:enable Metrics/MethodLength
end
end
Loading

0 comments on commit f29aec7

Please sign in to comment.