-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathny213_att_pdf.rb
63 lines (55 loc) · 1.88 KB
/
ny213_att_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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
module PdfFiller
class Ny213AttPdf
include PdfHelper
attr_accessor :start_node
delegate :tax_year, to: :@submission
def source_pdf_name
"it213att-TY2023"
end
def nys_form_type
"239"
end
def barcode_overlay_rect
[[0, 26], 125, 29]
end
def initialize(submission, dependent_offset: nil)
@submission = submission
@intake = submission.data_source
builder = StateFile::StateInformationService.submission_builder_class(:ny)
if dependent_offset.nil?
dependent_offset = builder::DEPENDENT_OVERFLOW_THRESHOLD
end
@xml_document = builder.new(submission).document
@dependent_offset = dependent_offset
end
def hash_for_pdf
answers = {}
answers["Name Shown on Return"] = names_on_return
answers["Your SSN"] = @xml_document.at('EXT_TP_ID')&.text
answers.merge!(dependents_info)
answers
end
private
def names_on_return
primary_name = "#{@xml_document.at('tiPrime FIRST_NAME')&.text} #{@xml_document.at('tiPrime LAST_NAME')&.text}"
if @intake.filing_status_mfj?
spouse_name = "#{@xml_document.at('tiSpouse FIRST_NAME')&.text} #{@xml_document.at('tiSpouse LAST_NAME')&.text}"
"#{primary_name} and #{spouse_name}"
else
primary_name
end
end
def dependents_info
answers = {}
qualifying_dependents = @intake.dependents.select(&:eligible_for_child_tax_credit)[@dependent_offset..]
qualifying_dependents.each_with_index do |dependent, index|
answers["Last Name #{index + 1}"] = dependent.last_name
answers["MI #{index + 1}"] = dependent.middle_initial
answers["First Name #{index + 1}"] = dependent.first_name
answers["SSN #{index + 1}"] = dependent.ssn
answers["Year of Birth 1.#{index}"] = dependent.dob.strftime("%m%d%Y")
end
answers
end
end
end