Class: BGS::Form686c

Inherits:
Object
  • Object
show all
Includes:
SentryLogging
Defined in:
lib/bgs/form686c.rb

Constant Summary collapse

REMOVE_CHILD_OPTIONS =
%w[report_child18_or_older_is_not_attending_school
report_stepchild_not_in_household
report_marriage_of_child_under18].freeze
MARRIAGE_TYPES =
%w[COMMON-LAW TRIBAL PROXY OTHER].freeze
RELATIONSHIPS =
%w[CHILD DEPENDENT_PARENT].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SentryLogging

#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger

Constructor Details

#initialize(user, saved_claim) ⇒ Form686c

Returns a new instance of Form686c.



26
27
28
29
30
31
32
33
# File 'lib/bgs/form686c.rb', line 26

def initialize(user, saved_claim)
  @user = user
  @saved_claim = saved_claim
  @end_product_name = '130 - Automated Dependency 686c'
  @end_product_code = '130DPNEBNADJ'
  @proc_state = 'Ready'
  @note_text = nil
end

Instance Attribute Details

#saved_claimObject (readonly)

Returns the value of attribute saved_claim.



18
19
20
# File 'lib/bgs/form686c.rb', line 18

def saved_claim
  @saved_claim
end

#userObject (readonly)

Returns the value of attribute user.



18
19
20
# File 'lib/bgs/form686c.rb', line 18

def user
  @user
end

Instance Method Details

#submit(payload) ⇒ Object

rubocop:disable Metrics/MethodLength



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
# File 'lib/bgs/form686c.rb', line 36

def submit(payload)
  vnp_proc_state_type_cd = get_state_type(payload)
  proc_id = create_proc_id_and_form(vnp_proc_state_type_cd)
  veteran = VnpVeteran.new(proc_id:, payload:, user:, claim_type: '130DPNEBNADJ').create

  process_relationships(proc_id, veteran, payload)

  vnp_benefit_claim = VnpBenefitClaim.new(proc_id:, veteran:, user:)
  vnp_benefit_claim_record = vnp_benefit_claim.create

  set_claim_type(vnp_proc_state_type_cd, payload['view:selectable686_options'])

  # temporary logging to troubleshoot
  log_message_to_sentry("#{proc_id} - #{@end_product_code}", :warn, '', { team: 'vfs-ebenefits' })

  benefit_claim_record = BenefitClaim.new(
    args: {
      vnp_benefit_claim: vnp_benefit_claim_record,
      veteran:,
      user:,
      proc_id:,
      end_product_name: @end_product_name,
      end_product_code: @end_product_code
    }
  ).create

  begin
    benefit_claim_id = benefit_claim_record[:benefit_claim_id]
    # temporary logging to troubleshoot
    log_message_to_sentry("#{proc_id} - #{benefit_claim_id}", :warn, '', { team: 'vfs-ebenefits' })

    vnp_benefit_claim.update(benefit_claim_record, vnp_benefit_claim_record)
    prep_manual_claim(benefit_claim_id) if vnp_proc_state_type_cd == 'MANUAL_VAGOV'
    bgs_service.update_proc(proc_id, proc_state: @proc_state)
  rescue => e
    Rails.logger.warning('BGS::Form686c.submit failed after creating benefit claim in BGS',
                         {
                           user_uuid: user.uuid,
                           saved_claim_id: saved_claim.id,
                           icn: user.icn,
                           error: e.message
                         })
  end
end