Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[API-43688] 526 - Validation for activeDutyEndDate beyond 180 days #20558

Merged
merged 3 commits into from
Feb 3, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@ def validate_form_526_submission_values!
# ensure the 'treatment.endDate' is after the 'treatment.startDate'
# ensure any provided 'treatment.treatedDisabilityNames' match a provided 'disabilities.name'
validate_form_526_treatments!
validate_form_526_direct_depost!
validate_form_526_direct_deposit!
validate_form_526_at_least_one_active_duty_end_date_within_180_days!
end

private

def validate_form_526_current_mailing_address!
validate_form_526_current_mailing_address_country!
end
Expand Down Expand Up @@ -575,7 +578,7 @@ def validate_treatment_center_names!
end
end

def validate_form_526_direct_depost!
def validate_form_526_direct_deposit!
direct_deposit = form_attributes['directDeposit']
return if direct_deposit.blank?

Expand All @@ -587,5 +590,23 @@ def validate_form_526_direct_depost!
)
end
end

def validate_form_526_at_least_one_active_duty_end_date_within_180_days!
service_periods = form_attributes.dig('serviceInformation', 'servicePeriods')

at_least_one_active_duty_end_date_within_180_days = service_periods.any? do |sp|
active_duty_end_date = sp['activeDutyEndDate']
next if active_duty_end_date.blank?

Date.parse(active_duty_end_date) <= 180.days.from_now.end_of_day
end

