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

Dex 91068 multi 674 pdfs #21151

Draft
wants to merge 62 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
6b8f252
initial v2 work
evansmith Nov 21, 2024
00602fc
Merge branch 'master' into dex-81929-support-v2-updated
evansmith Nov 26, 2024
a7292d3
rescue
evansmith Nov 26, 2024
b5e5271
Merge branch 'master' into dex-81929-support-v2-updated
evansmith Dec 2, 2024
c626eb8
Merge branch 'master' into dex-81929-support-v2-updated
evansmith Dec 6, 2024
56cc4ea
anticipated filler test change
evansmith Dec 6, 2024
a65133d
wip: assign form v2 to form_id
evansmith Dec 9, 2024
3d0e775
Merge branch 'master' into dex-81929-support-v2-updated
evansmith Dec 9, 2024
7d4b32a
Merge branch 'master' into dex-81929-support-v2-updated
evansmith Dec 12, 2024
fe2e08f
merge conflicts
evansmith Dec 20, 2024
557b4ee
Merge branch 'master' into dex-81929-support-v2-updated
evansmith Dec 23, 2024
9c24ea6
Merge branch 'master' into dex-81929-support-v2-updated
evansmith Dec 27, 2024
278c6d0
Merge branch 'master' into dex-81929-support-v2-updated
evansmith Dec 28, 2024
7886595
resolve merge conflict from master
evansmith Jan 6, 2025
8e6c796
student information scaffold
mreed101 Jan 8, 2025
e903e38
all student information added
mreed101 Jan 8, 2025
fd3c7f3
mapped student information to new fields
mreed101 Jan 8, 2025
c7f3231
update dates
evansmith Jan 13, 2025
985c6e4
all questions accounted for
mreed101 Jan 15, 2025
3c66fc2
Merge branch 'vabc/jr/686-arrays-to-pdef/91068' of https://github.com…
mreed101 Jan 15, 2025
dd08655
full fields
mreed101 Jan 21, 2025
5f74b16
helper updates
mreed101 Jan 22, 2025
4b7b510
all updated helpers
mreed101 Jan 22, 2025
44352e5
new helpers for student income
mreed101 Jan 22, 2025
20d1e32
unit test files for 686V2
mreed101 Jan 30, 2025
95d1df8
removed comments
mreed101 Feb 3, 2025
7f64be3
kitchen sink mapping test
mreed101 Feb 6, 2025
8a64450
added logging to detect errors
mreed101 Feb 6, 2025
9b0a4fe
pdftk save issue
mreed101 Feb 7, 2025
740727b
iterator for arrays
mreed101 Feb 10, 2025
c161cdf
finalized pdf test
mreed101 Feb 10, 2025
fc79204
updated pdf dates
mreed101 Feb 11, 2025
fb06cf0
Update pdf dates
mreed101 Feb 11, 2025
39f4ba5
removed unused code
mreed101 Feb 11, 2025
59072cb
merged master, resolved conflicts
mreed101 Feb 11, 2025
62d090d
Merge branch 'master' into vabc/jr/686-array-mapping/91068
mreed101 Feb 16, 2025
282a3b5
merged master, removed 686 from prefill_enabled_forms
mreed101 Feb 16, 2025
c3fc8d8
adds type of benefit logic
mreed101 Feb 17, 2025
6244fb4
lint fix
mreed101 Feb 17, 2025
f350965
resolved conflict with filler_spec
mreed101 Feb 20, 2025
b4832d5
Merge branch 'master' into dex-91068-multi-674-pdfs
evansmith Feb 24, 2025
840a89a
in progress: proof of concept for multi 674 pdf
evansmith Feb 27, 2025
33340a4
adds flipper logic for generate pdf
mreed101 Feb 28, 2025
23ab4c1
work in progress: fixes for pdf testing issue. point to v2 dependency…
evansmith Feb 28, 2025
d283bf6
remove puts
evansmith Feb 28, 2025
fe8944e
add 686c v2 into saved claim check
evansmith Feb 28, 2025
5167dd1
686 initial mapping fix
mreed101 Mar 2, 2025
d877d39
kitched sink mapping complete
mreed101 Mar 2, 2025
279e06a
finished 686 mapping
mreed101 Mar 3, 2025
ffc4ce3
updates test for 686v2
mreed101 Mar 3, 2025
38da96b
Merge branch 'master' into vabc/jr/686-array-mapping/91068
mreed101 Mar 3, 2025
f5e98c7
update spec files for simple and overflow, fix parsed_form testing issue
evansmith Mar 3, 2025
ddc4c3b
Merge branch 'master' into vabc/jr/686-array-mapping/91068
evansmith Mar 3, 2025
afbc84b
rubocop fix
evansmith Mar 3, 2025
adfa1d2
Merge branch 'vabc/jr/686-array-mapping/91068' into dex-91068-multi-6…
evansmith Mar 3, 2025
7cb25d4
merge conflict
evansmith Mar 5, 2025
a3e0780
wire up multi 674 pdfs in normal flow and backup flow
evansmith Mar 7, 2025
a7345b6
put bgs person and file number back
evansmith Mar 7, 2025
990bd29
quick cleanup
evansmith Mar 7, 2025
053e2b4
some unit tests
evansmith Mar 7, 2025
1a77ca5
rubocop
evansmith Mar 7, 2025
24bbc7b
Merge branch 'master' into dex-91068-multi-674-pdfs
evansmith Mar 7, 2025
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
26 changes: 18 additions & 8 deletions app/models/saved_claim/dependency_claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
class SavedClaim::DependencyClaim < CentralMailClaim
FORM = '686C-674'
STUDENT_ATTENDING_COLLEGE_KEYS = %w[
student_information
student_name_and_ssn
student_address_marriage_tuition
last_term_school_information
Expand Down Expand Up @@ -49,16 +50,26 @@ def upload_pdf(form_id, doc_type: '148')
uploaded_forms ||= []
return if uploaded_forms.include? form_id

upload_to_vbms(path: process_pdf(to_pdf(form_id:), created_at, form_id), doc_type:)
uploaded_forms << form_id
save
processed_pdfs = []
if form_id == '21-674-V2'
parsed_form['dependents_application']['student_information'].each_with_index do |student, index|
processed_pdfs << process_pdf(to_pdf(form_id:, student:), created_at, form_id, index)
end
else
processed_pdfs << process_pdf(to_pdf(form_id:), created_at, form_id)
end
processed_pdfs.each do |processed_pdf|
upload_to_vbms(path: processed_pdf, doc_type:)
uploaded_forms << form_id
save
end
rescue => e
Rails.logger.debug('DependencyClaim: Issue Uploading to VBMS in upload_pdf method',
{ saved_claim_id: id, form_id:, error: e })
raise e
end

def process_pdf(pdf_path, timestamp = nil, form_id = nil)
def process_pdf(pdf_path, timestamp = nil, form_id = nil, iterator = nil)
processed_pdf = PDFUtilities::DatestampPdf.new(pdf_path).run(
text: 'Application Submitted on site',
x: form_id == '686C-674' ? 400 : 300,
Expand All @@ -69,7 +80,7 @@ def process_pdf(pdf_path, timestamp = nil, form_id = nil)
template: "lib/pdf_fill/forms/pdfs/#{form_id}.pdf",
multistamp: true
)
renamed_path = "tmp/pdfs/#{form_id}_#{id}_final.pdf"
renamed_path = iterator.present? ? "tmp/pdfs/#{form_id}_#{id}_#{iterator}_final.pdf" : "tmp/pdfs/#{form_id}_#{id}_final.pdf" # rubocop:disable Layout/LineLength
File.rename(processed_pdf, renamed_path) # rename for vbms upload
renamed_path # return the renamed path
end
Expand Down Expand Up @@ -147,10 +158,9 @@ def upload_to_vbms(path:, doc_type: '148')
# end
# end

def to_pdf(form_id: FORM)
def to_pdf(form_id: FORM, student: nil)
self.form_id = form_id

PdfFill::Filler.fill_form(self, nil, { created_at: })
PdfFill::Filler.fill_form(self, nil, { created_at:, student: })
end

# this failure email is not the ideal way to handle the Notification Emails as
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete this comment of the failure email for me please

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ class SubmitCentralForm686cJob

FOREIGN_POSTALCODE = '00000'
FORM_ID = '686C-674'
FORM_ID_V2 = '686C-674-V2'
FORM_ID_674 = '21-674'
FORM_ID_674_V2 = '21-674-V2'
STATSD_KEY_PREFIX = 'worker.submit_686c_674_backup_submission'
ZSF_DD_TAG_FUNCTION = 'submit_686c_674_backup_submission'
# retry for 2d 1h 47m 12s
Expand Down Expand Up @@ -93,12 +95,28 @@ def create_form_submission_attempt(intake_uuid)

def get_files_from_claim
# process the main pdf record and the attachments as we would for a vbms submission
form_674_path = process_pdf(claim.to_pdf(form_id: FORM_ID_674), claim.created_at, FORM_ID_674) if claim.submittable_674? # rubocop:disable Layout/LineLength
form_686c_path = process_pdf(claim.to_pdf(form_id: FORM_ID), claim.created_at, FORM_ID) if claim.submittable_686? # rubocop:disable Layout/LineLength
@form_path = form_686c_path || form_674_path
v2 = Flipper.enabled?(:va_dependents_v2)
if claim.submittable_674?
form_674_paths = []
if v2
claim.parsed_form['dependents_application']['student_information'].each do |student|
form_674_paths << process_pdf(claim.to_pdf(form_id: FORM_ID_674_V2, student:), claim.created_at, FORM_ID_674_V2) # rubocop:disable Layout/LineLength
end
else
form_674_paths << process_pdf(claim.to_pdf(form_id: FORM_ID_674), claim.created_at, FORM_ID_674)
end
end
form_686c_path = process_pdf(claim.to_pdf(form_id: v2 ? FORM_ID_V2 : FORM_ID), claim.created_at, FORM_ID) if claim.submittable_686? # rubocop:disable Layout/LineLength
# set main form_path to be first 674 in array if needed
@form_path = form_686c_path || form_674_paths.first

@attachment_paths = claim.persistent_attachments.map { |pa| process_pdf(pa.to_pdf, claim.created_at) }
# Treat 674 as first attachment
attachment_paths.insert(0, form_674_path) if form_686c_path.present? && form_674_path.present?
if form_686c_path.present? && form_674_paths.present?
attachment_paths.unshift(*form_674_paths)
elsif form_674_paths.present? && form_674_paths.size > 1
attachment_paths.unshift(*form_674_paths.drop(1))
end
end

def cleanup_file_paths
Expand Down
2 changes: 2 additions & 0 deletions lib/pdf_fill/forms/va21674v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,8 @@ class Va21674v2 < FormBase

def merge_fields(options = {})
created_at = options[:created_at] if options[:created_at].present?
student = options[:student]
@form_data['dependents_application']['student_information'] = [student]
expand_signature(@form_data['veteran_information']['full_name'], created_at&.to_date || Time.zone.today)
@form_data['signature_date'] = split_date(@form_data['signatureDate'])
veteran_contact_information = @form_data['dependents_application']['veteran_contact_information']
Expand Down
52 changes: 41 additions & 11 deletions spec/models/saved_claim/dependency_claim_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@
RSpec.describe SavedClaim::DependencyClaim do
subject { create(:dependency_claim) }

let(:subject_v2) { create(:dependency_claim_v2) }

let(:all_flows_payload) { build(:form_686c_674_kitchen_sink) }
let(:all_flows_payload_v2) { build(:form686c_674_v2) }
let(:adopted_child) { build(:adopted_child_lives_with_veteran) }
let(:adopted_child_v2) { build(:adopted_child_lives_with_veteran_v2) }
let(:form_674_only) { build(:form_674_only) }
let(:form_674_only_v2) { build(:form_674_only_v2) }
let(:doc_type) { '148' }
let(:va_file_number) { subject.parsed_form['veteran_information']['va_file_number'] }
let(:va_file_number_v2) { subject_v2.parsed_form['veteran_information']['va_file_number'] }
let(:va_file_number_with_payload) do
{
'veteran_information' => {
Expand All @@ -22,8 +28,21 @@
}
}
end
let(:va_file_number_with_payload_v2) do
{
'veteran_information' => {
'birth_date' => '1809-02-12',
'full_name' => {
'first' => 'WESLEY', 'last' => 'FORD', 'middle' => nil
},
'ssn' => va_file_number_v2,
'va_file_number' => va_file_number_v2
}
}
end

let(:file_path) { "tmp/pdfs/686C-674_#{subject.id}_final.pdf" }
let(:file_path_v2) { "tmp/pdfs/686C-674-V2_#{subject_v2.id}_final.pdf" }

describe '#upload_pdf' do
context 'when :va_dependents_v2 is disabled' do
Expand All @@ -39,7 +58,6 @@
doc_type:
).and_return(uploader)
expect(uploader).to receive(:upload!)

