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

93461: Add stamps and digital signature to VBA214140 #20059

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
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
17 changes: 13 additions & 4 deletions modules/simple_forms_api/app/form_mappings/vba_21_4140.json.erb
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,17 @@
"F[0].#subform[1].Gross_Earnings_Per_Month[1]": "<%= form.employment_history[3].highest_income %>",
"F[0].#subform[1].Gross_Earnings_Per_Month[2]": "<%= form.employment_history[1].highest_income %>",

"F[0].#subform[1].DateSigned[0]": "<%= form.data.dig('DateSigned') %>",
"F[0].#subform[1].SignatureField1[0]": "<%= form.data.dig('SignatureField1') %>",
"F[0].#subform[1].SignatureField1[1]": "<%= form.data.dig('SignatureField1') %>",
"F[0].#subform[1].DateSigned[1]": "<%= form.data.dig('DateSigned') %>"
<%# 12A. Signature of Veteran %>
"F[0].#subform[1].SignatureField1[0]": "<%= form.signature_employed %>",

<%# 12B. Date Signed %>
"F[0].#subform[1].DateSigned[1]": "<%= form.signature_date_employed %>",

<%# Section III - Unemployment Certification %>

<%# 13A. Signature of Veteran %>
"F[0].#subform[1].SignatureField1[1]": "<%= form.signature_unemployed %>",

<%# 13B. Date Signed %>
"F[0].#subform[1].DateSigned[0]": "<%= form.signature_date_unemployed %>"
Comment on lines +115 to +127
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Depending on the employment history data, only one set of signatures/dates will be filled while the other will be blank.

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ def initialize(data)
state_code: data.dig('address', 'state'),
zip_code: data.dig('address', 'postal_code')
)
@signature = data['statement_of_truth_signature']
@signature_date_formatted = signature_date.strftime('%m/%d/%Y')
end

def desired_stamps
[]
coords = employed? ? [[50, 410]] : [[50, 275]]
[{ coords:, text: signature, page: 1 }]
Comment on lines +25 to +26
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Coordinates originate from the bottom left corner of the page.

end

def dob
Expand All @@ -31,11 +34,15 @@ def dob
end

def employed?
data['employers'] ? data['employers'].size.positive? : false
employers.any?
end

def employers
data['employers']&.delete_if(&:empty?) || []
end

def employment_history
[*0..3].map { |i| FormEngine::EmploymentHistory.new(data['employers'][i]) }
[*0..3].map { |i| FormEngine::EmploymentHistory.new(employers[i]) }
end

def first_name
Expand Down Expand Up @@ -70,21 +77,66 @@ def phone_primary
data['home_phone'].insert(-8, '-').insert(-5, '-')
end

def signature_date_employed
employed? ? signature_date_formatted : nil
end

def signature_date_unemployed
employed? ? nil : signature_date_formatted
end

def signature_employed
employed? ? signature : nil
end

def signature_unemployed
employed? ? nil : signature
end

def ssn
trimmed_ssn = data.dig('veteran_id', 'ssn')&.tr('-', '')

[trimmed_ssn&.[](0..2), trimmed_ssn&.[](3..4), trimmed_ssn&.[](5..8)]
end

def submission_date_stamps(_timestamp)
[]
def submission_date_stamps(timestamp = Time.current)
[
{
coords: [450, 670],
text: 'Application Submitted:',
page: 0,
font_size: 12
},
{
coords: [450, 650],
text: timestamp.in_time_zone('UTC').strftime('%H:%M %Z %D'),
page: 0,
font_size: 12
}
]
end

# At the moment, we only allow veterans to submit Form Engine forms.
def track_user_identity(confirmation_number); end

def words_to_remove
ssn + dob + address_to_remove + contact_info
end

def zip_code_is_us_based
address.country_code_iso3 == 'USA'
end

private

attr_reader :signature, :signature_date_formatted

def address_to_remove
[address.address_line1, address.address_line2, address.zip_code]
end

def contact_info
[phone_primary, phone_alternate, data['email_address']]
end
end
end
2 changes: 2 additions & 0 deletions modules/simple_forms_api/lib/simple_forms_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ def scrub_pii(message)
words_to_remove = aggregate_words(JSON.parse(params.to_json))

