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, #after_create_metrics, #after_destroy_metrics, #attachment_keys, #business_line, #confirmation_number, #email, #form_is_string, #form_matches_schema, #form_must_be_string, #insert_notification, #open_struct_form, #parsed_form, #submitted_at, #update_form, #va_notification?, #validate_form, #validate_schema
descendants_using_encryption, lockbox_options, #timestamp_attributes_for_update_in_model, #valid?
Instance Method Details
#add_veteran_info(va_file_number_with_payload) ⇒ Object
67
68
69
|
# File 'app/models/saved_claim/dependency_claim.rb', line 67
def add_veteran_info(va_file_number_with_payload)
parsed_form.merge!(va_file_number_with_payload)
end
|
#address_exists ⇒ Object
93
94
95
96
97
|
# File 'app/models/saved_claim/dependency_claim.rb', line 93
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
|
75
76
77
|
# File 'app/models/saved_claim/dependency_claim.rb', line 75
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
|
71
72
73
|
# File 'app/models/saved_claim/dependency_claim.rb', line 71
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
|
#partitioned_686_674_params ⇒ Object
171
172
173
174
175
176
177
178
179
|
# File 'app/models/saved_claim/dependency_claim.rb', line 171
def partitioned_686_674_params
dependent_data = parsed_form
student_data = dependent_data['dependents_application'].(*STUDENT_ATTENDING_COLLEGE_KEYS)
veteran_data = dependent_data['dependents_application'].slice('household_income', 'veteran_contact_information')
college_student_data = { 'dependents_application' => student_data.merge!(veteran_data) }
{ college_student_data:, dependent_data: }
end
|
#process_attachments! ⇒ Object
Run after a claim is saved, this processes any files/supporting documents that are present
110
111
112
113
114
115
116
117
118
119
|
# File 'app/models/saved_claim/dependency_claim.rb', line 110
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
|
#process_pdf(pdf_path, timestamp = nil, form_id = nil) ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'app/models/saved_claim/dependency_claim.rb', line 51
def process_pdf(pdf_path, timestamp = nil, form_id = nil)
processed_pdf = PDFUtilities::DatestampPdf.new(pdf_path).run(
text: 'Application Submitted on va.gov',
x: form_id == '686C-674' ? 400 : 300,
y: form_id == '686C-674' ? 675 : 775,
text_only: true, timestamp:,
page_number: form_id == '686C-674' ? 6 : 0,
template: "lib/pdf_fill/forms/pdfs/#{form_id}.pdf",
multistamp: true
)
renamed_path = "tmp/pdfs/#{form_id}_#{id}_final.pdf"
File.rename(processed_pdf, renamed_path) renamed_path end
|
#regional_office ⇒ Object
SavedClaims require regional_office to be defined
105
106
107
|
# File 'app/models/saved_claim/dependency_claim.rb', line 105
def regional_office
[]
end
|
#send_failure_email(email) ⇒ Object
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
# File 'app/models/saved_claim/dependency_claim.rb', line 142
def send_failure_email(email) template_id = if submittable_686? && submittable_674?
Settings.vanotify.services.va_gov.template_id.form21_686c_674_action_needed_email
elsif submittable_686?
Settings.vanotify.services.va_gov.template_id.form21_686c_action_needed_email
elsif submittable_674?
Settings.vanotify.services.va_gov.template_id.form21_674_action_needed_email
else
Rails.logger.error('Email template cannot be assigned for SavedClaim', saved_claim_id: id)
nil
end
if email.present? && template_id.present?
VANotify::EmailJob.perform_async(
email,
template_id,
{
'first_name' => parsed_form.dig('veteran_information', 'full_name', 'first')&.upcase.presence,
'date_submitted' => Time.zone.today.strftime('%B %d, %Y'),
'confirmation_number' => confirmation_number
}
)
end
end
|
#submittable_674? ⇒ Boolean
87
88
89
90
91
|
# File 'app/models/saved_claim/dependency_claim.rb', line 87
def submittable_674?
return false if parsed_form['view:selectable686_options']['report674'].blank?
true
end
|
#submittable_686? ⇒ Boolean
79
80
81
82
83
84
85
|
# File 'app/models/saved_claim/dependency_claim.rb', line 79
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
131
132
133
134
135
|
# File 'app/models/saved_claim/dependency_claim.rb', line 131
def to_pdf(form_id: FORM)
self.form_id = form_id
PdfFill::Filler.fill_form(self, nil, { created_at: })
end
|
#upload_pdf(form_id, doc_type: '148') ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'app/models/saved_claim/dependency_claim.rb', line 38
def upload_pdf(form_id, doc_type: '148')
uploaded_forms ||= []
return if uploaded_forms.include? form_id
upload_to_vbms(path: process_pdf(to_pdf(form_id:), created_at, form_id), doc_type:)
uploaded_forms << form_id
save
rescue => e
Rails.logger.debug('DependencyClaim: Issue Uploading to VBMS in upload_pdf method',
{ saved_claim_id: id, form_id:, error: e })
raise e
end
|
#upload_to_vbms(path:, doc_type: '148') ⇒ Object
121
122
123
124
125
126
127
128
129
|
# File 'app/models/saved_claim/dependency_claim.rb', line 121
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
|
99
100
101
102
|
# File 'app/models/saved_claim/dependency_claim.rb', line 99
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
|