subject.upload_pdf('686C-674')
end
end
Expand All @@ -52,13 +70,25 @@
it 'when :va_dependents_v2 is enabled' do
uploader = double(ClaimsApi::VBMSUploader)
expect(ClaimsApi::VBMSUploader).to receive(:new).with(
filepath: file_path,
file_number: va_file_number,
filepath: file_path_v2,
file_number: va_file_number_v2,
doc_type:
).and_return(uploader)
expect(uploader).to receive(:upload!)

subject.upload_pdf('686C-674')
subject_v2.upload_pdf('686C-674-V2')
end

it 'when :va_dependents_v2 is enabled upload 674' do
uploader = double(ClaimsApi::VBMSUploader)
expect(ClaimsApi::VBMSUploader).to receive(:new).with(
filepath: "tmp/pdfs/21-674-V2_#{subject_v2.id}_0_final.pdf",
file_number: va_file_number_v2,
doc_type:
).and_return(uploader)
expect(uploader).to receive(:upload!)

subject_v2.upload_pdf('21-674-V2')
end
end
end
Expand Down Expand Up @@ -100,24 +130,24 @@
end

context 'va_dependents_v2 is enabled' do
subject { described_class.new(form: all_flows_payload.to_json) }
subject { described_class.new(form: all_flows_payload_v2.to_json) }

