Skip to content

Commit

Permalink
Api 24834 section 7 service pay validation (#12771)
Browse files Browse the repository at this point in the history
* Incremental commit

* Rubocop fixes

* Test fixes & cleanup

* Disable module length check

* Update context descriptions for updated field names

* Linting fix for quotes

* Remove duplicate module declaration

* Changes for review feedback

* Add generated swagger
  • Loading branch information
mchristiansonVA authored May 31, 2023
1 parent aa6c8d3 commit 6fde0c3
Show file tree
Hide file tree
Showing 5 changed files with 382 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ def validate_form_526_submission_values!
validate_form_526_current_mailing_address_country!
# ensure homeless information is valid
validate_form_526_veteran_homelessness!
# ensure military service pay information is valid
validate_form_526_service_pay!
# ensure treament centers information is valid
validate_form_526_treatments!
# ensure service information is valid
Expand Down Expand Up @@ -119,6 +121,50 @@ def missing_point_of_contact?
homelessness_poc_attr.blank? && (currently_homeless_attr.present? || homelessness_risk_attr.present?)
end

def validate_form_526_service_pay!
validate_form_526_military_retired_pay!
validate_form_526_future_military_retired_pay!
validate_form_526_separation_pay_received_date!
end

def validate_form_526_military_retired_pay!
receiving_attr = form_attributes.dig('servicePay', 'receivingMilitaryRetiredPay')
future_attr = form_attributes.dig('servicePay', 'futureMilitaryRetiredPay')

return if receiving_attr.nil? || future_attr.nil?
return unless receiving_attr == future_attr

# EVSS does not allow both attributes to be the same value (unless that value is nil)
raise ::Common::Exceptions::InvalidFieldValue.new(
'servicePay.militaryRetiredPay',
form_attributes['servicePay']['militaryRetiredPay']
)
end

def validate_form_526_future_military_retired_pay!
future_attr = form_attributes.dig('servicePay', 'futureMilitaryRetiredPay')
future_explanation_attr = form_attributes.dig('servicePay', 'futureMilitaryRetiredPayExplanation')
return if future_attr.nil?

if future_attr == true && future_explanation_attr.blank?
raise ::Common::Exceptions::UnprocessableEntity.new(
detail: "If 'servicePay.futureMilitaryRetiredPay' is true, then " \
"'servicePay.futureMilitaryRetiredPayExplanation' is required"
)
end
end

def validate_form_526_separation_pay_received_date!
separation_pay_received_date = form_attributes.dig('servicePay', 'separationSeverancePay',
'datePaymentReceived')
return if separation_pay_received_date.blank?

return if Date.parse(separation_pay_received_date) < Time.zone.today

raise ::Common::Exceptions::InvalidFieldValue.new('separationSeverancePay.datePaymentReceived',
separation_pay_received_date)
end

def validate_form_526_treatments!
treatments = form_attributes['treatments']
return if treatments.blank?
Expand Down
8 changes: 3 additions & 5 deletions modules/claims_api/app/swagger/claims_api/v2/dev/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -3938,9 +3938,7 @@
"branchOfService": "Army",
"monthlyAmount": 840.75
},
"retiredStatus": [

],
"retiredStatus": "RETIRED",
"receivedSeparationOrSeverancePay": false,
"separationSeverancePay": {
"datePaymentReceived": "2018-07-31",
Expand Down Expand Up @@ -4594,8 +4592,8 @@
"id": "1",
"type": "intent_to_file",
"attributes": {
"creationDate": "2023-05-24",
"expirationDate": "2024-05-24",
"creationDate": "2023-05-26",
"expirationDate": "2024-05-26",
"type": "compensation",
"status": "active"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
"branchOfService": "Army",
"monthlyAmount": 840.75
},
"retiredStatus": [],
"retiredStatus": "RETIRED",
"receivedSeparationOrSeverancePay": false,
"separationSeverancePay": {
"datePaymentReceived": "2018-07-31",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
"retiredStatus": "RETIRED",
"receivedSeparationOrSeverancePay": false,
"separationSeverancePay": {
"datePaymentReceived": "7169-07-31",
"datePaymentReceived": "2022-03-01",
"branchOfService": "Naval Academy",
"preTaxAmountReceived": 379.25
}
Expand Down
Loading

0 comments on commit 6fde0c3

Please sign in to comment.