Class: FormProfiles::VA5655

Inherits:
FormProfile
  • Object
show all
Defined in:
app/models/form_profiles/va_5655.rb

Overview

Form Profile for VA Form 5655, the Financial Status Report Form

Instance Method Summary collapse

Instance Method Details

#init_paymentsObject (private)



51
52
53
54
55
56
57
58
59
60
61
# File 'app/models/form_profiles/va_5655.rb', line 51

def init_payments
  return {} unless user.authorize :debt, :access?

  payments = DebtManagementCenter::PaymentsService.new(user)

  DebtManagementCenter::Payment.new(
    education_amount: payment_amount(payments.education),
    compensation_amount: payment_amount(payments.compensation_and_pension),
    veteran_or_spouse: 'VETERAN'
  )
end

#metadataHash

Overrides the FormProfile metadata method, to provide frontend with usable metadata

Returns:

  • (Hash)


17
18
19
20
21
22
23
# File 'app/models/form_profiles/va_5655.rb', line 17

def 
  {
    version: 0,
    prefill: true,
    returnUrl: '/veteran-information'
  }
end

#payment_amount(payments) ⇒ Object (private)



63
64
65
66
67
68
69
70
71
# File 'app/models/form_profiles/va_5655.rb', line 63

def payment_amount(payments)
  return payments&.last&.[](:payment_amount) if Settings.dmc.fsr_payment_window.blank?

  # Window of time to consider included payments (in days)
  window = Time.zone.today - Settings.dmc.fsr_payment_window.days

  # Filter to only use recent payments from window of time
  payments&.select { |payment| Date.parse(payment[:payment_date].to_s) > window }&.last&.[](:payment_amount)
end

#prefillHash

Overrides the FormProfile prefill method to initialize @va_awards_composite

Returns:

  • (Hash)


30
31
32
33
# File 'app/models/form_profiles/va_5655.rb', line 30

def prefill
  @payments = init_payments
  super
end

#va_file_number_last_fourObject (private)



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/models/form_profiles/va_5655.rb', line 37

def va_file_number_last_four
  return unless user.authorize :debt, :access?

  file_number =
    begin
      response = BGS::People::Request.new.find_person_by_participant_id(user:)
      response.file_number.presence || user.ssn
    rescue
      user.ssn
    end

  file_number&.last(4)
end