Class: VBMS::SubmitDependentsPdfJob
- Inherits:
-
Object
- Object
- VBMS::SubmitDependentsPdfJob
- Includes:
- SentryLogging, Sidekiq::Job
- Defined in:
- app/sidekiq/vbms/submit_dependents_pdf_job.rb
Defined Under Namespace
Classes: Invalid686cClaim
Instance Attribute Summary collapse
-
#claim ⇒ Object
readonly
Returns the value of attribute claim.
Instance Method Summary collapse
- #check_doc_type(guid, parsed_form, dependent_type) ⇒ Object private
- #generate_pdf(submittable_686_form, submittable_674_form) ⇒ Object private
- #get_doc_type(guid, parsed_form) ⇒ Object private
-
#perform(saved_claim_id, encrypted_vet_info, submittable_686_form, submittable_674_form) ⇒ Object
Generates PDF for 686c form and uploads to VBMS.
- #upload_attachments ⇒ Object private
Methods included from SentryLogging
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger, #set_sentry_metadata
Instance Attribute Details
#claim ⇒ Object (readonly)
Returns the value of attribute claim.
12 13 14 |
# File 'app/sidekiq/vbms/submit_dependents_pdf_job.rb', line 12 def claim @claim end |
Instance Method Details
#check_doc_type(guid, parsed_form, dependent_type) ⇒ Object (private)
73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'app/sidekiq/vbms/submit_dependents_pdf_job.rb', line 73 def check_doc_type(guid, parsed_form, dependent_type) supporting_documents = parsed_form['dependents_application']['spouse_supporting_documents'] evidence_type = parsed_form['dependents_application']['spouse_evidence_document_type'] if dependent_type == 'child' supporting_documents = parsed_form['dependents_application']['child_supporting_documents'] evidence_type = parsed_form['dependents_application']['child_evidence_document_type'] end if supporting_documents.present? guid_matches = supporting_documents.any? { |doc| doc['confirmation_code'] == guid } evidence_type if guid_matches && evidence_type.present? end end |
#generate_pdf(submittable_686_form, submittable_674_form) ⇒ Object (private)
58 59 60 61 |
# File 'app/sidekiq/vbms/submit_dependents_pdf_job.rb', line 58 def generate_pdf(submittable_686_form, submittable_674_form) claim.upload_pdf('686C-674') if submittable_686_form claim.upload_pdf('21-674', doc_type: '142') if submittable_674_form end |
#get_doc_type(guid, parsed_form) ⇒ Object (private)
63 64 65 66 67 68 69 70 71 |
# File 'app/sidekiq/vbms/submit_dependents_pdf_job.rb', line 63 def get_doc_type(guid, parsed_form) doc_type = check_doc_type(guid, parsed_form, 'spouse') return doc_type if doc_type.present? doc_type = check_doc_type(guid, parsed_form, 'child') return doc_type if doc_type.present? '10' # return '10' which is doc type 'UNKNOWN' end |
#perform(saved_claim_id, encrypted_vet_info, submittable_686_form, submittable_674_form) ⇒ Object
Generates PDF for 686c form and uploads to VBMS
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/sidekiq/vbms/submit_dependents_pdf_job.rb', line 20 def perform(saved_claim_id, encrypted_vet_info, submittable_686_form, submittable_674_form) va_file_number_with_payload = JSON.parse(KmsEncrypted::Box.new.decrypt(encrypted_vet_info)) Rails.logger.info('VBMS::SubmitDependentsPdfJob running!', { saved_claim_id: }) @claim = SavedClaim::DependencyClaim.find(saved_claim_id) claim.add_veteran_info(va_file_number_with_payload) raise Invalid686cClaim unless claim.valid?(:run_686_form_jobs) generate_pdf(submittable_686_form, submittable_674_form) Rails.logger.info('VBMS::SubmitDependentsPdfJob succeeded!', { saved_claim_id: }) rescue => e Rails.logger.warn('VBMS::SubmitDependentsPdfJob failed, retrying...', { saved_claim_id:, error: e. }) @saved_claim_id = saved_claim_id raise end |
#upload_attachments ⇒ Object (private)
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/sidekiq/vbms/submit_dependents_pdf_job.rb', line 40 def claim..each do || next if .completed_at.present? file_extension = File.extname(URI.parse(.file.url).path) if %w[.jpg .jpeg .png .pdf].include? file_extension.downcase file_path = Common::FileHelpers.generate_clamav_temp_file(.file.read) File.rename(file_path, "#{file_path}#{file_extension}") file_path = "#{file_path}#{file_extension}" claim.upload_to_vbms(path: file_path, doc_type: get_doc_type(.guid, claim.parsed_form)) Common::FileHelpers.delete_file_if_exists(file_path) end .update(completed_at: Time.zone.now) end end |