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 33481 poa v2 ind signatures #16064

Merged
merged 43 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
aeeccaf
Make reg num required
acovrig Mar 14, 2024
6cb2b0a
Add sig to PDF
acovrig Mar 14, 2024
05f8ac4
Add .first test
acovrig Mar 14, 2024
91c97ea
Remove page1 signatures
acovrig Mar 14, 2024
518880e
Merge branch 'master' into API-33483-poa-v2-signatures
acovrig Mar 18, 2024
a8b5d69
Merge branch 'master' into API-33483-poa-v2-signatures
acovrig Mar 18, 2024
6909c0a
Handle duplicate reps by ID
acovrig Mar 19, 2024
7def9b8
Merge branch 'master' into API-33483-poa-v2-signatures
acovrig Mar 19, 2024
1a3e828
Merge branch 'API-33483-poa-v2-signatures' into API-33481-poa-v2-ind-…
acovrig Mar 19, 2024
8ca67c5
update tests
acovrig Mar 20, 2024
3b3a741
switch to created_at
acovrig Mar 20, 2024
0177f3e
Merge branch 'master' into API-33483-poa-v2-signatures
acovrig Mar 20, 2024
057e2d5
Merge branch 'API-33483-poa-v2-signatures' into API-33481-poa-v2-ind-…
acovrig Mar 20, 2024
70460d0
Remove unused method
acovrig Mar 20, 2024
937ff32
Require rep_id in builder
acovrig Mar 21, 2024
38c3b6c
Merge branch 'master' into API-33483-poa-v2-signatures
acovrig Mar 21, 2024
8634a4b
Merge branch 'API-33483-poa-v2-signatures' into API-33481-poa-v2-ind-…
acovrig Mar 22, 2024
39af6d4
Merge branch 'master' into API-33483-poa-v2-signatures
acovrig Mar 25, 2024
dd65266
Fix merge conflictions
acovrig Mar 25, 2024
ab66f19
Merge branch 'API-33483-poa-v2-signatures' into API-33481-poa-v2-ind-…
acovrig Mar 25, 2024
d20f566
Fix merge
acovrig Mar 25, 2024
002f8d9
Fix another merge confliction
acovrig Mar 25, 2024
29a76d9
Merge branch 'API-33483-poa-v2-signatures' into API-33481-poa-v2-ind-…
acovrig Mar 25, 2024
dd0b882
Merge branch 'master' into API-33483-poa-v2-signatures
acovrig Mar 25, 2024
83148b1
Merge branch 'master' into API-33481-poa-v2-ind-signatures
acovrig Mar 25, 2024
4fd951e
Remove method again
acovrig Mar 25, 2024
06a3bbc
Merge branch 'master' into API-33483-poa-v2-signatures
acovrig Mar 25, 2024
d2411fe
Merge branch 'master' into API-33483-poa-v2-signatures
acovrig Mar 26, 2024
795be3c
Merge branch 'master' into API-33481-poa-v2-ind-signatures
acovrig Mar 26, 2024
5a4ec64
Merge branch 'master' into API-33481-poa-v2-ind-signatures
acovrig Mar 26, 2024
e75d48b
Remove first/last name from 2122 schema
acovrig Mar 26, 2024
793d3ff
Fix spaces
acovrig Mar 26, 2024
fe91c6e
Fix rep name on form
acovrig Mar 26, 2024
9d6d5ac
Merge branch 'API-33483-poa-v2-signatures' into API-33481-poa-v2-ind-…
acovrig Mar 26, 2024
5627c82
Merge branch 'master' into API-33483-poa-v2-signatures
acovrig Mar 26, 2024
b598216
Merge branch 'API-33483-poa-v2-signatures' into API-33481-poa-v2-ind-…
acovrig Mar 26, 2024
ffceb66
Fix spec
acovrig Mar 26, 2024
c739b49
Ran rswag
acovrig Mar 26, 2024
25df005
Merge branch 'API-33483-poa-v2-signatures' into API-33481-poa-v2-ind-…
acovrig Mar 26, 2024
718f1c4
Remove first name from schema
acovrig Mar 28, 2024
e26885a
Merge branch 'master' into API-33481-poa-v2-ind-signatures
acovrig Mar 28, 2024
aed7af1
Remove unused methods
acovrig Mar 29, 2024
ac6207e
Merge branch 'master' into API-33481-poa-v2-ind-signatures
acovrig Mar 29, 2024
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 @@ -49,6 +49,8 @@ def shared_form_validation(form_number)
@claims_api_forms_validation_errors = validate_form_2122_and_2122a_submission_values(user_profile)
# JSON validations for POA submission, will combine with previously captured errors and raise
validate_json_schema(form_number.upcase)
@rep_id = validate_registration_number!(form_number)