unless at_least_one_active_duty_end_date_within_180_days
raise ::Common::Exceptions::InvalidFieldValue.new(
'serviceInformation/servicePeriods/activeDutyEndDate',
'At least one active duty end date must be within 180 days from now.'
)
end
end
end
end
6 changes: 3 additions & 3 deletions modules/claims_api/app/swagger/claims_api/v1/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1565,7 +1565,7 @@
"example": "1980-02-05"
},
"activeDutyEndDate": {
"description": "Date Completed Active Duty. If in the future, 'separationLocationCode' is required.",
"description": "Date Completed Active Duty. If in the future, 'separationLocationCode' is required. Cannot be more than 180 days in the future, unless past service is also included.",
"type": "string",
"pattern": "^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$",
"example": "1990-01-02"
Expand Down Expand Up @@ -3429,7 +3429,7 @@
"example": "1980-02-05"
},
"activeDutyEndDate": {
"description": "Date Completed Active Duty. If in the future, 'separationLocationCode' is required.",
"description": "Date Completed Active Duty. If in the future, 'separationLocationCode' is required. Cannot be more than 180 days in the future, unless past service is also included.",
"type": "string",
"pattern": "^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$",
"example": "1990-01-02"
Expand Down Expand Up @@ -5689,7 +5689,7 @@
"example": "1980-02-05"
},
"activeDutyEndDate": {
"description": "Date Completed Active Duty. If in the future, 'separationLocationCode' is required.",
"description": "Date Completed Active Duty. If in the future, 'separationLocationCode' is required. Cannot be more than 180 days in the future, unless past service is also included.",
"type": "string",
"pattern": "^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$",
"example": "1990-01-02"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1646,7 +1646,7 @@
"example": "2018-06-06"
},
"activeDutyEndDate": {
"description": "Date completed active duty.",
"description": "Date Completed Active Duty. If in the future, 'separationLocationCode' is required. Cannot be more than 180 days in the future, unless past service is also included.",
"type": "string",
"pattern": "^(?:[0-9]{4})-(?:0[1-9]|1[0-2])-(?:0[1-9]|[1-2][0-9]|3[0-1])$",
"example": "2018-06-06"
Expand Down Expand Up @@ -3030,7 +3030,7 @@
"example": "2018-06-06"
},
"activeDutyEndDate": {
"description": "Date completed active duty.",
"description": "Date Completed Active Duty. If in the future, 'separationLocationCode' is required. Cannot be more than 180 days in the future, unless past service is also included.",
"type": "string",
"pattern": "^(?:[0-9]{4})-(?:0[1-9]|1[0-2])-(?:0[1-9]|[1-2][0-9]|3[0-1])$",
"example": "2018-06-06"
Expand Down Expand Up @@ -5184,7 +5184,7 @@
"example": "2018-06-06"
},
"activeDutyEndDate": {
"description": "Date completed active duty.",
"description": "Date Completed Active Duty. If in the future, 'separationLocationCode' is required. Cannot be more than 180 days in the future, unless past service is also included.",
"type": "string",
"pattern": "^(?:[0-9]{4})-(?:0[1-9]|1[0-2])-(?:0[1-9]|[1-2][0-9]|3[0-1])$",
"example": "2018-06-06"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1646,7 +1646,7 @@
"example": "2018-06-06"
},
"activeDutyEndDate": {
"description": "Date completed active duty.",
"description": "Date Completed Active Duty. If in the future, 'separationLocationCode' is required. Cannot be more than 180 days in the future, unless past service is also included.",
"type": "string",
"pattern": "^(?:[0-9]{4})-(?:0[1-9]|1[0-2])-(?:0[1-9]|[1-2][0-9]|3[0-1])$",
"example": "2018-06-06"
Expand Down Expand Up @@ -3030,7 +3030,7 @@
"example": "2018-06-06"
},
"activeDutyEndDate": {
"description": "Date completed active duty.",
"description": "Date Completed Active Duty. If in the future, 'separationLocationCode' is required. Cannot be more than 180 days in the future, unless past service is also included.",
"type": "string",
"pattern": "^(?:[0-9]{4})-(?:0[1-9]|1[0-2])-(?:0[1-9]|[1-2][0-9]|3[0-1])$",
"example": "2018-06-06"
Expand Down Expand Up @@ -5184,7 +5184,7 @@
"example": "2018-06-06"
},
"activeDutyEndDate": {
"description": "Date completed active duty.",
"description": "Date Completed Active Duty. If in the future, 'separationLocationCode' is required. Cannot be more than 180 days in the future, unless past service is also included.",
"type": "string",
"pattern": "^(?:[0-9]{4})-(?:0[1-9]|1[0-2])-(?:0[1-9]|[1-2][0-9]|3[0-1])$",
"example": "2018-06-06"
Expand Down
2 changes: 1 addition & 1 deletion modules/claims_api/config/schemas/v1/526.json
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@
"example": "1980-02-05"
},
"activeDutyEndDate": {
"description": "Date Completed Active Duty. If in the future, 'separationLocationCode' is required.",
"description": "Date Completed Active Duty. If in the future, 'separationLocationCode' is required. Cannot be more than 180 days in the future, unless past service is also included.",
"type": "string",
"pattern": "^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$",
"example": "1990-01-02"
Expand Down
2 changes: 1 addition & 1 deletion modules/claims_api/config/schemas/v2/526.json
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@
"example": "2018-06-06"
},
"activeDutyEndDate": {
"description": "Date completed active duty.",
"description": "Date Completed Active Duty. If in the future, 'separationLocationCode' is required. Cannot be more than 180 days in the future, unless past service is also included.",
"type": "string",
"pattern": "^(?:[0-9]{4})-(?:0[1-9]|1[0-2])-(?:0[1-9]|[1-2][0-9]|3[0-1])$",
"example": "2018-06-06"
Expand Down
83 changes: 83 additions & 0 deletions modules/claims_api/spec/requests/v1/forms/526_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,89 @@
end
end

describe 'activeDutyEndDate within 180 days' do
let(:json_data) { JSON.parse data }

before do
allow_any_instance_of(ClaimsApi::DisabilityCompensationValidations)
.to receive(:validate_form_526_location_codes!).and_return(nil)
allow_any_instance_of(ClaimsApi::DisabilityCompensationValidations)
.to receive(:validate_form_526_current_mailing_address!).and_return(nil)
end

context 'when activeDutyEndDate is beyond 180 days from now' do
let(:service_periods) do
[
{
'activeDutyBeginDate' => 4.years.ago.to_date.to_s,
'activeDutyEndDate' => 181.days.from_now.to_date.to_s,
'serviceBranch' => 'Navy'
}
]
end

it 'returns a bad request response' do
mock_acg(scopes) do |auth_header|
VCR.use_cassette('claims_api/bgs/claims/claims') do
par = json_data
par['data']['attributes']['serviceInformation']['servicePeriods'] = service_periods

post path, params: par.to_json, headers: headers.merge(auth_header)
expect(response).to have_http_status(:bad_request)
end
end
end
end

context 'when activeDutyEndDate is exactly 180 days from now' do
let(:service_periods) do
[
{
'activeDutyBeginDate' => 4.years.ago.to_date.to_s,
'activeDutyEndDate' => 180.days.from_now.to_date.to_s,
'serviceBranch' => 'Navy'
}
]
end

it 'returns a successful response' do
mock_acg(scopes) do |auth_header|
VCR.use_cassette('claims_api/bgs/claims/claims') do
par = json_data
par['data']['attributes']['serviceInformation']['servicePeriods'] = service_periods

post path, params: par.to_json, headers: headers.merge(auth_header)
expect(response).to have_http_status(:ok)
end
end
end
end

context 'when activeDutyEndDate is less than 180 days from now' do
let(:service_periods) do
[
{
'activeDutyBeginDate' => 4.years.ago.to_date.to_s,
'activeDutyEndDate' => 179.days.from_now.to_date.to_s,
'serviceBranch' => 'Navy'
}
]
end

it 'returns a successful response' do
mock_acg(scopes) do |auth_header|
VCR.use_cassette('claims_api/bgs/claims/claims') do
par = json_data
par['data']['attributes']['serviceInformation']['servicePeriods'] = service_periods

post path, params: par.to_json, headers: headers.merge(auth_header)
expect(response).to have_http_status(:ok)
end
end
end
end
end

# lines 89-92 in disability_compensation_validations.rb checks phone number for dash
context 'when reservesNationalGuardService information is submitted' do
let(:json_data) { JSON.parse data }
Expand Down
Loading