Class: EVSS::DisabilityCompensationForm::Form4142Processor
- Inherits:
-
Object
- Object
- EVSS::DisabilityCompensationForm::Form4142Processor
- Defined in:
- lib/evss/disability_compensation_form/form4142_processor.rb
Overview
A Form4142Processor handles the work of generating a stamped PDF and a request body for a 4142 CentralMail submission
Constant Summary collapse
- FORM_ID =
'21-4142'
Instance Attribute Summary collapse
-
#pdf_path ⇒ Pathname
readonly
The generated PDF path.
-
#request_body ⇒ Hash
readonly
The generated request body.
Instance Method Summary collapse
- #form4142 ⇒ Object private
- #generate_metadata(jid) ⇒ Object private
-
#generate_stamp_pdf ⇒ Pathname
Invokes Filler ancillary form method to generate PDF document Then calls method PDFUtilities::DatestampPdf to stamp the document.
-
#initialize(submission, jid) ⇒ EVSS::DisabilityCompensationForm::Form4142Processor
constructor
An instance of this class.
- #received_date ⇒ Object private
- #set_signature_date(incoming_data) ⇒ Object private
- #submission_date ⇒ Object private
- #to_faraday_upload ⇒ Object private
Constructor Details
#initialize(submission, jid) ⇒ EVSS::DisabilityCompensationForm::Form4142Processor
Returns an instance of this class.
32 33 34 35 36 37 38 39 |
# File 'lib/evss/disability_compensation_form/form4142_processor.rb', line 32 def initialize(submission, jid) @submission = submission @pdf_path = generate_stamp_pdf @request_body = { 'document' => to_faraday_upload, 'metadata' => (jid) } end |
Instance Attribute Details
#pdf_path ⇒ Pathname (readonly)
Returns the generated PDF path.
20 21 22 |
# File 'lib/evss/disability_compensation_form/form4142_processor.rb', line 20 def pdf_path @pdf_path end |
#request_body ⇒ Hash (readonly)
Returns the generated request body.
23 24 25 |
# File 'lib/evss/disability_compensation_form/form4142_processor.rb', line 23 def request_body @request_body end |
Instance Method Details
#form4142 ⇒ Object (private)
102 103 104 |
# File 'lib/evss/disability_compensation_form/form4142_processor.rb', line 102 def form4142 @form4142 ||= set_signature_date(@submission.form[Form526Submission::FORM_4142]) end |
#generate_metadata(jid) ⇒ Object (private)
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/evss/disability_compensation_form/form4142_processor.rb', line 71 def (jid) address = form4142['veteranAddress'] country_is_us = address['country'] == 'USA' veteran_full_name = form4142['veteranFullName'] = { 'veteranFirstName' => veteran_full_name['first'], 'veteranLastName' => veteran_full_name['last'], 'fileNumber' => form4142['vaFileNumber'] || form4142['veteranSocialSecurityNumber'], 'receiveDt' => received_date, 'uuid' => jid, 'zipCode' => address['postalCode'], 'source' => 'VA Forms Group B', 'hashV' => Digest::SHA256.file(@pdf_path).hexdigest, 'numberAttachments' => 0, 'docType' => FORM_ID, 'numberPages' => PDF::Reader.new(@pdf_path).pages.size } SimpleFormsApiSubmission::MetadataValidator.validate( , zip_code_is_us_based: country_is_us ).to_json end |
#generate_stamp_pdf ⇒ Pathname
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 “FDC Reviewed - Vets.gov Submission” at the top of each page
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/evss/disability_compensation_form/form4142_processor.rb', line 48 def generate_stamp_pdf pdf = PdfFill::Filler.fill_ancillary_form( form4142, @submission.submitted_claim_id, FORM_ID ) stamped_path = PDFUtilities::DatestampPdf.new(pdf).run(text: 'VA.gov', x: 5, y: 5, timestamp: submission_date) PDFUtilities::DatestampPdf.new(stamped_path).run( text: 'VA.gov Submission', x: 510, y: 775, text_only: true ) end |
#received_date ⇒ Object (private)
98 99 100 |
# File 'lib/evss/disability_compensation_form/form4142_processor.rb', line 98 def received_date submission_date.strftime('%Y-%m-%d %H:%M:%S') end |
#set_signature_date(incoming_data) ⇒ Object (private)
106 107 108 |
# File 'lib/evss/disability_compensation_form/form4142_processor.rb', line 106 def set_signature_date(incoming_data) incoming_data.merge({ 'signatureDate' => received_date }) end |
#submission_date ⇒ Object (private)
94 95 96 |
# File 'lib/evss/disability_compensation_form/form4142_processor.rb', line 94 def submission_date @submission.created_at.in_time_zone('Central Time (US & Canada)') end |
#to_faraday_upload ⇒ Object (private)
64 65 66 67 68 69 |
# File 'lib/evss/disability_compensation_form/form4142_processor.rb', line 64 def to_faraday_upload Faraday::UploadIO.new( @pdf_path, Mime[:pdf].to_s ) end |