Skip to content

Commit 48ae764

Browse files
committed
Add El101 pdf lines
1 parent c7880b8 commit 48ae764

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

app/lib/pdf_filler/md_el101_pdf.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,19 @@ def hash_for_pdf
3333
'ERO firm name 2': @submission.data_source.spouse_esigned_yes? ? 'FileYourStateTaxes' : "",
3434
'Primary Signature Pin': @xml_document.at('Primary TaxpayerPIN')&.text,
3535
'Spouse Esigned': checkbox_value(@submission.data_source.spouse_esigned_yes?),
36-
'Secondary Signature Pin': @xml_document.at('Secondary TaxpayerPIN')&.text
36+
'Secondary Signature Pin': @xml_document.at('Secondary TaxpayerPIN')&.text,
37+
'2 Amount of overpayment to be refunded to you 2': calculated_fields.fetch(:MD502_LINE_48),
38+
'3': calculated_fields.fetch(:MD502_LINE_50),
3739
}
3840
end
3941

4042
def checkbox_value(condition)
4143
condition ? 'On' : 'Off'
4244
end
45+
46+
def calculated_fields
47+
@calculated_fields ||= @submission.data_source.tax_calculator.calculate
48+
end
4349
end
4450
end
4551

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
require "rails_helper"
2+
3+
RSpec.describe PdfFiller::MdEl101Pdf do
4+
include PdfSpecHelper
5+
6+
let(:intake) { create(:state_file_md_intake) }
7+
let(:submission) { create :efile_submission, tax_return: nil, data_source: intake }
8+
let(:pdf) { described_class.new(submission) }
9+
10+
describe "#hash_for_pdf" do
11+
let(:file_path) { described_class.new(submission).output_file.path }
12+
let(:pdf_fields) { filled_in_values(file_path) }
13+
let(:intake) { create(:state_file_md_intake) }
14+
15+
it 'uses field names that exist in the pdf' do
16+
missing_fields = pdf.hash_for_pdf.keys.map { |k| k.to_s.gsub("'", "'").to_s } - pdf_fields.keys
17+
expect(missing_fields).to eq([])
18+
end
19+
20+
context "when taxes are owed" do
21+
before do
22+
allow_any_instance_of(Efile::Md::Md502Calculator).to receive(:calculate_line_45).and_return 100
23+
end
24+
25+
it 'outputs the amount owed' do
26+
expect(pdf_fields["3"]).to eq "100"
27+
end
28+
end
29+
30+
context "when there is a refund" do
31+
before do
32+
allow_any_instance_of(Efile::Md::Md502Calculator).to receive(:calculate_line_46).and_return 300
33+
end
34+
35+
it 'outputs the amount to be refunded' do
36+
expect(pdf_fields["2 Amount of overpayment to be refunded to you 2"]).to eq "300"
37+
end
38+
end
39+
end
40+
end
41+
42+

0 commit comments

Comments
 (0)