Skip to content

Commit

Permalink
Fallback to appellant address in VACOLS for LegacyAppeal (#13549)
Browse files Browse the repository at this point in the history
https://dsva.slack.com/archives/CD5DAQNCU/p1582834251001700

### Description

Add fallback to VACOLS for appellant address since BGS doesn't always have data. This tries to preserve populating the address from a consistent source (e.g. calling `claimant[:address]` and `appellant_address` should give you the same thing)

Fixes a regression from: #13411
  • Loading branch information
ferristseng authored Feb 28, 2020
1 parent 970320b commit 0752945
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .reek.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ detectors:
exclude:
- Address
- Fakes::PersistentStore#convert_dates_from
UncommunicativeMethodName:
exclude:
- LegacyAppeal#appellant_address_line_1
- LegacyAppeal#appellant_address_line_2
UncommunicativeParameterName:
exclude:
- Address
Expand Down Expand Up @@ -113,6 +117,7 @@ detectors:
exclude:
- HearingLocation
- JudgeTeam
- LegacyAppeal
- QueueConfig
- RequestIssue
- BulkTaskReassignment
Expand All @@ -135,6 +140,7 @@ detectors:
UtilityFunction:
public_methods_only: true
exclude:
- AddressMapper#get_address_from_veteran_record
- ClaimReviewAsyncStatsReporter#seconds_to_hms
- ETL::Builder#last_built
- ETL::Syncer#filter?
Expand Down
14 changes: 14 additions & 0 deletions app/mappers/address_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@ def get_address_from_corres_entry(corres_entry)
}
end

def get_address_from_veteran_record(veteran)
return nil unless veteran

{
address_line_1: veteran.address_line1,
address_line_2: veteran.address_line2,
address_line_3: veteran.address_line3,
city: veteran.city,
state: veteran.state,
country: veteran.country,
zip: veteran.zip_code
}
end

def get_address_from_rep_entry(rep_entry)
return {} unless rep_entry

Expand Down
46 changes: 39 additions & 7 deletions app/models/legacy_appeal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class LegacyAppeal < ApplicationRecord
include AssociatedVacolsModel
include BgsService
include CachedAttributes
include AddressMapper
include Taskable
include PrintsTaskTree
include HasTaskHistory
Expand Down Expand Up @@ -80,11 +81,6 @@ class UnknownLocationError < StandardError; end
to: :veteran,
allow_nil: true

delegate :address, :address_line_1, :address_line_2, :city, :country, :state, :zip,
to: :bgs_address_service,
prefix: :appellant,
allow_nil: true

cache_attribute :aod do
self.class.repository.aod(vacols_id)
end
Expand Down Expand Up @@ -219,8 +215,42 @@ def cavc_due_date
(decision_date + 120.days).to_date
end

def appellant
claimant
def appellant_address
appellant_address_from_bgs = bgs_address_service&.address

# Attempt to get the address from BGS, or fall back to VACOLS. These are expected
# to have the same hash keys.
if appellant_is_not_veteran
appellant_address_from_bgs || get_address_from_corres_entry(case_record.correspondent)
else
appellant_address_from_bgs ||
get_address_from_veteran_record(veteran) ||
get_address_from_corres_entry(case_record.correspondent)
end
end

def appellant_address_line_1
appellant_address&.[](:address_line_1)
end

def appellant_address_line_2
appellant_address&.[](:address_line_2)
end

def appellant_city
appellant_address&.[](:city)
end

def appellant_country
appellant_address&.[](:country)
end

def appellant_state
appellant_address&.[](:state)
end

def appellant_zip
appellant_address&.[](:zip)
end

def appellant_is_not_veteran
Expand Down Expand Up @@ -366,6 +396,8 @@ def claimant
end
end

alias appellant claimant

# reptype C is a contested claimant
def contested_claimants
vacols_representatives.where(reptype: "C").map(&:as_claimant)
Expand Down

0 comments on commit 0752945

Please sign in to comment.