-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathid39r_pdf.rb
48 lines (43 loc) · 1.79 KB
/
id39r_pdf.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
module PdfFiller
class Id39rPdf
include PdfHelper
def source_pdf_name
"idform39r-TY2024"
end
def initialize(submission)
@submission = submission
# Most PDF fields are grabbed right off the XML
builder = StateFile::StateInformationService.submission_builder_class(:id)
@xml_document = builder.new(submission).document
end
def hash_for_pdf
answers = {
"AL7" => @xml_document.at('Form39R TotalAdditions')&.text,
"BL3" => @xml_document.at('Form39R IncomeUSObligations')&.text,
"BL6" => @xml_document.at('Form39R ChildCareCreditAmt')&.text,
"BL7" => @xml_document.at('Form39R TxblSSAndRRBenefits')&.text,
"BL8a" => @xml_document.at('Form39R PensionFilingStatusAmount')&.text,
"BL8c" => @xml_document.at('Form39R SocialSecurityBenefits')&.text,
"BL8d" => calculated_fields.fetch(:ID39R_B_LINE_8d),
"BL8e" => @xml_document.at('Form39R PensionExclusions')&.text,
"BL8f" => @xml_document.at('Form39R RetirementBenefitsDeduction')&.text,
"BL18" => @xml_document.at('Form39R HealthInsurancePaid')&.text,
"BL24" => @xml_document.at('Form39R TotalSubtractions')&.text,
"DL4" => @xml_document.at('Form39R TotalSupplementalCredits')&.text,
}
@submission.data_source.dependents.drop(4).first(3).each_with_index do |dependent, index|
answers.merge!(
"FR#{index + 1}FirstName" => dependent.first_name,
"FR#{index + 1}LastName" => dependent.last_name,
"FR#{index + 1}SSN" => dependent.ssn,
"FR#{index + 1}Birthdate" => dependent.dob.strftime('%m/%d/%Y'),
)
end
answers
end
private
def calculated_fields
@calculated_fields ||= @submission.data_source.tax_calculator.calculate
end
end
end