This repository is currently being migrated. It's locked while the migration is in progress.
-
Notifications
You must be signed in to change notification settings - Fork 94
Expand file tree
/
Copy pathva220810.rb
More file actions
220 lines (202 loc) · 7.46 KB
/
va220810.rb
File metadata and controls
220 lines (202 loc) · 7.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# frozen_string_literal: true
module PdfFill
module Forms
class Va220810 < FormBase
include FormHelper
include FormHelper::PhoneNumberFormatting
BENEFIT_PROGRAMS = %w[chapter30 chapter33 chapter35 chapter1606].freeze
# rubocop:disable Layout/LineLength
KEY = {
'vaBenefitProgram' => {
question_text: 'Select the education benefit under which you are requesting National Exam fee reimbursement',
question_num: 0,
'chapter30' => {
key: 'chapter30',
question_text: 'Montgomery GI Bill - Active Duty Educational Assistance Program (MGIB) (Chapter 30)'
},
'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\' Education Assistance Program (DEA) (Chapter 35)'
},
'chapter1606' => {
key: 'chapter1606',
question_text: 'Montgomery GI Bill - Selected Reserve Educational Assistance Program (MGIB-SR) (Chapter 1606)'
}
},
'applicantName' => {
key: 'applicantName',
question_text: 'APPLICANT\'S NAME (First, Middle Initial, Last Name)',
question_num: 1,
limit: 107
},
'mailingAddress' => {
key: 'mailingAddress',
question_text: 'APPLICANT\'S ADDRESS (Number and street or rural route, P.O. Box, City, State, Zip Code)',
question_num: 2,
limit: 180,
multiline_limit: 2
},
'emailAddress' => {
key: 'emailAddress',
question_text: 'APPLICANT\'S EMAIL ADDRESS',
question_num: 3,
limit: 107
},
'phone' => {
question_text: 'TELEPHONE NUMBER (Include Area Code)',
question_num: 4,
'mobilePhone' => {
key: 'mobilePhone',
question_text: 'MOBILE',
question_suffix: 'A',
limit: 28
},
'homePhone' => {
key: 'homePhone',
question_text: 'HOME',
question_suffix: 'B',
limit: 29
}
},
'vaFileNumber' => {
key: 'vaFileNumber',
question_text: 'VA FILE NUMBER (For chapter 35, enter the veteran\'s file number and include your suffix indicator. For Chapter 30 dependent\'s case, enter the file number of the person who transferred entitlement to you)',
question_num: 5,
limit: 107
},
'hasPreviouslyApplied' => {
question_text: 'HAVE YOU PREVIOUSLY APPLIED FOR VA EDUCATION BENEFITS?',
question_num: 6,
'yes' => {
key: 'hasPreviouslyAppliedYes',
question_text: 'YES (If "Yes," show the specific benefit you previously applied for in Item 6B)'
},
'no' => {
key: 'hasPreviouslyAppliedNo',
question_text: 'NO (If "No," you must also complete an Application for VA Education Benefits, as indicated in "Important" paragraph instructions above)'
}
},
'examName' => {
key: 'examName',
question_text: 'NAME OF EXAM (Use this form for one exam only)',
question_num: 7,
limit: 107
},
'organization' => {
key: 'organization',
question_text: 'NAME AND ADDRESS OF ORGANIZATION GIVING EXAM',
question_num: 8,
limit: 107,
multiline_limit: 1
},
'examDate' => {
key: 'examDate',
question_text: 'DATE EXAM TAKEN (MM/DD/YYYY) (Attach a copy of exam results)',
question_num: 9,
limit: 107
},
'examCost' => {
key: 'examCost',
question_text: 'TOTAL COST OF EXAM INCLUDING MANDATORY FEES (Attach exam receipt)',
question_num: 10,
limit: 107
},
'remarks' => {
key: 'remarks',
question_text: 'REMARKS (Optional)',
question_num: 11,
limit: 456,
multiline_limit: 5
},
'statementOfTruthSignature' => {
key: 'statementOfTruthSignature',
question_text: 'SIGNATURE OF APPLICANT',
question_num: 12,
limit: 78
},
'dateSigned' => {
key: 'dateSigned',
question_text: 'DATE SIGNED (MM/DD/YYYY)',
question_num: 13,
limit: 28
}
}.freeze
# rubocop:enable Layout/LineLength
def merge_fields(_options = {})
merge_identification_helpers
merge_benefit_program_helpers
format_organization
merge_date_helpers
@form_data
end
private
def merge_identification_helpers
format_applicant_name(@form_data['applicantName'])
format_address(@form_data['mailingAddress'])
format_phone
format_va_file_number
end
def format_applicant_name(name)
# Convert middle name to middle initial if present
name['middle'] = "#{name['middle'][0]}." if name['middle']
@form_data['applicantName'] = combine_full_name(name)
end
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')
@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'])
end
end
def format_ssn(ssn)
split_ssn(ssn).values.join('-')
end
def merge_benefit_program_helpers
format_has_previously_applied_checkbox
format_benefit_program_checkbox
end
def format_has_previously_applied_checkbox
flag = @form_data['hasPreviouslyApplied']
@form_data['hasPreviouslyApplied'] = {
'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 format_organization
normalize_mailing_address(@form_data['organizationAddress'])
@form_data['organization'] = combine_name_addr_extras(@form_data,
'organizationName',
'organizationAddress')
end
def merge_date_helpers
%w[examDate dateSigned].each(&method(:format_date))
end
def format_date(key)
str = @form_data[key]
@form_data[key] = str.to_date.strftime(self.class.date_strftime)
end
end
end
end