Class: PdfFill::Forms::Va21p0969
- Includes:
- ActiveSupport::NumberHelper
- Defined in:
- lib/pdf_fill/forms/va21p0969.rb
Constant Summary collapse
- ITERATOR =
PdfFill::HashConverter::ITERATOR
- CLAIMANT_TYPES =
{ 'VETERAN' => 0, 'SPOUSE' => 1, 'CHILD' => 2, 'PARENT' => 3, 'CUSTODIAN' => 4 }.freeze
- RECIPIENTS =
{ 'VETERAN' => 0, 'SPOUSE' => 1, 'CUSTODIAN' => 2, 'CHILD' => 3, 'PARENT' => 4, 'OTHER' => 5 }.freeze
- INCOME_TYPES =
{ 'SOCIAL_SECURITY' => 0, 'RETIREMENT_PENSION' => 1, 'WAGES' => 2, 'UNEMPLOYMENT' => 3, 'CIVIL_SERVICE' => 4, 'OTHER' => 5 }.freeze
- KEY =
{ # 1a 'veteranFullName' => { # form allows up to 39 characters but validation limits to 30, # so no overflow is needed 'first' => { key: 'F[0].Page_4[0].VeteransName.First[0]' }, 'middle' => { key: 'F[0].Page_4[0].VeteransName.MI[0]' }, # form allows up to 34 characters but validation limits to 30, # so no overflow is needed 'last' => { key: 'F[0].Page_4[0].VeteransName.Last[0]' } }, # 1b 'veteranSocialSecurityNumber' => { key: 'F[0].Page_4[0].VeteransSSN[0]' }, # 1c 'vaFileNumber' => { key: 'F[0].Page_4[0].VeteransFileNumber[0]' }, # 2a 'claimantFullName' => { # form allows up to 39 characters but validation limits to 30, # so no overflow is needed 'first' => { key: 'F[0].Page_4[0].ClaimantsName.First[0]' }, 'middle' => { key: 'F[0].Page_4[0].ClaimantsName.MI[0]' }, # form allows up to 34 characters but validation limits to 30, # so no overflow is needed 'last' => { key: 'F[0].Page_4[0].ClaimantsName.Last[0]' } }, # 2b 'claimantSocialSecurityNumber' => { key: 'F[0].Page_4[0].ClaimantsSSN[0]' }, # 2c 'claimantPhone' => { key: 'F[0].Page_4[0].ClaimantTelephoneNumber[0]' }, # 2d 'claimantType' => { key: 'F[0].Page_4[0].TypeofClaimant[0]' }, # 2e 'incomeNetWorthDateRange' => { 'from' => { key: 'F[0].Page_4[0].DateStarting[0]' }, 'to' => { key: 'F[0].Page_4[0].DateEnding[0]' }, 'useDateReceivedByVA' => { key: 'F[0].Page_4[0].DateReceivedByVA[0]' } }, # 3a 'unassociatedIncome' => { key: 'F[0].Page_4[0].DependentsReceiving3a[0]' }, # 3b - 3f 'unassociatedIncomes' => { limit: 5, first_key: 'recipientRelationship', 'recipientRelationship' => { key: "F[0].IncomeRecipients3[#{ITERATOR}]" }, 'recipientRelationshipOverflow' => { question_num: 3, question_suffix: '(1)', question_text: "SPECIFY INCOME RECIPIENT'S RELATIONSHIP TO VETERAN" }, 'otherRecipientRelationshipType' => { key: "F[0].OtherRelationship3[#{ITERATOR}]", question_num: 3, question_suffix: '(1)', question_text: "SPECIFY INCOME RECIPIENT'S RELATIONSHIP TO VETERAN" }, 'recipientName' => { key: "F[0].NameofIncomeRecipient3[#{ITERATOR}]", question_num: 3, question_suffix: '(2)', question_text: 'SPECIFY NAME OF INCOME RECIPIENT (Only needed if Custodian of child, child, parent, or other)' }, 'incomeType' => { key: "F[0].TypeOfIncome3[#{ITERATOR}]" }, 'incomeTypeOverflow' => { question_num: 3, question_suffix: '(3)', question_text: 'SPECIFY THE TYPE OF INCOME' }, 'otherIncomeType' => { key: "F[0].OtherIncomeType3[#{ITERATOR}]", question_num: 3, question_suffix: '(3)', question_text: 'SPECIFY THE TYPE OF INCOME' }, 'grossMonthlyIncome' => { 'thousands' => { key: "F[0].GrossMonthlyIncome1_3[#{ITERATOR}]" }, 'dollars' => { key: "F[0].GrossMonthlyIncome2_3[#{ITERATOR}]" }, 'cents' => { key: "F[0].GrossMonthlyIncome3_3[#{ITERATOR}]" } }, 'grossMonthlyIncomeOverflow' => { question_num: 3, question_suffix: '(4)', question_text: 'GROSS MONTHLY INCOME' }, 'payer' => { key: "F[0].IncomePayer3[#{ITERATOR}]", question_num: 3, question_suffix: '(5)', question_text: 'SPECIFY INCOME PAYER (Name of business, financial institution, or program, etc.)' } } }.freeze
Instance Attribute Summary
Attributes inherited from FormBase
Instance Method Summary collapse
- #expand_claimant_info ⇒ Object private
-
#expand_unassociated_income(income) ⇒ Object
private
:reek:FeatureEnvy.
- #expand_unassociated_incomes ⇒ Object private
- #expand_veteran_info ⇒ Object private
-
#format_date_to_mm_dd_yyyy(date_string) ⇒ String
private
Format a YYYY-MM-DD date string to MM/DD/YYYY.
-
#get_currency_field(arr, neg_i, field_length) ⇒ Object
private
:reek:FeatureEnvy.
-
#merge_fields(_options = {}) ⇒ Hash
Post-process form data to match the expected format.
- #split_currency_amount(amount) ⇒ Object private
Methods inherited from FormBase
#combine_both_addr, #combine_full_address, #combine_full_address_extras, #combine_full_name, #combine_hash, #combine_name_addr, #combine_name_addr_extras, #combine_postal_code, #combine_previous_names, date_strftime, #expand_checkbox, #expand_date_range, #expand_signature, #initialize
Constructor Details
This class inherits a constructor from PdfFill::Forms::FormBase
Instance Method Details
#expand_claimant_info ⇒ Object (private)
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/pdf_fill/forms/va21p0969.rb', line 194 def claimant_middle_name = form_data['claimantFullName'].try(:[], 'middle') claimant_type = form_data['claimantType'] net_worth_date_range = form_data['incomeNetWorthDateRange'] form_data['claimantFullName']['middle'] = claimant_middle_name[0].upcase if claimant_middle_name.present? form_data['claimantType'] = CLAIMANT_TYPES[claimant_type] if net_worth_date_range.blank? || net_worth_date_range['from'].blank? || net_worth_date_range['to'].blank? form_data['incomeNetWorthDateRange'] = { 'from' => nil, 'to' => nil, 'useDateReceivedByVA' => true } else form_data['incomeNetWorthDateRange'] = { 'from' => format_date_to_mm_dd_yyyy(net_worth_date_range['from']), 'to' => format_date_to_mm_dd_yyyy(net_worth_date_range['to']), 'useDateReceivedByVA' => false } end end |
#expand_unassociated_income(income) ⇒ Object (private)
:reek:FeatureEnvy
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/pdf_fill/forms/va21p0969.rb', line 227 def (income) recipient_relationship = income['recipientRelationship'] income_type = income['incomeType'] gross_monthly_income = income['grossMonthlyIncome'] { 'recipientRelationship' => RECIPIENTS[recipient_relationship], 'recipientRelationshipOverflow' => recipient_relationship, 'otherRecipientRelationshipType' => income['otherRecipientRelationshipType'], 'recipientName' => income['recipientName'], 'incomeType' => INCOME_TYPES[income_type], 'incomeTypeOverflow' => income_type, 'otherIncomeType' => income['otherIncomeType'], 'grossMonthlyIncome' => gross_monthly_income ? split_currency_amount(gross_monthly_income) : {}, 'grossMonthlyIncomeOverflow' => gross_monthly_income, 'payer' => income['payer'] } end |
#expand_unassociated_incomes ⇒ Object (private)
218 219 220 221 222 223 224 |
# File 'lib/pdf_fill/forms/va21p0969.rb', line 218 def unassociated_incomes = form_data['unassociatedIncomes'] form_data['unassociatedIncome'] = unassociated_incomes&.length ? 'YES' : 1 form_data['unassociatedIncomes'] = unassociated_incomes&.map do |income| (income) end end |
#expand_veteran_info ⇒ Object (private)
189 190 191 192 |
# File 'lib/pdf_fill/forms/va21p0969.rb', line 189 def veteran_middle_name = form_data['veteranFullName'].try(:[], 'middle') form_data['veteranFullName']['middle'] = veteran_middle_name.try(:[], 0)&.upcase end |
#format_date_to_mm_dd_yyyy(date_string) ⇒ String (private)
Format a YYYY-MM-DD date string to MM/DD/YYYY
251 252 253 254 255 |
# File 'lib/pdf_fill/forms/va21p0969.rb', line 251 def format_date_to_mm_dd_yyyy(date_string) return nil if date_string.blank? Date.parse(date_string).strftime('%m/%d/%Y') end |
#get_currency_field(arr, neg_i, field_length) ⇒ Object (private)
:reek:FeatureEnvy
269 270 271 272 |
# File 'lib/pdf_fill/forms/va21p0969.rb', line 269 def get_currency_field(arr, neg_i, field_length) value = arr.length >= -neg_i ? arr[neg_i] : 0 format("%0#{field_length}d", value.to_i) end |
#merge_fields(_options = {}) ⇒ Hash
Post-process form data to match the expected format. Each section of the form is processed in its own expand function.
179 180 181 182 183 184 185 |
# File 'lib/pdf_fill/forms/va21p0969.rb', line 179 def merge_fields( = {}) form_data end |
#split_currency_amount(amount) ⇒ Object (private)
257 258 259 260 261 262 263 264 265 266 |
# File 'lib/pdf_fill/forms/va21p0969.rb', line 257 def split_currency_amount(amount) return {} if amount.negative? || amount >= 100_000 arr = number_to_currency(amount).to_s.split(/[,.$]/).reject(&:empty?) { 'cents' => get_currency_field(arr, -1, 2), 'dollars' => get_currency_field(arr, -2, 3), 'thousands' => get_currency_field(arr, -3, 2) } end |