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 42951 poa v2 zip code updates #19665

Merged
merged 11 commits into from
Dec 4, 2024
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def shared_form_validation(form_number)
poa_code = form_attributes.dig(base, 'poaCode')

@claims_api_forms_validation_errors = validate_form_2122_and_2122a_submission_values(
user_profile:, veteran_participant_id: target_veteran.participant_id, poa_code:, base:
user_profile:, veteran_participant_id: target_veteran.participant_id, poa_code:,
base:
)

validate_json_schema(form_number.upcase)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ module V2
module PowerOfAttorneyValidation
include ClaimsApi::DependentClaimantValidation

def validate_form_2122_and_2122a_submission_values(user_profile:, veteran_participant_id: nil, poa_code: nil,
base: nil)
def validate_form_2122_and_2122a_submission_values(user_profile:, veteran_participant_id: nil,
poa_code: nil, base: nil)
validate_non_claimant_address_values
validate_claimant_fields(user_profile)
if [veteran_participant_id, user_profile, poa_code, base].all?(&:present?)
validate_dependent_claimant(veteran_participant_id:, user_profile:, poa_code:, base:)
Expand Down Expand Up @@ -40,6 +41,16 @@ def build_dependent_claimant_verification_service(veteran_participant_id:, user_
poa_code:)
end

# the Claimant object is already being validatated below,
# so that code has been adjusted and it is being left out of this workflow
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldnʼt need the comment now that the method name is self-descriptive.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, yep cabc789

def validate_non_claimant_address_values
%w[veteran representative].each do |base|
address = form_attributes.dig(base, 'address')

validate_address_zip_code(address, base) if address.present?
end
end

def validate_claimant(service:, base:)
validate_poa_code(service:, base:)
validate_dependent(service:)
Expand Down Expand Up @@ -78,14 +89,15 @@ def validate_address
collect_error_messages(
source: '/claimant/address/',
detail: "If claimant is present 'address' must be filled in " \
'with required fields addressLine1, city, stateCode, countryCode and zipCode'
"with required fields addressLine1, city, stateCode and countryCode. If the countryCode is 'US' " \
'then zipCode is also required.'
)
else
validate_address_line_one(address)
validate_address_city(address)
validate_address_state_code(address)
validate_address_country_code(address)
validate_address_zip_code(address)
validate_address_zip_code(address, 'claimant')
end
end

Expand Down Expand Up @@ -125,11 +137,14 @@ def validate_address_country_code(address)
end
end

def validate_address_zip_code(address)
if address['zipCode'].nil?
def validate_address_zip_code(address, base)
country = address['countryCode']&.downcase
return unless country == 'us'

