diff --git a/app/models/saved_claim/burial.rb b/app/models/saved_claim/burial.rb index 465821ab084..d9412a62844 100644 --- a/app/models/saved_claim/burial.rb +++ b/app/models/saved_claim/burial.rb @@ -44,6 +44,22 @@ def form_matches_schema end end + def process_pdf(pdf_path, timestamp = nil, form_id = nil) + processed_pdf = CentralMail::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 + def business_line 'NCA' end diff --git a/app/sidekiq/central_mail/submit_saved_claim_job.rb b/app/sidekiq/central_mail/submit_saved_claim_job.rb index 60ce5ca6649..b4c688c4ffd 100644 --- a/app/sidekiq/central_mail/submit_saved_claim_job.rb +++ b/app/sidekiq/central_mail/submit_saved_claim_job.rb @@ -59,7 +59,11 @@ def perform(saved_claim_id) def send_claim_to_central_mail(saved_claim_id) @claim = SavedClaim.find(saved_claim_id) - @pdf_path = process_record(@claim) + @pdf_path = if @claim.form_id == '21P-530V2' + process_record(@claim, @claim.created_at, @claim.form_id) + else + process_record(@claim) + end @attachment_paths = @claim.persistent_attachments.map do |record| process_record(record) @@ -97,16 +101,33 @@ def to_faraday_upload(file_path) ) end - def process_record(record) + # rubocop:disable Metrics/MethodLength + def process_record(record, timestamp = nil, form_id = nil) pdf_path = record.to_pdf stamped_path1 = CentralMail::DatestampPdf.new(pdf_path).run(text: 'VA.GOV', x: 5, y: 5) - CentralMail::DatestampPdf.new(stamped_path1).run( + stamped_path2 = CentralMail::DatestampPdf.new(stamped_path1).run( text: 'FDC Reviewed - va.gov Submission', - x: 429, + x: 400, y: 770, text_only: true ) + if form_id.present? && ['21P-530V2'].include?(form_id) + CentralMail::DatestampPdf.new(stamped_path2).run( + text: 'Application Submitted on va.gov', + x: 425, + y: 675, + text_only: true, # passing as text only because we override how the date is stamped in this instance + timestamp:, + page_number: 5, + size: 9, + template: "lib/pdf_fill/forms/pdfs/#{form_id}.pdf", + multistamp: true + ) + else + stamped_path2 + end end + # rubocop:enable Metrics/MethodLength def get_hash_and_pages(file_path) { diff --git a/spec/sidekiq/central_mail/submit_saved_claim_job_spec.rb b/spec/sidekiq/central_mail/submit_saved_claim_job_spec.rb index 5372a2fc6b8..d265e05709d 100644 --- a/spec/sidekiq/central_mail/submit_saved_claim_job_spec.rb +++ b/spec/sidekiq/central_mail/submit_saved_claim_job_spec.rb @@ -68,6 +68,8 @@ end describe '#process_record' do + let(:path) { 'tmp/pdf_path' } + it 'processes a record and add stamps' do record = double datestamp_double1 = double @@ -79,7 +81,7 @@ expect(CentralMail::DatestampPdf).to receive(:new).with('path2').and_return(datestamp_double2) expect(datestamp_double2).to receive(:run).with( text: 'FDC Reviewed - va.gov Submission', - x: 429, + x: 400, y: 770, text_only: true ).and_return('path3') @@ -87,6 +89,40 @@ expect(described_class.new.process_record(record)).to eq('path3') end + it 'processes a 21P-530V2 record and add stamps' do + record = double + datestamp_double1 = double + datestamp_double2 = double + datestamp_double3 = double + timestamp = claim.created_at + form_id = '21P-530V2' + + expect(record).to receive(:to_pdf).and_return('path1') + expect(CentralMail::DatestampPdf).to receive(:new).with('path1').and_return(datestamp_double1) + expect(datestamp_double1).to receive(:run).with(text: 'VA.GOV', x: 5, y: 5).and_return('path2') + expect(CentralMail::DatestampPdf).to receive(:new).with('path2').and_return(datestamp_double2) + expect(datestamp_double2).to receive(:run).with( + text: 'FDC Reviewed - va.gov Submission', + x: 400, + y: 770, + text_only: true + ).and_return('path3') + expect(CentralMail::DatestampPdf).to receive(:new).with('path3').and_return(datestamp_double3) + expect(datestamp_double3).to receive(:run).with( + text: 'Application Submitted on va.gov', + x: 425, + y: 675, + text_only: true, + timestamp:, + page_number: 5, + size: 9, + template: 'lib/pdf_fill/forms/pdfs/21P-530V2.pdf', + multistamp: true + ).and_return(path) + + expect(described_class.new.process_record(record, timestamp, form_id)).to eq(path) + end + describe '#get_hash_and_pages' do it 'gets sha and number of pages' do expect(Digest::SHA256).to receive(:file).with('path').and_return(