Class: SavedClaim::DependencyClaim
Constant Summary
collapse
- FORM =
'686C-674'
- STUDENT_ATTENDING_COLLEGE_KEYS =
%w[
student_name_and_ssn
student_address_marriage_tuition
last_term_school_information
school_information
program_information
current_term_dates
student_earnings_from_school_year
student_networth_information
student_expected_earnings_next_year
student_does_have_networth
student_does_earn_income
student_will_earn_income_next_year
student_did_attend_school_last_term
].freeze
- DEPENDENT_CLAIM_FLOWS =
%w[
report_death
report_divorce
add_child
report_stepchild_not_in_household
report_marriage_of_child_under18
child_marriage
report_child18_or_older_is_not_attending_school
add_spouse
].freeze
Instance Method Summary
collapse
Methods inherited from SavedClaim
add_form_and_validation, #confirmation_number, #form_is_string, #form_matches_schema, #form_must_be_string, #open_struct_form, #parsed_form, #submit_to_structured_data_services!, #submitted_at, #update_form
descendants_using_encryption, lockbox_options, #timestamp_attributes_for_update_in_model, #valid?
Instance Method Details
#add_veteran_info(va_file_number_with_payload) ⇒ Object
46
47
48
|
# File 'app/models/saved_claim/dependency_claim.rb', line 46
def add_veteran_info(va_file_number_with_payload)
parsed_form.merge!(va_file_number_with_payload)
end
|
#address_exists ⇒ Object
72
73
74
75
76
|
# File 'app/models/saved_claim/dependency_claim.rb', line 72
def address_exists
if parsed_form.dig('dependents_application', 'veteran_contact_information', 'veteran_address').blank?
errors.add(:parsed_form, "Veteran address can't be blank")
end
end
|
54
55
56
|
# File 'app/models/saved_claim/dependency_claim.rb', line 54
def formatted_674_data(va_file_number_with_payload)
partitioned_686_674_params[:college_student_data].merge(va_file_number_with_payload).with_indifferent_access
end
|
50
51
52
|
# File 'app/models/saved_claim/dependency_claim.rb', line 50
def formatted_686_data(va_file_number_with_payload)
partitioned_686_674_params[:dependent_data].merge(va_file_number_with_payload).with_indifferent_access
end
|
#process_attachments! ⇒ Object
Run after a claim is saved, this processes any files/supporting documents that are present
89
90
91
92
93
94
95
96
97
98
|
# File 'app/models/saved_claim/dependency_claim.rb', line 89
def process_attachments!
child_documents = parsed_form.dig('dependents_application', 'child_supporting_documents')
spouse_documents = parsed_form.dig('dependents_application', 'spouse_supporting_documents')
supporting_documents = [child_documents, spouse_documents].compact.reduce([], :|)
if supporting_documents.present?
files = PersistentAttachment.where(guid: supporting_documents.map { |doc| doc['confirmation_code'] })
files.find_each { |f| f.update(saved_claim_id: id) }
end
end
|
#regional_office ⇒ Object
SavedClaims require regional_office to be defined
84
85
86
|
# File 'app/models/saved_claim/dependency_claim.rb', line 84
def regional_office
[]
end
|
#submittable_674? ⇒ Boolean
66
67
68
69
70
|
# File 'app/models/saved_claim/dependency_claim.rb', line 66
def submittable_674?
return false if parsed_form['view:selectable686_options']['report674'].blank?
true
end
|
#submittable_686? ⇒ Boolean
58
59
60
61
62
63
64
|
# File 'app/models/saved_claim/dependency_claim.rb', line 58
def submittable_686?
submitted_flows = DEPENDENT_CLAIM_FLOWS.map { |flow| parsed_form['view:selectable686_options'].include?(flow) }
return true if submitted_flows.include?(true)
false
end
|
#to_pdf(form_id: FORM) ⇒ Object
110
111
112
113
114
|
# File 'app/models/saved_claim/dependency_claim.rb', line 110
def to_pdf(form_id: FORM)
self.form_id = form_id
PdfFill::Filler.fill_form(self)
end
|
#upload_pdf(form_id, doc_type: '148') ⇒ Object
37
38
39
40
41
42
43
44
|
# File 'app/models/saved_claim/dependency_claim.rb', line 37
def upload_pdf(form_id, doc_type: '148')
uploaded_forms ||= []
return if uploaded_forms.include? form_id
upload_to_vbms(path: to_pdf(form_id:), doc_type:)
uploaded_forms << form_id
save
end
|
#upload_to_vbms(path:, doc_type: '148') ⇒ Object
100
101
102
103
104
105
106
107
108
|
# File 'app/models/saved_claim/dependency_claim.rb', line 100
def upload_to_vbms(path:, doc_type: '148')
uploader = ClaimsApi::VBMSUploader.new(
filepath: path,
file_number: parsed_form['veteran_information']['va_file_number'] || parsed_form['veteran_information']['ssn'],
doc_type:
)
uploader.upload!
end
|
78
79
80
81
|
# File 'app/models/saved_claim/dependency_claim.rb', line 78
def validate_686_form_data
errors.add(:parsed_form, "SSN can't be blank") if parsed_form['veteran_information']['ssn'].blank?
errors.add(:parsed_form, "Dependent application can't be blank") if parsed_form['dependents_application'].blank?
end
|