if address['zipCode'].blank?
collect_error_messages(
source: '/claimant/address/zipCode',
detail: "If claimant is present 'zipCode' must be filled in"
source: "/#{base}/address/zipCode",
detail: "If 'countryCode' is 'US' then 'zipCode' is required."
)
end
end
Expand Down Expand Up @@ -175,7 +190,7 @@ def collect_error_messages(detail: 'Missing or invalid attribute', source: '/',
end

def raise_error_collection
errors_array.uniq! { |e| e[:detail] }
errors_array.uniq! { |e| [e[:source], e[:detail]] }
errors_array
end
end
Expand Down
62 changes: 29 additions & 33 deletions modules/claims_api/app/swagger/claims_api/v2/dev/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -4394,7 +4394,7 @@
"202 without a transactionId": {
"value": {
"data": {
"id": "1c4b30a7-520b-4eb4-b9de-ab1a26ee24d4",
"id": "2dd4c099-b700-471b-b4a5-578b55234a2f",
"type": "forms/526",
"attributes": {
"claimId": "600442191",
Expand Down Expand Up @@ -4579,7 +4579,7 @@
},
"federalActivation": {
"activationDate": "2023-10-01",
"anticipatedSeparationDate": "2024-12-04"
"anticipatedSeparationDate": "2024-12-06"
},
"confinements": [
{
Expand Down Expand Up @@ -4625,7 +4625,7 @@
"202 with a transactionId": {
"value": {
"data": {
"id": "c4b3e30b-6c8a-459e-9e77-c5e2c413c18f",
"id": "8088708b-f0a2-43d3-8bca-6432c8b24b89",
"type": "forms/526",
"attributes": {
"claimId": "600442191",
Expand Down Expand Up @@ -4789,7 +4789,7 @@
"serviceBranch": "Public Health Service",
"serviceComponent": "Active",
"activeDutyBeginDate": "2008-11-14",
"activeDutyEndDate": "2024-12-04",
"activeDutyEndDate": "2024-12-06",
"separationLocationCode": "98282"
}
],
Expand All @@ -4810,7 +4810,7 @@
},
"federalActivation": {
"activationDate": "2023-10-01",
"anticipatedSeparationDate": "2024-12-04"
"anticipatedSeparationDate": "2024-12-06"
},
"confinements": [
{
Expand Down Expand Up @@ -8053,7 +8053,7 @@
"serviceBranch": "Public Health Service",
"serviceComponent": "Active",
"activeDutyBeginDate": "2008-11-14",
"activeDutyEndDate": "2024-12-04",
"activeDutyEndDate": "2024-12-06",
"separationLocationCode": "98282"
}
],
Expand All @@ -8074,7 +8074,7 @@
},
"federalActivation": {
"activationDate": "2023-10-01",
"anticipatedSeparationDate": "2024-12-04"
"anticipatedSeparationDate": "2024-12-06"
},
"confinements": [
{
Expand Down Expand Up @@ -9838,7 +9838,7 @@
"application/json": {
"example": {
"data": {
"id": "c7bf5f3c-1781-44ae-af52-7ea31d970238",
"id": "cd3552a2-7300-4902-81a9-0814b4f65127",
"type": "forms/526",
"attributes": {
"claimProcessType": "STANDARD_CLAIM_PROCESS",
Expand Down Expand Up @@ -13580,8 +13580,8 @@
"id": "1",
"type": "intent_to_file",
"attributes": {
"creationDate": "2024-12-02",
"expirationDate": "2025-12-02",
"creationDate": "2024-12-04",
"expirationDate": "2025-12-04",
"type": "compensation",
"status": "active"
}
Expand Down Expand Up @@ -14378,7 +14378,7 @@
"status": "422",
"detail": "Could not retrieve Power of Attorney due to multiple representatives with code: A1Q",
"source": {
"pointer": "/modules/claims_api/app/controllers/claims_api/v2/veterans/power_of_attorney/base_controller.rb:165:in `representative'"
"pointer": "/modules/claims_api/app/controllers/claims_api/v2/veterans/power_of_attorney/base_controller.rb:166:in `representative'"
}
}
]
Expand Down Expand Up @@ -14477,7 +14477,7 @@
"application/json": {
"example": {
"data": {
"id": "a9fbe587-d95a-46b8-b1a6-65262ed11e91",
"id": "89beb6db-e4ed-43e9-baa8-a3157a1788a7",
"type": "individual",
"attributes": {
"code": "067",
Expand Down Expand Up @@ -14792,8 +14792,7 @@
"addressLine1",
"city",
"stateCode",
"countryCode",
"zipCode"
"countryCode"
],
"properties": {
"addressLine1": {
Expand Down Expand Up @@ -14825,7 +14824,7 @@
"example": "US"
},
"zipCode": {
"description": "Zipcode (First 5 digits) of the address.",
"description": "Zip code (First 5 digits) of the address. Required if 'countryCode' is 'US'.",
"type": "string",
"pattern": "^\\d{5}?$",
"example": "12345"
Expand Down Expand Up @@ -14920,7 +14919,7 @@
"example": "USA"
},
"zipCode": {
"description": "Zipcode (First 5 digits) of the address. Required if claimant information provided.",
"description": "Zip code (First 5 digits) of the address. Required if 'countryCode' is 'US'.",
"type": "string",
"pattern": "^\\d{5}?$",
"example": "12345"
Expand Down Expand Up @@ -15040,7 +15039,7 @@
"example": "US"
},
"zipCode": {
"description": "Zipcode (First 5 digits) of the address.",
"description": "Zip code (First 5 digits) of the address. Required if 'countryCode' is 'US'.",
"type": "string",
"pattern": "^\\d{5}?$",
"example": "12345"
Expand Down Expand Up @@ -15252,7 +15251,7 @@
"application/json": {
"example": {
"data": {
"id": "d57d6212-a5ec-4564-9acf-488a64a4496a",
"id": "005a7686-e6a3-4644-b9c0-b7894a53d65e",
"type": "organization",
"attributes": {
"code": "083",
Expand Down Expand Up @@ -15549,9 +15548,8 @@
"required": [
"addressLine1",
"city",
"countryCode",
"stateCode",
"zipCode"
"countryCode"
],
"properties": {
"addressLine1": {
Expand Down Expand Up @@ -15583,7 +15581,7 @@
"example": "US"
},
"zipCode": {
"description": "Zipcode (First 5 digits) of the address.",
"description": "Zip code (First 5 digits) of the address. Required if 'countryCode' is 'US'.",
"type": "string",
"pattern": "^\\d{5}?$",
"example": "12345"
Expand Down Expand Up @@ -15689,7 +15687,7 @@
"example": "US"
},
"zipCode": {
"description": "Zipcode (First 5 digits) of the address. Required if claimant information provided.",
"description": "Zip code (First 5 digits) of the address. Required if 'countryCode' is 'US'.",
"type": "string",
"pattern": "^\\d{5}?$",
"example": "12345"
Expand Down Expand Up @@ -16243,8 +16241,7 @@
"addressLine1",
"city",
"stateCode",
"countryCode",
"zipCode"
"countryCode"
],
"properties": {
"addressLine1": {
Expand Down Expand Up @@ -16276,7 +16273,7 @@
"example": "US"
},
"zipCode": {
"description": "Zipcode (First 5 digits) of the address.",
"description": "Zip code (First 5 digits) of the address. Required if 'countryCode' is 'US'.",
"type": "string",
"pattern": "^\\d{5}?$",
"example": "12345"
Expand Down Expand Up @@ -16371,7 +16368,7 @@
"example": "USA"
},
"zipCode": {
"description": "Zipcode (First 5 digits) of the address. Required if claimant information provided.",
"description": "Zip code (First 5 digits) of the address. Required if 'countryCode' is 'US'.",
"type": "string",
"pattern": "^\\d{5}?$",
"example": "12345"
Expand Down Expand Up @@ -16491,7 +16488,7 @@
"example": "US"
},
"zipCode": {
"description": "Zipcode (First 5 digits) of the address.",
"description": "Zip code (First 5 digits) of the address. Required if 'countryCode' is 'US'.",
"type": "string",
"pattern": "^\\d{5}?$",
"example": "12345"
Expand Down Expand Up @@ -16912,9 +16909,8 @@
"required": [
"addressLine1",
"city",
"countryCode",
"stateCode",
"zipCode"
"countryCode"
],
"properties": {
"addressLine1": {
Expand Down Expand Up @@ -16946,7 +16942,7 @@
"example": "US"
},
"zipCode": {
"description": "Zipcode (First 5 digits) of the address.",
"description": "Zip code (First 5 digits) of the address. Required if 'countryCode' is 'US'.",
"type": "string",
"pattern": "^\\d{5}?$",
"example": "12345"
Expand Down Expand Up @@ -17052,7 +17048,7 @@
"example": "US"
},
"zipCode": {
"description": "Zipcode (First 5 digits) of the address. Required if claimant information provided.",
"description": "Zip code (First 5 digits) of the address. Required if 'countryCode' is 'US'.",
"type": "string",
"pattern": "^\\d{5}?$",
"example": "12345"
Expand Down Expand Up @@ -17255,10 +17251,10 @@
"application/json": {
"example": {
"data": {
"id": "4ec954c8-b02c-4bc8-8d80-2ec540f966a6",
"id": "2c6ffced-a984-4521-8a2c-72de8d057362",
"type": "claimsApiPowerOfAttorneys",
"attributes": {
"dateRequestAccepted": "2024-12-02",
"dateRequestAccepted": "2024-12-04",
"previousPoa": null,
"representative": {
"serviceOrganization": {
Expand Down
Loading
Loading