Class: BGSDependents::Child

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

Constant Summary collapse

CHILD_STATUS =
{
  'stepchild' => 'Stepchild',
  'biological' => 'Biological',
  'adopted' => 'Adopted Child',
  'disabled' => 'Other',
  'child_under18' => 'Other',
  'child_over18_in_school' => 'Other'
}.freeze

Constants inherited from Base

Base::MILITARY_POST_OFFICE_TYPE_CODES

Instance Attribute Summary collapse

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(child_info) ⇒ Child

Returns a new instance of Child.



58
59
60
61
# File 'app/models/bgs_dependents/child.rb', line 58

def initialize(child_info)
  @child_info = child_info
  self.attributes = child_attributes
end

Instance Attribute Details

#child_incomeString

Returns did this child have income in the last 365 days.

Returns:

  • (String)

    did this child have income in the last 365 days



30
# File 'app/models/bgs_dependents/child.rb', line 30

attribute :ssn, String

#ever_married_indString

Returns Y/N indicates whether the person has ever been married.

Returns:

  • (String)

    Y/N indicates whether the person has ever been married



30
# File 'app/models/bgs_dependents/child.rb', line 30

attribute :ssn, String

#family_relationship_typeString

Returns family relationship type: Biological/Stepchild/Adopted Child/Other.

Returns:

  • (String)

    family relationship type: Biological/Stepchild/Adopted Child/Other



30
# File 'app/models/bgs_dependents/child.rb', line 30

attribute :ssn, String

#firstString

Returns the person’s first name.

Returns:

  • (String)

    the person’s first name



30
# File 'app/models/bgs_dependents/child.rb', line 30

attribute :ssn, String

#lastString

Returns the person’s last name.

Returns:

  • (String)

    the person’s last name



30
# File 'app/models/bgs_dependents/child.rb', line 30

attribute :ssn, String

#middleString

Returns the person’s middle name.

Returns:

  • (String)

    the person’s middle name



30
# File 'app/models/bgs_dependents/child.rb', line 30

attribute :ssn, String

#place_of_birth_cityString

Returns city where child was born.

Returns:

  • (String)

    city where child was born



30
# File 'app/models/bgs_dependents/child.rb', line 30

attribute :ssn, String

#place_of_birth_stateString

Returns state where child was born.

Returns:

  • (String)

    state where child was born



30
# File 'app/models/bgs_dependents/child.rb', line 30

attribute :ssn, String

#reason_marriage_endedString

Returns reason child marriage ended.

Returns:

  • (String)

    reason child marriage ended



30
# File 'app/models/bgs_dependents/child.rb', line 30

attribute :ssn, String

#ssnString

Returns the person’s social security number.

Returns:

  • (String)

    the person’s social security number



30
# File 'app/models/bgs_dependents/child.rb', line 30

attribute :ssn, String

#suffixString

Returns the person’s name suffix.

Returns:

  • (String)

    the person’s name suffix



30
# File 'app/models/bgs_dependents/child.rb', line 30

attribute :ssn, String

Instance Method Details

#address(dependents_application) ⇒ Hash

Sets a hash with address information based on the submitted form information

Parameters:

  • dependents_application (Hash)

    the submitted form information

Returns:

  • (Hash)

    child address



76
77
78
79
80
81
82
# File 'app/models/bgs_dependents/child.rb', line 76

def address(dependents_application)
  dependent_address(
    dependents_application:,
    lives_with_vet: @child_info['does_child_live_with_you'],
    alt_address: @child_info.dig('child_address_info', 'address')
  )
end

#child_attributesObject (private)



86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'app/models/bgs_dependents/child.rb', line 86

def child_attributes
  {
    ssn: @child_info['ssn'],
    birth_date: @child_info['birth_date'],
    family_relationship_type: child_status,
    place_of_birth_country: @child_info.dig('place_of_birth', 'country'),
    place_of_birth_state: @child_info.dig('place_of_birth', 'state'),
    place_of_birth_city: @child_info.dig('place_of_birth', 'city'),
    reason_marriage_ended: @child_info.dig('previous_marriage_details', 'reason_marriage_ended'),
    ever_married_ind: marriage_indicator,
    child_income: formatted_boolean(@child_info['child_income']),
    not_self_sufficient: formatted_boolean(@child_info['not_self_sufficient'])
  }.merge(@child_info['full_name'])
end

#child_statusObject (private)



101
102
103
# File 'app/models/bgs_dependents/child.rb', line 101

def child_status
  CHILD_STATUS[@child_info['child_status']&.key(true)]
end

#format_infoHash

Sets a hash with child attributes

Returns:

  • (Hash)

    child attributes including name, address and birth info



67
68
69
# File 'app/models/bgs_dependents/child.rb', line 67

def format_info
  attributes.with_indifferent_access
end

#marriage_indicatorObject (private)



105
106
107
# File 'app/models/bgs_dependents/child.rb', line 105

def marriage_indicator
  @child_info['previously_married'] == 'Yes' ? 'Y' : 'N'
end