Skip to content

Commit

Permalink
Add #ssn
Browse files Browse the repository at this point in the history
  • Loading branch information
derekhouck committed Dec 17, 2024
1 parent 294b9ba commit 2508340
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@
"F[0].Page_1[0].VeteranFirstName[0]": "<%= form.first_name %>",
"F[0].Page_1[0].VeteranMiddleInitial1[0]": "<%= form.middle_initial %>",
"F[0].Page_1[0].VeteranLastName[0]": "<%= form.last_name %>",

<%# 2. Social Security Number %>
"F[0].Page_1[0].Veterans_Social_SecurityNumber_FirstThreeNumbers[0]": "<%= form.ssn[0] %>",
"F[0].Page_1[0].Veterans_Social_SecurityNumber_SecondTwoNumbers[0]": "<%= form.ssn[1] %>",
"F[0].Page_1[0].Veterans_Social_SecurityNumber_LastFourNumbers[0]": "<%= form.ssn[2] %>",

"F[0].Page_1[0].DOByear[0]": "<%= form.data.dig('DOByear') %>",
"F[0].Page_1[0].DOBday[0]": "<%= form.data.dig('DOBday') %>",
"F[0].Page_1[0].DOBmonth[0]": "<%= form.data.dig('DOBmonth') %>",
"F[0].Page_1[0].VAFileNumber[0]": "<%= form.data.dig('VAFileNumber') %>",
"F[0].Page_1[0].Veterans_Social_SecurityNumber_LastFourNumbers[0]": "<%= form.data.dig('Veterans_Social_SecurityNumber_LastFourNumbers') %>",
"F[0].Page_1[0].Veterans_Social_SecurityNumber_SecondTwoNumbers[0]": "<%= form.data.dig('Veterans_Social_SecurityNumber_SecondTwoNumbers') %>",
"F[0].Page_1[0].Veterans_Social_SecurityNumber_FirstThreeNumbers[0]": "<%= form.data.dig('Veterans_Social_SecurityNumber_FirstThreeNumbers') %>",
"F[0].Page_1[0].VeteransServiceNumber[0]": "<%= form.data.dig('VeteransServiceNumber') %>",
"F[0].Page_1[0].CurrentMailingAddress_ZIPOrPostalCode_LastFourNumbers[0]": "<%= form.data.dig('CurrentMailingAddress_ZIPOrPostalCode_LastFourNumbers') %>",
"F[0].Page_1[0].CurrentMailingAddress_ZIPOrPostalCode_FirstFiveNumbers[0]": "<%= form.data.dig('CurrentMailingAddress_ZIPOrPostalCode_FirstFiveNumbers') %>",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ def middle_initial
data.dig('full_name', 'middle')&.[](0)
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)
[]
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"veteran_id": {
"va_file_number": "12345678"
},
"service_number": "A12345678",
"home_phone": "1231231233",
"mobile_phone": "9876543210",
"email_address": "test@example.com",
"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"
}
}
],
"statement_of_truth_signature": "Example Test User",
"statement_of_truth_certified": true,
"form_number": "21-4140"
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"veteran_id": {
"ssn": "547901234",
"ssn": "547-90-1234",
"va_file_number": "12345678"
},
"service_number": "A12345678",
Expand Down
29 changes: 28 additions & 1 deletion modules/simple_forms_api/spec/models/vba_21_4140_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
RSpec.describe SimpleFormsApi::VBA214140 do
subject(:form) { described_class.new(data) }

let(:fixture_file) { 'vba_21_4140.json' }
let(:fixture_path) do
Rails.root.join('modules', 'simple_forms_api', 'spec', 'fixtures', 'form_json', 'vba_21_4140.json')
Rails.root.join('modules', 'simple_forms_api', 'spec', 'fixtures', 'form_json', fixture_file)
end
let(:data) { JSON.parse(fixture_path.read) }

Expand Down Expand Up @@ -75,4 +76,30 @@
end
end
end

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

let(:first_three) { ssn[0] }
let(:second_two) { ssn[1] }
let(:last_four) { ssn[2] }

context 'when ssn exists' do
it 'returns an array of numbers' do
expect(first_three.length).to eq 3
expect(second_two.length).to eq 2
expect(last_four.length).to eq 4
end
end

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

it 'returns an array with empty values' do
expect(first_three).to eq nil
expect(second_two).to eq nil
expect(last_four).to eq nil
end
end
end
end

0 comments on commit 2508340

Please sign in to comment.