Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ndbex 71275 pdf stamping #16088

Merged
merged 53 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
34ceed3
initial commit, add 530ez to repo
evansmith Feb 12, 2024
00e9f84
replace with new version
evansmith Feb 12, 2024
53e2b99
setup copies of 530 to prep for 530ez
evansmith Feb 12, 2024
3a6a3ff
setup tentative keys for veteran info
evansmith Feb 13, 2024
c6d5e06
wip: updated fields for pages 1 and 2
evansmith Feb 23, 2024
7fb9d85
small changes, swapped forms
evansmith Feb 26, 2024
c1ea933
slight changes
evansmith Feb 29, 2024
2c9fc9d
Merge branch 'master' into ndbex-70721-map-form-fields
evansmith Mar 1, 2024
13cc805
renaming
evansmith Mar 1, 2024
8f0cac5
prepare to toggle on form id
evansmith Mar 1, 2024
6159990
temporarily point at other branch
evansmith Mar 1, 2024
e30b7f7
version 2 toggle
evansmith Mar 1, 2024
612e938
change to formV2
evansmith Mar 1, 2024
ab882f3
update schema ref
evansmith Mar 1, 2024
5ec65e2
experiment to get formV2
evansmith Mar 1, 2024
0ba5de6
update api to receive 21p-530v2, maintain form_id throughout process …
evansmith Mar 6, 2024
8331d8a
updated hash for temp branch
evansmith Mar 6, 2024
093f727
temporary update to schema ref
evansmith Mar 8, 2024
ab223b0
mapped a new pdf, small field updates
evansmith Mar 11, 2024
dcf04c5
fix pdf telephone field. begin mapping values
evansmith Mar 12, 2024
c8e9862
relationship to veteran and final resting place
evansmith Mar 12, 2024
6ddee44
updates to pdf and methods filling in values
evansmith Mar 15, 2024
b655a50
update schema ref
evansmith Mar 15, 2024
29c175f
combine previous names and service
evansmith Mar 15, 2024
6ed7d07
more pdf fill work
evansmith Mar 19, 2024
c1e47c6
flipper for controller and model
evansmith Mar 20, 2024
69589cb
fix lettering
evansmith Mar 20, 2024
8ce8776
update schema ref
evansmith Mar 20, 2024
cbfa3de
small updates
evansmith Mar 20, 2024
a578906
fix merge conflict
evansmith Mar 20, 2024
b41300d
Merge branch 'master' into ndbex-70721-map-form-fields
tblackwe Mar 21, 2024
9cbbb94
fix overflow for both suffix fields and international phone number. a…
evansmith Mar 21, 2024
22e199c
Merge branch 'ndbex-70721-map-form-fields' of github.com:department-o…
evansmith Mar 21, 2024
e77bb14
unit tests
evansmith Mar 22, 2024
26062ab
process option
evansmith Mar 22, 2024
5b18f0c
update gemfile lock
evansmith Mar 22, 2024
8e548cc
merge conflict
evansmith Mar 22, 2024
f155507
initial pdf stamping ideas
evansmith Mar 25, 2024
7c3e45a
rubocop
evansmith Mar 25, 2024
7234283
remove flipper check that interferes with other claim types
evansmith Mar 25, 2024
377da6b
update with process option
evansmith Mar 25, 2024
f2a3a98
better error handling for parse
evansmith Mar 25, 2024
f9ec159
Merge branch 'master' into ndbex-70721-map-form-fields
evansmith Mar 25, 2024
c7b0e9e
Merge branch 'master' into ndbex-70721-map-form-fields
evansmith Mar 25, 2024
0e89d34
Merge branch 'master' into ndbex-70721-map-form-fields
evansmith Mar 25, 2024
382a56a
Merge branch 'ndbex-70721-map-form-fields' into ndbex-71275-pdf-stamping
evansmith Mar 26, 2024
1a9bbce
merge conflict
evansmith Mar 26, 2024
7dc0522
working version of datestamppdf with 530-v2
evansmith Mar 26, 2024
d111115
unit test for 530v2 pdf stamping
evansmith Mar 26, 2024
38afa50
rubocop
evansmith Mar 26, 2024
c9f35ef
fixes for rubocop
evansmith Mar 26, 2024
eb439d3
Merge branch 'master' into ndbex-71275-pdf-stamping
evansmith Mar 26, 2024
cc1e6b4
split up line into if/else
evansmith Mar 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions app/models/saved_claim/burial.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 21 additions & 4 deletions app/sidekiq/central_mail/submit_saved_claim_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ 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 = @claim.form_id == '21P-530V2' ? process_record(@claim, @claim.created_at, @claim.form_id) : process_record(@claim) # rubocop:disable Layout/LineLength
evansmith marked this conversation as resolved.
Show resolved Hide resolved

@attachment_paths = @claim.persistent_attachments.map do |record|
process_record(record)
Expand Down Expand Up @@ -97,16 +97,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)
{
Expand Down
38 changes: 37 additions & 1 deletion spec/sidekiq/central_mail/submit_saved_claim_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -79,14 +81,48 @@
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')

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(
Expand Down
Loading