diff --git a/lib/pdf_fill/forms/pdfs/22-10272.pdf b/lib/pdf_fill/forms/pdfs/22-10272.pdf index 434a0d15639..87addbbf72b 100644 Binary files a/lib/pdf_fill/forms/pdfs/22-10272.pdf and b/lib/pdf_fill/forms/pdfs/22-10272.pdf differ diff --git a/lib/pdf_fill/forms/va220810.rb b/lib/pdf_fill/forms/va220810.rb index 9852a8b4b78..153f10bb0b2 100644 --- a/lib/pdf_fill/forms/va220810.rb +++ b/lib/pdf_fill/forms/va220810.rb @@ -145,8 +145,7 @@ def merge_identification_helpers format_applicant_name(@form_data['applicantName']) format_address(@form_data['mailingAddress']) format_phone - append_payee_number = @form_data['vaFileNumber'].present? && @form_data['vaBenefitProgram'] == 'chapter35' - format_va_file_number(append_payee_number:) + format_va_file_number end def format_applicant_name(name) @@ -166,7 +165,8 @@ def format_phone @form_data['phone'].transform_values!(&method(:format_us_phone)) if domestic?(@country) end - def format_va_file_number(append_payee_number: false) + def format_va_file_number + append_payee_number = @form_data['vaFileNumber'].present? && @form_data['vaBenefitProgram'] == 'chapter35' @form_data['vaFileNumber'] = if append_payee_number "#{format_ssn(@form_data['vaFileNumber'])} #{@form_data['payeeNumber']}" else diff --git a/lib/pdf_fill/forms/va2210272.rb b/lib/pdf_fill/forms/va2210272.rb index 0d5ef0c73ef..cfea0f81a62 100644 --- a/lib/pdf_fill/forms/va2210272.rb +++ b/lib/pdf_fill/forms/va2210272.rb @@ -6,116 +6,119 @@ class Va2210272 < FormBase include FormHelper include FormHelper::PhoneNumberFormatting + BENEFIT_PROGRAMS = %w[chapter33 chapter35].freeze + + # rubocop:disable Layout/LineLength KEY = { + 'vaBenefitProgram' => { + key: 'vaBenefitProgram', + question_text: 'Select the education benefit under which you are requesting Prep Course fee reimbursement', + question_num: 0, + 'chapter33' => { + key: 'chapter33', + question_text: 'Post-9/11 GI Bill Including Transfer of Entitlement and Fry Scholarship Recipients (Chapter 33)' + }, + 'chapter35' => { + key: 'chapter35', + question_text: 'Survivors\' and Dependents\' Educational Assistance Program (DEA) (Chapter 35)' + } + }, 'applicantName' => { key: 'applicantName', question_text: 'APPLICANT\'S NAME (First, Middle Initial, Last Name)', question_num: 1, - limit: 54 + limit: 118 }, - 'address' => { - 'mailing' => { - key: 'mailingAddress', - question_text: 'MAILING ADDRESS (Complete Street Address, City, State and 9-Digit ZIP Code)', - question_num: 2, - question_suffix: 'A', - limit: 340, - multiline_limit: 4 - }, - 'email' => { - key: 'emailAddress', - question_text: 'APPLICANT\'S EMAIL ADDRESS', - question_num: 2, - question_suffix: 'B', - limit: 65 - } + 'mailingAddress' => { + key: 'mailingAddress', + question_text: 'MAILING ADDRESS (Complete Street Address, City, State and 9-Digit ZIP Code)', + question_num: 2, + limit: 280, + multiline_limit: 4 + }, + 'emailAddress' => { + key: 'emailAddress', + question_text: 'APPLICANT\'S EMAIL ADDRESS', + question_num: 3, + limit: 54 }, 'phone' => { question_text: 'TELEPHONE NUMBER (Include Area Code)', - 'homePhone' => { - key: 'homePhone', - question_text: 'HOME', - question_num: 3, - question_suffix: 'A', - limit: 32 - }, 'mobilePhone' => { key: 'mobilePhone', question_text: 'MOBILE', - question_num: 3, + question_num: 4, + question_suffix: 'A', + limit: 26 + }, + 'homePhone' => { + key: 'homePhone', + question_text: 'HOME', + question_num: 4, question_suffix: 'B', - limit: 46 + limit: 34 } }, 'vaFileNumber' => { key: 'vaFileNumber', - question_text: 'VA FILE NUMBER', - question_num: 4, - limit: 42 - }, - 'payeeNumber' => { - key: 'payeeNumber', - question_text: 'PAYEE NUMBER (if applicable)', + question_text: 'VA FILE NUMBER (For chapter 35, enter the Veteran\'s file number and your Payee Number)', question_num: 5, - limit: 42 + limit: 70 }, 'hasPreviouslyApplied' => { - question_text: 'HAVE YOU PREVIOUSLY APPLIED', + question_text: 'HAVE YOU PREVIOUSLY APPLIED FOR VA EDUCATION BENEFITS? (Please check the appropriate box below:)', question_num: 6, - question_suffix: 'A', - 'hasPreviouslyAppliedYes' => { + 'yes' => { key: 'hasPreviouslyAppliedYes', question_text: 'YES' }, - 'hasPreviouslyAppliedNo' => { + 'no' => { key: 'hasPreviouslyAppliedNo', question_text: 'NO' } }, - 'vaBenefitProgram' => { - key: 'vaBenefitProgram', - question_text: 'WHAT EDUCATION BENEFIT(S) HAVE YOU APPLIED FOR PREVIOUSLY?', - question_num: 6, - question_suffix: 'B', - limit: 87 - }, 'testName' => { key: 'testName', - question_text: 'NAME OF TEST', + question_text: 'NAME OF TEST FOR WHICH THE PREP COURSE WILL PREPARE YOU', question_num: 7, - limit: 87 + limit: 70 }, 'orgNameAndAddress' => { key: 'orgNameAndAddress', - question_text: 'NAME OF ORGANIZATION AWARDING LICENSE OR CERTIFICATION (Include address)', + question_text: 'NAME AND ADDRESS OF ORGANIZATION AWARDING LICENSE OR CERTIFICATION', question_num: 8, - limit: 340, + limit: 280, multiline_limit: 4 }, 'prepCourseName' => { key: 'prepCourseName', - question_text: 'NAME OF COURSE', + question_text: 'NAME OF PREP COURSE', question_num: 9, - limit: 46, + limit: 76, multiline_limit: 2 }, 'prepCourseOrgNameAndAddress' => { key: 'prepCourseOrgNameAndAddress', - question_text: 'ORGANIZATION GIVING PREP COURSE (Please include address)', + question_text: 'NAME AND ADDRESS OF ORGANIZATION GIVING PREP COURSE', question_num: 10, - question_suffix: 'A', - limit: 234, - multiline_limit: 5 + limit: 448, + multiline_limit: 14 + }, + 'prepCourseCost' => { + key: 'prepCourseCost', + question_text: 'TOTAL PREP COURSE COST INCLUDING MANDATORY FEES (You must attach a receipt)', + question_num: 11, + limit: 38 }, 'prepCourseTakenOnline' => { question_text: 'TAKEN ONLINE?', - question_num: 10, - question_suffix: 'B', - 'prepCourseTakenOnlineYes' => { + question_num: 12, + question_suffix: 'A', + 'yes' => { key: 'prepCourseTakenOnlineYes', question_text: 'YES' }, - 'prepCourseTakenOnlineNo' => { + 'no' => { key: 'prepCourseTakenOnlineNo', question_text: 'NO' } @@ -123,44 +126,38 @@ class Va2210272 < FormBase 'prepCourseStartDate' => { key: 'prepCourseStartDate', question_text: 'COURSE START DATE (MM/DD/YYYY)', - question_num: 11, - question_suffix: 'A', - limit: 24 + question_num: 12, + question_suffix: 'B', + limit: 19 }, 'prepCourseEndDate' => { key: 'prepCourseEndDate', question_text: 'COURSE END DATE (MM/DD/YYYY)', - question_num: 11, - question_suffix: 'B', - limit: 23 - }, - 'prepCourseCost' => { - key: 'prepCourseCost', - question_text: 'ITEMIZE PREP COURSE COST INCLUDING FEES (Attach receipt)', question_num: 12, - limit: 524, - multiline_limit: 14 + question_suffix: 'C', + limit: 19 }, 'remarks' => { key: 'remarks', question_text: 'REMARKS', question_num: 14, - limit: 3200, + limit: 2590, multiline_limit: 37 }, 'statementOfTruthSignature' => { key: 'statementOfTruthSignature', question_text: 'SIGNATURE OF APPLICANT', question_num: 15, - limit: 65 + limit: 52 }, 'dateSigned' => { key: 'dateSigned', question_text: 'DATE SIGNED (MM/DD/YYYY)', question_num: 16, - limit: 20 + limit: 16 } }.freeze + # rubocop:enable Layout/LineLength def merge_fields(_options = {}) merge_identification_helpers @@ -176,8 +173,9 @@ def merge_fields(_options = {}) def merge_identification_helpers format_applicant_name(@form_data['applicantName']) - format_address(@form_data['mailingAddress'].dup) + format_address(@form_data['mailingAddress']) format_phone + format_va_file_number end def format_applicant_name(name) @@ -186,22 +184,29 @@ def format_applicant_name(name) @form_data['applicantName'] = combine_full_name(name) end - def format_address(mailing_address) - normalize_mailing_address(mailing_address) - @form_data['address'] = { - 'mailing' => combine_full_address_extras(mailing_address), - 'email' => @form_data['emailAddress'] - } + def format_address(address) + @country = address['country'] + normalize_mailing_address(address) + @form_data['mailingAddress'] = combine_full_address_extras(address) end def format_phone @form_data['phone'] = @form_data.slice('homePhone', 'mobilePhone') - country = @form_data['mailingAddress']['country'] - @form_data['phone'].transform_values!(&method(:format_us_phone)) if domestic?(country) + @form_data['phone'].transform_values!(&method(:format_us_phone)) if domestic?(@country) + end + + def format_va_file_number + append_payee_number = @form_data['vaFileNumber'].present? && @form_data['vaBenefitProgram'] == 'chapter35' + @form_data['vaFileNumber'] = if append_payee_number + "#{format_ssn(@form_data['vaFileNumber'])} #{@form_data['payeeNumber']}" + else + format_ssn(@form_data['ssn'] || @form_data['vaFileNumber']) + end end def merge_education_helpers format_yes_no_checkbox('hasPreviouslyApplied') + format_benefit_program_checkbox end def merge_licensing_helpers @@ -222,11 +227,20 @@ def merge_prep_course_helpers def format_yes_no_checkbox(boolean_key) flag = @form_data[boolean_key] @form_data[boolean_key] = { - "#{boolean_key}Yes" => flag ? 'Yes' : 'Off', - "#{boolean_key}No" => flag ? 'Off' : 'Yes' + 'yes' => flag ? 'Yes' : 'Off', + 'no' => flag ? 'Off' : 'Yes' } end + def format_benefit_program_checkbox + selected_program = @form_data.delete('vaBenefitProgram') + @form_data['vaBenefitProgram'] = {} + BENEFIT_PROGRAMS.each do |program| + flag = program == selected_program + @form_data['vaBenefitProgram'][program] = flag ? 'Yes' : 'Off' + end + end + def merge_date_helpers %w[prepCourseStartDate prepCourseEndDate dateSigned].each(&method(:format_date)) end @@ -235,6 +249,10 @@ def format_date(key) str = @form_data[key] @form_data[key] = str.to_date.strftime(self.class.date_strftime) end + + def format_ssn(ssn) + split_ssn(ssn).values.join('-') + end end end end diff --git a/spec/fixtures/education_benefits_claims/10272/minimal.json b/spec/fixtures/education_benefits_claims/10272/minimal.json index bb8aed92d6f..c6c713455b3 100644 --- a/spec/fixtures/education_benefits_claims/10272/minimal.json +++ b/spec/fixtures/education_benefits_claims/10272/minimal.json @@ -18,7 +18,7 @@ "vaFileNumber": "123456789", "payeeNumber": "12", "hasPreviouslyApplied": true, - "vaBenefitProgram": "Post-9/11 GI Bill", + "vaBenefitProgram": "chapter35", "testName": "SAT", "organizationName": "College Board", "organizationAddress": { diff --git a/spec/fixtures/pdf_fill/22-10272/kitchen_sink.json b/spec/fixtures/pdf_fill/22-10272/kitchen_sink.json index bb8aed92d6f..c6c713455b3 100644 --- a/spec/fixtures/pdf_fill/22-10272/kitchen_sink.json +++ b/spec/fixtures/pdf_fill/22-10272/kitchen_sink.json @@ -18,7 +18,7 @@ "vaFileNumber": "123456789", "payeeNumber": "12", "hasPreviouslyApplied": true, - "vaBenefitProgram": "Post-9/11 GI Bill", + "vaBenefitProgram": "chapter35", "testName": "SAT", "organizationName": "College Board", "organizationAddress": { diff --git a/spec/fixtures/pdf_fill/22-10272/kitchen_sink.pdf b/spec/fixtures/pdf_fill/22-10272/kitchen_sink.pdf index 87ce71de0bc..2b73be9a359 100644 Binary files a/spec/fixtures/pdf_fill/22-10272/kitchen_sink.pdf and b/spec/fixtures/pdf_fill/22-10272/kitchen_sink.pdf differ diff --git a/spec/fixtures/pdf_fill/22-10272/overflow.json b/spec/fixtures/pdf_fill/22-10272/overflow.json index 9b98e381461..a3a3957d76f 100644 --- a/spec/fixtures/pdf_fill/22-10272/overflow.json +++ b/spec/fixtures/pdf_fill/22-10272/overflow.json @@ -18,7 +18,7 @@ "vaFileNumber": "123456789", "payeeNumber": "12", "hasPreviouslyApplied": true, - "vaBenefitProgram": "Post-9/11 GI Bill Post-9/11 GI Bill Post-9/11 GI Bill Post-9/11 GI Bill Post-9/11 GI Bill Post-9/11 GI Bill Post-9/11 GI Bill Post-9/11 GI Bill Post-9/11 GI Bill", + "vaBenefitProgram": "chapter35", "testName": "SAT", "organizationName": "College Board", "organizationAddress": { diff --git a/spec/fixtures/pdf_fill/22-10272/overflow.pdf b/spec/fixtures/pdf_fill/22-10272/overflow.pdf index b702001a3cc..8dcfdd63cbd 100644 Binary files a/spec/fixtures/pdf_fill/22-10272/overflow.pdf and b/spec/fixtures/pdf_fill/22-10272/overflow.pdf differ diff --git a/spec/fixtures/pdf_fill/22-10272/overflow_extras.pdf b/spec/fixtures/pdf_fill/22-10272/overflow_extras.pdf index fd3359c153b..42a5dfba8a1 100644 Binary files a/spec/fixtures/pdf_fill/22-10272/overflow_extras.pdf and b/spec/fixtures/pdf_fill/22-10272/overflow_extras.pdf differ diff --git a/spec/fixtures/pdf_fill/22-10272/simple.json b/spec/fixtures/pdf_fill/22-10272/simple.json index bb8aed92d6f..c6c713455b3 100644 --- a/spec/fixtures/pdf_fill/22-10272/simple.json +++ b/spec/fixtures/pdf_fill/22-10272/simple.json @@ -18,7 +18,7 @@ "vaFileNumber": "123456789", "payeeNumber": "12", "hasPreviouslyApplied": true, - "vaBenefitProgram": "Post-9/11 GI Bill", + "vaBenefitProgram": "chapter35", "testName": "SAT", "organizationName": "College Board", "organizationAddress": { diff --git a/spec/fixtures/pdf_fill/22-10272/simple.pdf b/spec/fixtures/pdf_fill/22-10272/simple.pdf index 87ce71de0bc..2b73be9a359 100644 Binary files a/spec/fixtures/pdf_fill/22-10272/simple.pdf and b/spec/fixtures/pdf_fill/22-10272/simple.pdf differ diff --git a/spec/lib/pdf_fill/forms/va2210272_spec.rb b/spec/lib/pdf_fill/forms/va2210272_spec.rb index 78fc9494c5a..c0cc16dff2d 100644 --- a/spec/lib/pdf_fill/forms/va2210272_spec.rb +++ b/spec/lib/pdf_fill/forms/va2210272_spec.rb @@ -22,11 +22,10 @@ )) end - it 'formats mailing and email address' do + it 'formats mailing address' do mailing_address = form_data['mailingAddress'] form.normalize_mailing_address(mailing_address) - expect(merged_fields['address']['mailing']).to eq(form.combine_full_address_extras(mailing_address)) - expect(merged_fields['address']['email']).to eq(form_data['emailAddress']) + expect(merged_fields['mailingAddress']).to eq(form.combine_full_address_extras(mailing_address)) end it 'formats phone if domestic' do @@ -42,6 +41,18 @@ expect(mobile).to eq(form_data['mobilePhone']) end + it 'formats va file number without payee number if not chapter 35' do + form_data['vaBenefitProgram'] = 'chapter33' + formatted_file_number = form_data['vaFileNumber'].gsub(/(\d{3})(\d{2})(\d{4})/, '\1-\2-\3') + expect(merged_fields['vaFileNumber']).to eq(formatted_file_number) + end + + it 'appends payee number to va file number if chapter 35' do + expect(form_data['vaBenefitProgram']).to eq('chapter35') + formatted_file_number = form_data['vaFileNumber'].gsub(/(\d{3})(\d{2})(\d{4})/, '\1-\2-\3') + expect(merged_fields['vaFileNumber']).to eq("#{formatted_file_number} #{form_data['payeeNumber']}") + end + it 'converts hasPreviouslyApplied boolean to Yes/Off' do expect(form_data['hasPreviouslyApplied']).to be true has_applied_yes, has_applied_no = merged_fields['hasPreviouslyApplied'].values @@ -77,5 +88,12 @@ expect(merged_fields[field]).to match(%r{^(0[1-9]|1[0-2])/(0[1-9]|[12][0-9]|3[01])/\d{4}$}) end end + + it 'sets vaBenefitProgram values to Yes/Off' do + described_class::BENEFIT_PROGRAMS.each do |program| + expected = program == form_data['vaBenefitProgram'] ? 'Yes' : 'Off' + expect(merged_fields['vaBenefitProgram'][program]).to eq(expected) + end + end end end