Class: SavedClaim::Burial

Inherits:
SavedClaim show all
Defined in:
app/models/saved_claim/burial.rb

Constant Summary collapse

FORM =
'21P-530'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from SavedClaim

add_form_and_validation, #after_create_metrics, #after_destroy_metrics, #confirmation_number, #form_is_string, #form_must_be_string, #insert_notification, #open_struct_form, #parsed_form, #submitted_at, #to_pdf, #update_form, #va_notification?, #validate_form, #validate_schema

Methods inherited from ApplicationRecord

descendants_using_encryption, lockbox_options, #timestamp_attributes_for_update_in_model, #valid?

Instance Attribute Details

#formV2Object

attribute name is passed from the FE as a flag, maintaining camel case



9
10
11
# File 'app/models/saved_claim/burial.rb', line 9

def formV2
  @formV2
end

Instance Method Details

#attachment_keysObject



29
30
31
# File 'app/models/saved_claim/burial.rb', line 29

def attachment_keys
  %i[transportationReceipts deathCertificate militarySeparationDocuments additionalEvidence].freeze
end

#benefits_claimedObject



82
83
84
85
86
87
88
# File 'app/models/saved_claim/burial.rb', line 82

def benefits_claimed
  claimed = []
  claimed << 'Burial Allowance' if parsed_form['burialAllowance']
  claimed << 'Plot Allowance' if parsed_form['plotAllowance']
  claimed << 'Transportation' if parsed_form['transportation']
  claimed
end

#business_lineObject



61
62
63
# File 'app/models/saved_claim/burial.rb', line 61

def business_line
  'NCA'
end

#claimaint_first_nameObject



78
79
80
# File 'app/models/saved_claim/burial.rb', line 78

def claimaint_first_name
  parsed_form.dig('claimantFullName', 'first')
end

#emailObject



33
34
35
# File 'app/models/saved_claim/burial.rb', line 33

def email
  parsed_form['claimantEmail']
end

#form_matches_schemaObject



37
38
39
40
41
42
43
# File 'app/models/saved_claim/burial.rb', line 37

def form_matches_schema
  return unless form_is_string

  JSON::Validator.fully_validate(VetsJsonSchema::SCHEMAS[form_id], parsed_form).each do |v|
    errors.add(:form, v.to_s)
  end
end

#process_attachments!Object



19
20
21
22
23
# File 'app/models/saved_claim/burial.rb', line 19

def process_attachments!
  refs = attachment_keys.map { |key| Array(open_struct_form.send(key)) }.flatten
  files = PersistentAttachment.where(guid: refs.map(&:confirmationCode))
  files.find_each { |f| f.update(saved_claim_id: id) }
end

#process_pdf(pdf_path, timestamp = nil, form_id = nil) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'app/models/saved_claim/burial.rb', line 45

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: 400,
    y: 675,
    text_only: true, # passing as text only because we override how the date is stamped in this instance
    timestamp:,
    page_number: 6,
    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) # rename for vbms upload
  renamed_path # return the renamed path
end

#regional_officeObject



25
26
27
# File 'app/models/saved_claim/burial.rb', line 25

def regional_office
  PensionBurial::ProcessingOffice.address_for(open_struct_form.claimantAddress.postalCode)
end

#veteran_first_nameString

utility function to retrieve claimant first name from form

Returns:

  • (String)

    the claimant first name



70
71
72
# File 'app/models/saved_claim/burial.rb', line 70

def veteran_first_name
  parsed_form.dig('veteranFullName', 'first')
end

#veteran_last_nameObject



74
75
76
# File 'app/models/saved_claim/burial.rb', line 74

def veteran_last_name
  parsed_form.dig('veteranFullName', 'last')
end