case params[:form_number]
when '21-4140'
words_to_remove += SimpleFormsApi::VBA214140.new(params).words_to_remove
when '21-4142'
words_to_remove += SimpleFormsApi::VBA214142.new(params).words_to_remove
when '21-10210'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"veteran_id": {
"ssn": "547-90-1234",
"va_file_number": "12345678"
},
"service_number": "A12345678",
"home_phone": "1231231233",
"mobile_phone": "9876543210",
"email_address": "[email protected]",
"address": {
"country": "USA",
"street": "123 Fake St",
"street2": "Apt 123",
"street3": "Attn: Testing",
"city": "Los Angeles",
"state": "CA",
"postal_code": "90210"
},
"full_name": {
"first": "Rumpelstiltskin",
"middle": "Test",
"last": "Mephistopheles-Reinhardt"
},
"date_of_birth": "1979-02-27",
"employers": [
{
"type_of_work": "Full-time",
"hours_per_week": "40",
"lost_time": "13",
"highest_income": "2300",
"date_range": {
"from": "2018-03-15",
"to": "2020-06-30"
},
"name": "Test Employer",
"address": {
"country": "USA",
"street": "1234 Executive Ave",
"city": "Metropolis",
"state": "CA",
"postal_code": "90210"
}
},
{
"type_of_work": "Freelance",
"hours_per_week": "20",
"lost_time": "30",
"highest_income": "1300",
"date_range": {
"from": "2020-07-01",
"to": "2022-09-13"
},
"name": "Freelancer",
"address": {
"country": "USA",
"street": "123 Test St",
"city": "Test City",
"state": "CA",
"postal_code": "90210"
}
},
{
"type_of_work": "Sub-contractor",
"hours_per_week": "60",
"lost_time": "56",
"highest_income": "600",
"date_range": {
"from": "2022-10-11",
"to": "2024-04-07"
},
"name": "Example \"Construction\" Company",
"address": {
"country": "CAN",
"street": "4321 Example Ave",
"city": "Test City",
"state": "NS",
"postal_code": "M4B 1G5"
}
},
{}
],
"statement_of_truth_signature": "Example Test User",
"statement_of_truth_certified": true,
"form_number": "21-4140"
}
69 changes: 69 additions & 0 deletions modules/simple_forms_api/spec/models/vba_21_4140_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@
it { is_expected.to match(data) }
end

describe '#desired_stamps' do
subject(:desired_stamps) { form.desired_stamps }

it 'only adds one stamp' do
expect(desired_stamps.size).to eq 1
end

it 'contains the correct properties' do
expect(desired_stamps[0][:text]).to eq form.signature_employed
expect(desired_stamps[0][:page]).to eq 1
end
end

describe '#dob' do
subject(:dob) { form.dob }

Expand Down Expand Up @@ -161,6 +174,62 @@
end
end

describe '#signature_date_employed' do
subject { form.signature_date_employed }

context 'when employed' do
it { is_expected.to match(%r{\d{2}/\d{2}/\d{4}}) }
end

context 'when unemployed' do
let(:fixture_file) { 'vba_21_4140-min.json' }

it { is_expected.to be_nil }
end
end

describe '#signature_date_unemployed' do
subject { form.signature_date_unemployed }

context 'when employed' do
it { is_expected.to be_nil }
end

context 'when unemployed' do
let(:fixture_file) { 'vba_21_4140-min.json' }

it { is_expected.to match(%r{\d{2}/\d{2}/\d{4}}) }
end
end

describe '#signature_employed' do
subject { form.signature_employed }

context 'when employed' do
it { is_expected.to eq data['statement_of_truth_signature'] }
end

context 'when unemployed' do
let(:fixture_file) { 'vba_21_4140-min.json' }

it { is_expected.to be_nil }
end
end

describe '#signature_unemployed' do
subject { form.signature_unemployed }

context 'when employed' do
it { is_expected.to be_nil }
end

context 'when unemployed' do
let(:fixture_file) { 'vba_21_4140-min.json' }

it { is_expected.to eq data['statement_of_truth_signature'] }
end
end

describe '#ssn' do
subject(:ssn) { form.ssn }

Expand Down
Loading
Loading