add_claimant_data_to_form if user_profile
# if we get here there were only validations file errors
if @claims_api_forms_validation_errors
Expand All @@ -57,6 +59,22 @@ def shared_form_validation(form_number)
end
end

def validate_registration_number!(form_number)
base = form_number == '2122' ? 'serviceOrganization' : 'representative'
rn = form_attributes.dig(base, 'registrationNumber')
poa_code = form_attributes.dig(base, 'poaCode')
rep = ::Veteran::Service::Representative.where('? = ANY(poa_codes) AND representative_id = ?',
poa_code,
rn).order(created_at: :desc).first
if rep.nil?
raise ::Common::Exceptions::ResourceNotFound.new(
detail: "Could not find an Accredited Representative with registration number: #{rn} " \
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, I like this language update

"and poa code: #{poa_code}"
)
end
rep.id
end

def submit_power_of_attorney(poa_code, form_number)
attributes = {
status: ClaimsApi::PowerOfAttorney::PENDING,
Expand All @@ -70,7 +88,7 @@ def submit_power_of_attorney(poa_code, form_number)
power_of_attorney = ClaimsApi::PowerOfAttorney.create!(attributes)

unless Settings.claims_api&.poa_v2&.disable_jobs
ClaimsApi::V2::PoaFormBuilderJob.perform_async(power_of_attorney.id, form_number)
ClaimsApi::V2::PoaFormBuilderJob.perform_async(power_of_attorney.id, form_number, @rep_id)
end

render json: ClaimsApi::V2::Blueprints::PowerOfAttorneyBlueprint.render(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ class PoaFormBuilderJob < ClaimsApi::ServiceBase
# it queues a job to update the POA code in BGS, as well.
#
# @param power_of_attorney_id [String] Unique identifier of the submitted POA
def perform(power_of_attorney_id, form_number)
def perform(power_of_attorney_id, form_number, rep_id)
power_of_attorney = ClaimsApi::PowerOfAttorney.find(power_of_attorney_id)
rep = ::Veteran::Service::Representative.where(representative_id: rep_id).order(created_at: :desc).first

output_path = pdf_constructor(form_number).construct(data(power_of_attorney, form_number),
output_path = pdf_constructor(form_number).construct(data(power_of_attorney, form_number, rep),
id: power_of_attorney.id)
upload_to_vbms(power_of_attorney, output_path)
ClaimsApi::PoaUpdater.perform_async(power_of_attorney.id)
Expand All @@ -43,7 +44,7 @@ def pdf_constructor(form_number)
# @param form_number [String] Either 2122 or 2122A
#
# @return [Hash] All data to be inserted into pdf
def data(power_of_attorney, form_number)
def data(power_of_attorney, form_number, rep)
res = power_of_attorney
.form_data.deep_merge({
'veteran' => {
Expand All @@ -57,16 +58,18 @@ def data(power_of_attorney, form_number)
signatures = if form_number == '2122A'
individual_signatures(power_of_attorney)
else
organization_signatures(power_of_attorney)
organization_signatures(power_of_attorney, rep)
end

res.deep_merge!({ 'serviceOrganization' => {
'firstName' => rep.first_name,
'lastName' => rep.last_name
} })
res.merge!({ 'text_signatures' => signatures })
res
end

def organization_signatures(power_of_attorney)
rep_first_name = power_of_attorney.form_data['serviceOrganization']['firstName']
rep_last_name = power_of_attorney.form_data['serviceOrganization']['lastName']
def organization_signatures(power_of_attorney, rep)
first_name, last_name = veteran_or_claimant_signature(power_of_attorney)
{
'page2' => [
Expand All @@ -77,7 +80,7 @@ def organization_signatures(power_of_attorney)
'y' => 240
},
{
'signature' => "#{rep_first_name} #{rep_last_name} - signed via api.va.gov",
'signature' => "#{rep.first_name} #{rep.last_name} - signed via api.va.gov",
'x' => 35,
'y' => 200
}
Expand All @@ -89,8 +92,19 @@ def individual_signatures(power_of_attorney)
first_name = power_of_attorney.form_data['representative']['firstName']
last_name = power_of_attorney.form_data['representative']['lastName']
{
'page1' => individual_page1_signatures(power_of_attorney, first_name, last_name),
'page2' => individual_page2_signatures(power_of_attorney, first_name, last_name)
acovrig marked this conversation as resolved.
Show resolved Hide resolved
'page2' => [
{
'signature' => "#{power_of_attorney.auth_headers['va_eauth_firstName']} " \
"#{power_of_attorney.auth_headers['va_eauth_lastName']} - signed via api.va.gov",
'x' => 35,
'y' => 306
},
{
'signature' => "#{first_name} #{last_name} - signed via api.va.gov",
'x' => 35,
'y' => 200
}
]
}
end

Expand Down
104 changes: 80 additions & 24 deletions modules/claims_api/app/swagger/claims_api/v2/dev/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -8751,6 +8751,14 @@
"pointer": "data/attributes/representative"
}
},
{
"title": "Unprocessable entity",
"detail": "The property /representative did not contain the required key registrationNumber",
"status": "422",
"source": {
"pointer": "data/attributes/representative"
}
},
{
"title": "Unprocessable entity",
"detail": "The property / did not contain the required key veteran",
Expand Down Expand Up @@ -8815,7 +8823,7 @@
{
"title": "Resource not found",
"status": "404",
"detail": "Could not find an Accredited Representative with code: 083",
"detail": "Could not find an Accredited Representative with registration number: 67890 and poa code: 083",
"source": {
"pointer": "/modules/claims_api/app/controllers/claims_api/v2/veterans/power_of_attorney/individual_controller.rb:35:in `validate_individual_poa_code!'"
}
Expand Down Expand Up @@ -9123,6 +9131,7 @@
"additionalProperties": false,
"required": [
"poaCode",
"registrationNumber",
"firstName",
"lastName",
"type"
Expand All @@ -9133,6 +9142,11 @@
"type": "string",
"example": "A1Q"
},
"registrationNumber": {
"description": "Registration Number of representative.",
"type": "string",
"example": "12345"
},
"firstName": {
"description": "First Name of the representative.",
"type": "string",
Expand Down Expand Up @@ -9254,6 +9268,7 @@
},
"representative": {
"poaCode": "083",
"registrationNumber": "67890",
"firstName": "my",
"lastName": "name",
"type": "ATTORNEY",
Expand Down Expand Up @@ -9451,13 +9466,29 @@
"pointer": "data/attributes/serviceOrganization"
}
},
{
"title": "Unprocessable entity",
"detail": "The property /serviceOrganization did not contain the required key registrationNumber",
"status": "422",
"source": {
"pointer": "data/attributes/serviceOrganization"
}
},
{
"title": "Unprocessable entity",
"detail": "The property / did not contain the required key veteran",
"status": "422",
"source": {
"pointer": "data/attributes/"
}
},
{
"title": "Unprocessable entity",
"detail": "The property /serviceOrganization/withoutPoaCode is not defined on the schema. Additional properties are not allowed",
"status": "422",
"source": {
"pointer": "data/attributes/serviceOrganization/withoutPoaCode"
}
}
]
},
Expand Down Expand Up @@ -9515,7 +9546,7 @@
{
"title": "Resource not found",
"status": "404",
"detail": "Could not find an Organization with code: 083",
"detail": "Could not find an Accredited Representative with registration number: 67890 and poa code: 083",
"source": {
"pointer": "/modules/claims_api/app/controllers/claims_api/v2/veterans/power_of_attorney/organization_controller.rb:35:in `validate_org_poa_code!'"
}
Expand Down Expand Up @@ -9806,7 +9837,8 @@
"type": "object",
"additionalProperties": false,
"required": [
"poaCode"
"poaCode",
"registrationNumber"
],
"properties": {
"poaCode": {
Expand All @@ -9819,15 +9851,10 @@
"type": "string",
"example": "I help vets LLC."
},
"firstName": {
"description": "First Name of the representative.",
"registrationNumber": {
"description": "Registration Number of representative.",
"type": "string",
"example": "John"
},
"lastName": {
"description": "Last Name of the representative",
"type": "string",
"example": "Doe"
"example": "12345"
},
"jobTitle": {
"description": "Job title of the representative.",
Expand Down Expand Up @@ -9888,7 +9915,8 @@
}
},
"serviceOrganization": {
"poaCode": "083"
"poaCode": "083",
"registrationNumber": "67890"
}
}
}
Expand Down Expand Up @@ -10065,6 +10093,14 @@
"pointer": "data/attributes/representative"
}
},
{
"title": "Unprocessable entity",
"detail": "The property /representative did not contain the required key registrationNumber",
"status": "422",
"source": {
"pointer": "data/attributes/representative"
}
},
{
"title": "Unprocessable entity",
"detail": "The property / did not contain the required key veteran",
Expand Down Expand Up @@ -10129,7 +10165,7 @@
{
"title": "Resource not found",
"status": "404",
"detail": "Could not find an Accredited Representative with code: 083",
"detail": "Could not find an Accredited Representative with registration number: 67890 and poa code: 083",
"source": {
"pointer": "/modules/claims_api/app/controllers/claims_api/v2/veterans/power_of_attorney/individual_controller.rb:35:in `validate_individual_poa_code!'"
}
Expand Down Expand Up @@ -10437,6 +10473,7 @@
"additionalProperties": false,
"required": [
"poaCode",
"registrationNumber",
"firstName",
"lastName",
"type"
Expand All @@ -10447,6 +10484,11 @@
"type": "string",
"example": "A1Q"
},
"registrationNumber": {
"description": "Registration Number of representative.",
"type": "string",
"example": "12345"
},
"firstName": {
"description": "First Name of the representative.",
"type": "string",
Expand Down Expand Up @@ -10568,6 +10610,7 @@
},
"representative": {
"poaCode": "083",
"registrationNumber": "67890",
"firstName": "my",
"lastName": "name",
"type": "ATTORNEY",
Expand Down Expand Up @@ -10756,13 +10799,29 @@
"pointer": "data/attributes/serviceOrganization"
}
},
{
"title": "Unprocessable entity",
"detail": "The property /serviceOrganization did not contain the required key registrationNumber",
"status": "422",
"source": {
"pointer": "data/attributes/serviceOrganization"
}
},
{
"title": "Unprocessable entity",
"detail": "The property / did not contain the required key veteran",
"status": "422",
"source": {
"pointer": "data/attributes/"
}
},
{
"title": "Unprocessable entity",
"detail": "The property /serviceOrganization/withoutPoaCode is not defined on the schema. Additional properties are not allowed",
"status": "422",
"source": {
"pointer": "data/attributes/serviceOrganization/withoutPoaCode"
}
}
]
},
Expand Down Expand Up @@ -10820,7 +10879,7 @@
{
"title": "Resource not found",
"status": "404",
"detail": "Could not find an Organization with code: 083",
"detail": "Could not find an Accredited Representative with registration number: 67890 and poa code: 083",
"source": {
"pointer": "/modules/claims_api/app/controllers/claims_api/v2/veterans/power_of_attorney/organization_controller.rb:35:in `validate_org_poa_code!'"
}
Expand Down Expand Up @@ -11111,7 +11170,8 @@
"type": "object",
"additionalProperties": false,
"required": [
"poaCode"
"poaCode",
"registrationNumber"
],
"properties": {
"poaCode": {
Expand All @@ -11124,15 +11184,10 @@
"type": "string",
"example": "I help vets LLC."
},
"firstName": {
"description": "First Name of the representative.",
"registrationNumber": {
"description": "Registration Number of representative.",
"type": "string",
"example": "John"
},
"lastName": {
"description": "Last Name of the representative",
"type": "string",
"example": "Doe"
"example": "12345"
},
"jobTitle": {
"description": "Job title of the representative.",
Expand Down Expand Up @@ -11193,7 +11248,8 @@
}
},
"serviceOrganization": {
"poaCode": "083"
"poaCode": "083",
"registrationNumber": "67890"
}
}
}
Expand Down
Loading
Loading