Class: EVSS::DisabilityCompensationForm::EVSSDocument

Inherits:
Object
  • Object
show all
Defined in:
app/sidekiq/evss/disability_compensation_form/evss_document.rb

Overview

Base document class for the 526 ancillary forms

Direct Known Subclasses

Form8940Document

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pdf_pathObject (readonly)

The file path of the PDF



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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
# File 'app/sidekiq/evss/disability_compensation_form/evss_document.rb', line 12

class EVSSDocument
  # @return [String] the contents of the file
  #
  def file_body
    File.open(@pdf_path).read
  end

  # @return [EVSSClaimDocument] A new claim document instance
  #
  def data
    @document_data
  end

  attr_reader :pdf_path

  private

  # Invokes Filler ancillary form method to generate PDF document
  # Then calls method PDFUtilities::DatestampPdf to stamp the document.
  # Its called twice, once to stamp with text "VA.gov YYYY-MM-DD" at the bottom of each page
  # and second time to stamp with text "VA.gov Submission" at the top of each page
  def generate_stamp_pdf(form_content, , form_id)
    pdf_path = PdfFill::Filler.fill_ancillary_form(form_content, , form_id)
    stamped_path1 = PDFUtilities::DatestampPdf.new(pdf_path).run(text: 'VA.gov', x: 5, y: 5)
    PDFUtilities::DatestampPdf.new(stamped_path1).run(
      text: 'VA.gov Submission',
      x: 510,
      y: 775,
      text_only: true
    )
  end

  def (pdf_path, doc_type)
    pdf_path_split = pdf_path.split('/')
    {
      doc_type:,
      file_name: pdf_path_split.last
    }
  end

  def create_document_data(evss_claim_id, upload_data, doc_type)
    EVSSClaimDocument.new(
      evss_claim_id:,
      file_name: upload_data[:file_name],
      tracked_item_id: nil,
      document_type: doc_type
    )
  end
end

Instance Method Details

#create_document_data(evss_claim_id, upload_data, doc_type) ⇒ Object (private)



52
53
54
55
56
57
58
59
# File 'app/sidekiq/evss/disability_compensation_form/evss_document.rb', line 52

def create_document_data(evss_claim_id, upload_data, doc_type)
  EVSSClaimDocument.new(
    evss_claim_id:,
    file_name: upload_data[:file_name],
    tracked_item_id: nil,
    document_type: doc_type
  )
end

#dataEVSSClaimDocument

Returns A new claim document instance.

Returns:



21
22
23
# File 'app/sidekiq/evss/disability_compensation_form/evss_document.rb', line 21

def data
  @document_data
end

#file_bodyString

Returns the contents of the file.

Returns:

  • (String)

    the contents of the file



15
16
17
# File 'app/sidekiq/evss/disability_compensation_form/evss_document.rb', line 15

def file_body
  File.open(@pdf_path).read
end

#generate_stamp_pdf(form_content, submitted_claim_id, form_id) ⇒ Object (private)

Invokes Filler ancillary form method to generate PDF document Then calls method PDFUtilities::DatestampPdf to stamp the document. Its called twice, once to stamp with text “VA.gov YYYY-MM-DD” at the bottom of each page and second time to stamp with text “VA.gov Submission” at the top of each page



33
34
35
36
37
38
39
40
41
42
# File 'app/sidekiq/evss/disability_compensation_form/evss_document.rb', line 33

def generate_stamp_pdf(form_content, , form_id)
  pdf_path = PdfFill::Filler.fill_ancillary_form(form_content, , form_id)
  stamped_path1 = PDFUtilities::DatestampPdf.new(pdf_path).run(text: 'VA.gov', x: 5, y: 5)
  PDFUtilities::DatestampPdf.new(stamped_path1).run(
    text: 'VA.gov Submission',
    x: 510,
    y: 775,
    text_only: true
  )
end

#get_evss_claim_metadata(pdf_path, doc_type) ⇒ Object (private)



44
45
46
47
48
49
50
# File 'app/sidekiq/evss/disability_compensation_form/evss_document.rb', line 44

def (pdf_path, doc_type)
  pdf_path_split = pdf_path.split('/')
  {
    doc_type:,
    file_name: pdf_path_split.last
  }
end