before do
allow(Flipper).to receive(:enabled?).with(:va_dependents_v2).and_return(true)
end

describe '#formatted_686_data' do
it 'returns all data for 686 submissions' do
formatted_data = subject.formatted_686_data(va_file_number_with_payload)
formatted_data = subject.formatted_686_data(va_file_number_with_payload_v2)
expect(formatted_data).to include(:veteran_information)
end
end

describe '#formatted_674_data' do
it 'returns all data for 674 submissions' do
formatted_data = subject.formatted_674_data(va_file_number_with_payload)
formatted_data = subject.formatted_674_data(va_file_number_with_payload_v2)
expect(formatted_data).to include(:dependents_application)
expect(formatted_data[:dependents_application]).to include(:student_name_and_ssn)
expect(formatted_data[:dependents_application]).to include(:student_information)
end
end

Expand Down Expand Up @@ -151,7 +181,7 @@
end

context 'va_dependents_v2 is enabled' do
subject { described_class.new(form: form_674_only.to_json) }
subject { described_class.new(form: form_674_only_v2.to_json) }

before do
allow(Flipper).to receive(:enabled?).with(:va_dependents_v2).and_return(true)
Expand Down Expand Up @@ -187,7 +217,7 @@
end

context 'va_dependents_v2 is enabled' do
subject { described_class.new(form: adopted_child.to_json) }
subject { described_class.new(form: adopted_child_v2.to_json) }

before do
allow(Flipper).to receive(:enabled?).with(:va_dependents_v2).and_return(true)
Expand All @@ -208,7 +238,7 @@
end

context 'v2 form' do
subject { described_class.new(form: all_flows_payload.to_json, use_v2: true) }
subject { described_class.new(form: all_flows_payload_v2.to_json, use_v2: true) }

before do
allow(Flipper).to receive(:enabled?).with(:va_dependents_v2).and_return(true)
Expand Down
Loading
Loading