Skip to content

Commit

Permalink
Api 24835 526 v2 section 8 direct deposit information validation (#12818
Browse files Browse the repository at this point in the history
)

* RSpec stes written and validation methods added, waiting on some feedback on questions to continue

* Updates schema for discussion in stand up

* Updates and validation, leaving in place until standup discussion

* Adds direct deposit validation - section 8
API-24835
* Adds validataion for direct deposit elements
* Updates 526.json schema file and related files to ensure correct validations
* Updates rswag docs with update schema
* Adds RSpec tests for validations
Changes to be committed:
	modified:   modules/claims_api/app/controllers/concerns/claims_api/v2/disability_compensation_validation.rb
	modified:   modules/claims_api/app/swagger/claims_api/v2/dev/swagger.json
	modified:   modules/claims_api/config/schemas/v2/526.json
	modified:   modules/claims_api/config/schemas/v2/request_bodies/disability_compensation/example.json
	modified:   modules/claims_api/config/schemas/v2/request_bodies/disability_compensation/request.json
	modified:   modules/claims_api/spec/fixtures/v2/veterans/disability_compensation/form_526_json_api.json
	modified:   modules/claims_api/spec/requests/v2/veterans/disability_compensation_request_spec.rb
	modified:   spec/support/schemas/claims_api/v2/forms/disability/submission.json

* Fixing my Gemfile.lock include

* Rollbacks incorrect inclusions when fixing merge conflict

* Merges master, tests running green, ran swager compile

* Refactors validation file, strengthens tests up

* Fixes strings being passed into the error raised

* Updates test value so it matches a valid account number

* Fixes account number REGEX after latest merge test was red, tests green and in original state,updates swagger and all related json files

* Refactoring in validation file to make check more rebust and give better name to deposit error method
  • Loading branch information
rockwellwindsor-va authored Jun 5, 2023
1 parent ff9a784 commit 3220939
Show file tree
Hide file tree
Showing 9 changed files with 552 additions and 120 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ def validate_form_526_submission_values!
validate_form_526_treatments!
# ensure service information is valid
validate_form_526_service_information!
# ensure direct deposit information is valid
validate_form_526_direct_deposit!
end

def validate_form_526_change_of_address!
Expand Down Expand Up @@ -527,6 +529,53 @@ def validate_reserves_tos_dates!
)
end
end

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

account_check = direct_deposit&.dig('noAccount')

account_check.present? && account_check == true ? validate_no_account! : validate_account_values!
end

def validate_no_account!
acc_vals = form_attributes['directDeposit']

raise_exception_on_invalid_account_values('account type') if acc_vals['accountType'].present?
raise_exception_on_invalid_account_values('account number') if acc_vals['accountNumber'].present?
raise_exception_on_invalid_account_values('routing number') if acc_vals['routingNumber'].present?
if acc_vals['financialInstitutionName'].present?
raise_exception_on_invalid_account_values('financial institution name')
end
end

def raise_exception_on_invalid_account_values(account_detail)
raise ::Common::Exceptions::UnprocessableEntity.new(
detail: "If the claimant has no account the #{account_detail} field must be left empty."
)
end

def validate_account_values!
direct_deposit_account_vals = form_attributes['directDeposit']

valid_account_types = %w[CHECKING SAVINGS]
account_type = direct_deposit_account_vals&.dig('accountType')
account_number = direct_deposit_account_vals&.dig('accountNumber')
routing_number = direct_deposit_account_vals&.dig('routingNumber')

if account_type.blank? || valid_account_types.exclude?(account_type)
raise_exception_if_value_present('account type (CHECKING/SAVINGS)')
end
raise_exception_if_value_present('account number') if account_number.blank?
raise_exception_if_value_present('routing number') if routing_number.blank?
end

