Class: BGSDependents::Veteran

Inherits:
Base show all
Defined in:
app/models/bgs_dependents/veteran.rb

Constant Summary

Constants inherited from Base

Base::MILITARY_POST_OFFICE_TYPE_CODES

Instance Attribute Summary

Attributes inherited from Common::Base

#errors_hash, #metadata

Instance Method Summary collapse

Methods inherited from Base

#adjust_address_lines_for!, #adjust_country_name_for!, #create_address_params, #create_person_params, #dependent_address, #format_date, #formatted_boolean, #generate_address, #relationship_type, #serialize_dependent_result

Methods inherited from Common::Base

#changed, #changed?, #changes, default_sort, filterable_attributes, max_per_page, per_page, sortable_attributes

Constructor Details

#initialize(proc_id, user) ⇒ Veteran

Returns a new instance of Veteran.



11
12
13
14
15
# File 'app/models/bgs_dependents/veteran.rb', line 11

def initialize(proc_id, user)
  @proc_id = proc_id
  @user = user
  self.attributes = user_veteran_attributes
end

Instance Method Details

#formatted_params(payload) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/models/bgs_dependents/veteran.rb', line 17

def formatted_params(payload)
  dependents_application = payload['dependents_application']

  vet_info = [
    *payload['veteran_information'],
    ['first', first_name],
    ['middle', middle_name],
    ['last', last_name],
    *dependents_application['veteran_contact_information'],
    *dependents_application.dig('veteran_contact_information', 'veteran_address'),
    %w[vet_ind Y]
  ]

  if dependents_application['current_marriage_information']
    vet_info << ['martl_status_type_cd', marital_status(dependents_application)]
  end

  vet_info.to_h
end

#veteran_response(participant, address, claim_info) ⇒ Object

rubocop:disable Metrics/MethodLength



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
# File 'app/models/bgs_dependents/veteran.rb', line 38

def veteran_response(participant, address, claim_info)
  {
    vnp_participant_id: participant[:vnp_ptcpnt_id],
    first_name:,
    last_name:,
    vnp_participant_address_id: address[:vnp_ptcpnt_addrs_id],
    file_number: claim_info[:va_file_number],
    address_line_one: address[:addrs_one_txt],
    address_line_two: address[:addrs_two_txt],
    address_line_three: address[:addrs_three_txt],
    address_country: address[:cntry_nm],
    address_state_code: address[:postal_cd],
    address_city: address[:city_nm],
    address_zip_code: address[:zip_prefix_nbr],
    address_type: address[:address_type],
    mlty_postal_type_cd: address[:mlty_postal_type_cd],
    mlty_post_office_type_cd: address[:mlty_post_office_type_cd],
    foreign_mail_code: address[:frgn_postal_cd],
    type: 'veteran',
    benefit_claim_type_end_product: claim_info[:claim_type_end_product],
    regional_office_number: claim_info[:regional_office_number],
    location_id: claim_info[:location_id],
    net_worth_over_limit_ind: claim_info[:net_worth_over_limit_ind]
  }
end