Skip to content

Commit

Permalink
Api 32103 bdd separation date (#14818)
Browse files Browse the repository at this point in the history
* Add logic to map dateOfReleaseFromActiveDuty

* Add tests for dateOfReleaseFromActiveDuty mapping

* Rubocop fixes

* Update date tests to be dynamic based on test run time

* Appease the rubocop

* Move date variable

* Additional test for nil related attributes
  • Loading branch information
mchristiansonVA authored Dec 11, 2023
1 parent b279292 commit 4a40d6c
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class DisabilityCompensationPdfMapper # rubocop:disable Metrics/ClassLength
4 => :convert_date_string_to_format_yyyy
}.freeze

BDD_LOWER_LIMIT = 90
BDD_UPPER_LIMIT = 180

def initialize(auto_claim, pdf_data, auth_headers, middle_initial, created_at)
@auto_claim = auto_claim
@pdf_data = pdf_data
Expand Down Expand Up @@ -299,6 +302,8 @@ def veteran_info # rubocop:disable Metrics/MethodLength

@pdf_data[:data][:attributes].delete(:veteranIdentification)

date_of_release

@pdf_data
end

Expand Down Expand Up @@ -337,6 +342,25 @@ def zip
@pdf_data
end

def date_of_release
if @pdf_data[:data][:attributes][:claimProcessType] == 'BDD_PROGRAM_CLAIM'
claim_date = Date.parse(@created_at.to_s)
service_information = @auto_claim['serviceInformation']

active_dates = service_information['servicePeriods']&.pluck('activeDutyEndDate')
active_dates << service_information&.dig('federalActivation', 'anticipatedSeparationDate')

end_or_separation_date = active_dates.compact.find do |a|
Date.strptime(a, '%Y-%m-%d').between?(claim_date.next_day(BDD_LOWER_LIMIT),
claim_date.next_day(BDD_UPPER_LIMIT))
end

@pdf_data[:data][:attributes][:identificationInformation][:dateOfReleaseFromActiveDuty] = regex_date_conversion(end_or_separation_date)
end

@pdf_data
end

def disability_attributes
@pdf_data[:data][:attributes][:claimInformation] = {}
@pdf_data[:data][:attributes][:claimInformation].merge!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@
end

describe 'when the claimProcessType is BDD_PROGRAM' do
date = DateTime.now + 4.months
let(:claim_process_type) { 'BDD_PROGRAM' }
let(:anticipated_seperation_date) { date.strftime('%Y-%m-%d') }
let(:active_duty_end_date) { date.strftime('%Y-%m-%d') }

it 'maps correctly to BDD_PROGRAM_CLAIM' do
form_attributes['claimProcessType'] = claim_process_type
Expand All @@ -62,6 +65,42 @@
claim_process_type = pdf_data[:data][:attributes][:claimProcessType]
expect(claim_process_type).to eq('BDD_PROGRAM_CLAIM')
end

it 'maps anticipatedSeparationDate correctly' do
form_attributes['claimProcessType'] = claim_process_type
form_attributes['serviceInformation']['federalActivation']['anticipatedSeparationDate'] =
anticipated_seperation_date
mapper.map_claim

date_of_release_from_active_duty =
pdf_data[:data][:attributes][:identificationInformation][:dateOfReleaseFromActiveDuty]
expect(date_of_release_from_active_duty).to eq({ year: date.strftime('%Y'), month: date.strftime('%m'),
day: date.strftime('%d') })
end

it 'maps activeDutyEndDate correctly' do
form_attributes['claimProcessType'] = claim_process_type
form_attributes['serviceInformation']['servicePeriods'][0]['activeDutyEndDate'] = active_duty_end_date
mapper.map_claim

date_of_release_from_active_duty =
pdf_data[:data][:attributes][:identificationInformation][:dateOfReleaseFromActiveDuty]
expect(date_of_release_from_active_duty).to eq({ year: date.strftime('%Y'), month: date.strftime('%m'),
day: date.strftime('%d') })
end

it 'maps activeDutyEndDate correctly when federalActivation & activeDutyBeginDate are nil' do
form_attributes['claimProcessType'] = claim_process_type
form_attributes['serviceInformation']['federalActivation'] = nil
form_attributes['serviceInformation']['servicePeriods'][0]['activeDutyBeginDate'] = nil
form_attributes['serviceInformation']['servicePeriods'][0]['activeDutyEndDate'] = active_duty_end_date
mapper.map_claim

date_of_release_from_active_duty =
pdf_data[:data][:attributes][:identificationInformation][:dateOfReleaseFromActiveDuty]
expect(date_of_release_from_active_duty).to eq({ year: date.strftime('%Y'), month: date.strftime('%m'),
day: date.strftime('%d') })
end
end
end

Expand Down

0 comments on commit 4a40d6c

Please sign in to comment.