def raise_exception_if_value_present(val)
raise ::Common::Exceptions::UnprocessableEntity.new(
detail: "The #{val} is required for direct deposit."
)
end
end
end
end
96 changes: 59 additions & 37 deletions modules/claims_api/app/swagger/claims_api/v2/dev/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2350,13 +2350,13 @@
"type": "string",
"maxLength": 3,
"pattern": "^\\d{3}$",
"example": "688"
"example": "555"
},
"phoneNumber": {
"type": "string",
"maxLength": 7,
"pattern": "^\\d{7}$",
"example": "8675309"
"example": "5555555"
}
}
},
Expand Down Expand Up @@ -2535,32 +2535,41 @@
"description": "Financial Direct Deposit information for Veteran.",
"type": "object",
"additionalProperties": false,
"required": [
"accountType",
"accountNumber",
"routingNumber"
],
"properties": {
"accountType": {
"description": "Veteran Account Type (value is case insensitive).",
"description": "Account type for the direct deposit.",
"type": "string",
"enum": [
"CHECKING",
"SAVINGS"
],
"example": "CHECKING"
"example": "CHECKING",
"properties": {
"result": {
"oneOf": [
{
"type": "string",
"enum": [
"CHECKING",
"SAVINGS"
]
},
{
"type": "string",
"enum": [
""
]
}
]
}
}
},
"accountNumber": {
"description": "Veteran Bank Account Number.",
"minLength": 4,
"maxLength": 17,
"description": "Account number for the direct deposit.",
"pattern": "^(?:[a-zA-Z0-9]{4,17})?$",
"type": "string",
"example": "123123123123"
},
"routngNumber": {
"description": "Veteran Bank Routing Number.",
"routingNumber": {
"description": "Routing number for the direct deposit.",
"type": "string",
"pattern": "^\\d{9}$",
"pattern": "^(?:\\d{9})?$",
"example": "123123123"
},
"financialInstitutionName": {
Expand All @@ -2571,7 +2580,7 @@
},
"noAccount": {
"type": "boolean",
"description": "Box 29 is checked if directDeposit is missing in the JSON request.",
"description": "Claimant certifies that they do not have an account with a financial institution or certified payment agent.",
"default": false
}
}
Expand Down Expand Up @@ -3518,13 +3527,13 @@
"type": "string",
"maxLength": 3,
"pattern": "^\\d{3}?$",
"example": "688"
"example": "555"
},
"phoneNumber": {
"type": "string",
"maxLength": 7,
"pattern": "^\\d{7}$",
"example": "8675309"
"example": "5555555"
}
}
},
Expand Down Expand Up @@ -3701,11 +3710,6 @@
"directDeposit": {
"type": "object",
"additionalProperties": false,
"required": [
"accountType",
"accountNumber",
"routingNumber"
],
"properties": {
"accountType": {
"description": "Account type for the direct deposit.",
Expand All @@ -3714,19 +3718,37 @@
"CHECKING",
"SAVINGS"
],
"example": "CHECKING"
"example": "CHECKING",
"properties": {
"result": {
"anyOf": [
{
"type": "string",
"enum": [
"CHECKING",
"SAVINGS"
]
},
{
"type": "string",
"enum": [
""
]
}
]
}
}
},
"accountNumber": {
"description": "Account number for the direct deposit.",
"minLength": 4,
"maxLength": 17,
"pattern": "^(?:[a-zA-Z0-9]{4,17})?$",
"type": "string",
"example": "123123123123"
},
"routingNumber": {
"description": "Routing number for the direct deposit.",
"type": "string",
"pattern": "^\\d{9}$",
"pattern": "^(?:\\d{9})?$",
"example": "123123123"
},
"financialInstitutionName": {
Expand Down Expand Up @@ -3921,8 +3943,8 @@
"title10ActivationDate": "2018-02-11"
},
"unitPhone": {
"areaCode": "123",
"phoneNumber": "4567890"
"areaCode": "555",
"phoneNumber": "5555555"
},
"receivingInactiveDutyTrainingPay": true
},
Expand Down Expand Up @@ -3952,9 +3974,9 @@
},
"directDeposit": {
"accountType": "CHECKING",
"accountNumber": "123456789",
"accountNumber": "123123123123",
"routingNumber": "123456789",
"financialInstituteName": "Chase",
"financialInstitutionName": "Chase",
"noAccount": false
}
}
Expand Down Expand Up @@ -4596,8 +4618,8 @@
"id": "1",
"type": "intent_to_file",
"attributes": {
"creationDate": "2023-05-31",
"expirationDate": "2024-05-31",
"creationDate": "2023-06-01",
"expirationDate": "2024-06-01",
"type": "compensation",
"status": "active"
}
Expand Down
107 changes: 59 additions & 48 deletions modules/claims_api/config/schemas/v2/526.json
Original file line number Diff line number Diff line change
Expand Up @@ -871,18 +871,18 @@
"additionalProperties": false,
"required": ["areaCode", "phoneNumber"],
"properties": {
"areaCode": {
"type": "string",
"pattern": "^\\d{3}?$",
"areaCode": {
"type": "string",
"maxLength": 3,
"example": "688"
},
"phoneNumber": {
"type": "string",
"pattern": "^\\d{7}$",
"pattern": "^\\d{3}$",
"example": "555"
},
"phoneNumber": {
"type": "string",
"maxLength": 7,
"example": "8675309"
}
"pattern": "^\\d{7}$",
"example": "5555555"
}
}
},
"receivingInactiveDutyTrainingPay": {
Expand Down Expand Up @@ -1051,42 +1051,53 @@
}
}
},
"directDeposit": {
"type": "object",
"additionalProperties": false,
"required": ["accountType", "accountNumber", "routingNumber"],
"properties": {
"accountType": {
"description": "Account type for the direct deposit.",
"type": "string",
"enum": ["CHECKING", "SAVINGS"],
"example": "CHECKING"
},
"accountNumber": {
"description": "Account number for the direct deposit.",
"minLength": 4,
"maxLength": 17,
"type": "string",
"example": "123123123123"
},
"routingNumber": {
"description": "Routing number for the direct deposit.",
"type": "string",
"pattern": "^\\d{9}$",
"example": "123123123"
},
"financialInstitutionName": {
"description": "Provide the name of the financial institution where the Veteran wants the direct deposit.",
"maxLength": 35,
"type": "string",
"example": "Some Bank"
},
"noAccount": {
"type": "boolean",
"description": "Claimant certifies that they do not have an account with a financial institution or certified payment agent.",
"default": false
}
}
}
}
"directDeposit": {
"type": "object",
"additionalProperties": false,
"properties": {
"accountType": {
"description": "Account type for the direct deposit.",
"type": "string",
"example": "CHECKING",
"properties": {
"result": {
"oneOf": [
{
"type": "string",
"enum": ["CHECKING", "SAVINGS"]
},
{
"type": "string",
"enum": [""]
}
]
}
}
},
"accountNumber": {
"description": "Account number for the direct deposit.",
"pattern": "^(?:[a-zA-Z0-9]{4,17})?$",
"type": "string",
"example": "123123123123"
},
"routingNumber": {
"description": "Routing number for the direct deposit.",
"type": "string",
"pattern": "^(?:\\d{9})?$",
"example": "123123123"
},
"financialInstitutionName": {
"description": "Provide the name of the financial institution where the Veteran wants the direct deposit.",
"maxLength": 35,
"type": "string",
"example": "Some Bank"
},
"noAccount": {
"type": "boolean",
"description": "Claimant certifies that they do not have an account with a financial institution or certified payment agent.",
"default": false
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@
"title10ActivationDate": "2018-02-11"
},
"unitPhone": {
"areaCode": "123",
"phoneNumber": "4567890"
"areaCode": "555",
"phoneNumber": "5555555"
},
"receivingInactiveDutyTrainingPay": true
},
Expand Down Expand Up @@ -195,9 +195,9 @@
},
"directDeposit": {
"accountType": "CHECKING",
"accountNumber": "123456789",
"accountNumber": "123123123123",
"routingNumber": "123456789",
"financialInstituteName": "Chase",
"financialInstitutionName": "Chase",
"noAccount": false
}
}
Expand Down
Loading

0 comments on commit 3220939

Please sign in to comment.