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

Add in lines 15 and 16 to MD Form 502 #4980

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
14 changes: 10 additions & 4 deletions app/lib/efile/line_data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,6 @@ MD502_LINE_6:
label: '6 Total additions: add lines 2 - 5 (line 2, 4, 5 out of scope)'
MD502_LINE_7:
label: '7 Total federal adjusted gross income and Maryland additions: add line 1 and line 6'
MD502_LINE_15:
label: 'TBD'
MD502_LINE_A_PRIMARY:
label: 'A Primary exemption'
MD502_LINE_A_SPOUSE:
Expand Down Expand Up @@ -586,10 +584,18 @@ MD502_LINE_D_COUNT_TOTAL:
label: 'D Total Exemption Count: add lines A, B and C counts'
MD502_LINE_D_AMOUNT_TOTAL:
label: 'D Total Exemption Dollar Amount: add lines A, B and C amounts'
MD502_LINE_9:
label: 'TBD'
MD502_LINE_10A:
label: 'TBD'
MD502_LINE_11:
label: 'TBD'
MD502_LINE_13:
label: Subtractions from attached form 502SU
label: 'Subtractions from attached form 502SU'
MD502_LINE_15:
label: 'Total subtractions (Add lines 8 through 14. See instructions.)'
MD502_LINE_16:
label: '16 TBD'
label: 'Maryland adjusted gross income (Subtract line 15 from line 7.)'
MD502_DEDUCTION_METHOD:
label: 'Itemized, standard or non-taxable deduction method'
MD502_LINE_17:
Expand Down
31 changes: 23 additions & 8 deletions app/lib/efile/md/md502_calculator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,18 @@ def calculate
set_line(:MD502_LINE_6, :calculate_line_6)
set_line(:MD502_LINE_7, :calculate_line_7)

# Subtractions
set_line(:MD502_LINE_15, :calculate_line_15) # STUBBED: PLEASE REPLACE, don't forget line_data.yml
set_line(:MD502_LINE_16, :calculate_line_16) # STUBBED: PLEASE REPLACE, don't forget line_data.yml

# MD502SU Subtractions
@md502_su.calculate
set_line(:MD502_LINE_13, :calculate_line_13)

# Subtractions
set_line(:MD502_LINE_9, :calculate_line_9) # STUBBED: PLEASE REPLACE, don't forget line_data.yml
set_line(:MD502_LINE_10A, :calculate_line_10a) # STUBBED: PLEASE REPLACE, don't forget line_data.yml
set_line(:MD502_LINE_11, :calculate_line_11) # STUBBED: PLEASE REPLACE, don't forget line_data.yml
# lines 15 and 16 depend on lines 8-14
set_line(:MD502_LINE_15, :calculate_line_15)
set_line(:MD502_LINE_16, :calculate_line_16)

# Deductions
set_line(:MD502_DEDUCTION_METHOD, :calculate_deduction_method)
set_line(:MD502_LINE_17, :calculate_line_17)
Expand Down Expand Up @@ -319,9 +323,20 @@ def calculate_line_7
line_or_zero(:MD502_LINE_1) + line_or_zero(:MD502_LINE_6)
end

def calculate_line_15; end
def calculate_line_9; end
def calculate_line_10a; end
def calculate_line_11; end

def calculate_line_16; end
def calculate_line_15
subtraction_lines = [9, "10A", 11, 13]
subtraction_lines.sum do |line_num|
line_or_zero("MD502_LINE_#{line_num}")
end
end

def calculate_line_16
line_or_zero(:MD502_LINE_7) - line_or_zero(:MD502_LINE_15)
end

FILING_MINIMUMS_NON_SENIOR = {
single: 14_600,
Expand Down Expand Up @@ -361,12 +376,12 @@ def calculate_deduction_method
s_mfs_d: {
12000 => 1_800,
17999 => ->(x) { x * 0.15 },
18000 => 2_700,
Float::INFINITY => 2_700,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jenny-heath helped sort out there was a bug here where its supposed to be "$18,000 or over" and so the band is changed in this line. Here is the original ticket for reference.

},
mfj_hoh_qss: {
24333 => 3_650,
36332 => ->(x) { x * 0.15 },
36333 => 5_450,
Float::INFINITY => 5_450,
}
}.freeze
FILING_STATUS_GROUPS = {
Expand Down
2 changes: 2 additions & 0 deletions app/lib/pdf_filler/md502_pdf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ def hash_for_pdf
'Enter 3': @xml_document.at('Form502 Additions StateRetirementPickup')&.text,
'Enter 6': @xml_document.at('Form502 Additions Total')&.text,
'Enter 7': @xml_document.at('Form502 Additions FedAGIAndStateAdditions')&.text,
"Enter 15": @xml_document.at('Form502 Subtractions Total')&.text,
"Enter 16": @xml_document.at('Form502 Subtractions StateAdjustedGrossIncome')&.text,
'Text Box 30': @xml_document.at('Form502 StateTaxComputation StateIncomeTax')&.text,
'Text Box 36': @xml_document.at('Form502 StateTaxComputation PovertyLevelCredit')&.text,
'Text Box 40': @xml_document.at('Form502 StateTaxComputation TotalCredits')&.text,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ def document
xml.ChildAndDependentCareExpenses @direct_file_data.total_qualifying_dependent_care_expenses
xml.SocialSecurityRailRoadBenefits @direct_file_data.fed_taxable_ssb
xml.Other calculated_fields.fetch(:MD502_LINE_13)
add_element_if_present(xml, "Total", :MD502_LINE_15)
add_element_if_present(xml, "StateAdjustedGrossIncome", :MD502_LINE_16)
end
xml.Deduction do
xml.Method calculated_fields.fetch(:MD502_DEDUCTION_METHOD)
Expand Down
28 changes: 26 additions & 2 deletions spec/lib/efile/md/md502_calculator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -818,18 +818,42 @@
end
end

describe "#calculate_line_15" do
before do
allow_any_instance_of(Efile::Md::Md502Calculator).to receive(:calculate_line_9).and_return 2
allow_any_instance_of(Efile::Md::Md502Calculator).to receive(:calculate_line_10a).and_return 4
allow_any_instance_of(Efile::Md::Md502Calculator).to receive(:calculate_line_11).and_return 6
allow_any_instance_of(Efile::Md::Md502Calculator).to receive(:calculate_line_13).and_return 8
end
it "sums lines 8 - 14" do
instance.calculate
expect(instance.lines[:MD502_LINE_15].value).to eq 20
end
end

describe "#calculate_line_16" do
before do
allow_any_instance_of(Efile::Md::Md502Calculator).to receive(:calculate_line_7).and_return 150
allow_any_instance_of(Efile::Md::Md502Calculator).to receive(:calculate_line_15).and_return 50
end
it "subtracts line 15 from line 7" do
instance.calculate
expect(instance.lines[:MD502_LINE_16].value).to eq 100
end
end

describe "#calculate_line_17" do
context "when method is standard" do
[
[["single", "married_filing_separately", "dependent"], [
[12_000, 1_800],
[17_999, 17_999 * 0.15],
[18_000, 2_700],
[18_001, 2_700],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed the tests to expose the above mentioned bug.

]],
[["married_filing_jointly", "head_of_household", "qualifying_widow"], [
[24_333, 3_650],
[36_332, 36_332 * 0.15],
[36_333, 5_450],
[36_334, 5_450],
]]
].each do |filing_statuses, agis_to_deductions|
filing_statuses.each do |filing_status|
Expand Down
17 changes: 16 additions & 1 deletion spec/lib/pdf_filler/md502_pdf_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,6 @@
end

it 'outputs the total state and local tax withheld' do
puts pdf_fields
expect(pdf_fields["Text Box 68"]).to eq "500"
end
end
Expand Down Expand Up @@ -440,5 +439,21 @@
expect(pdf_fields["Enter 13"].to_i).to eq 0
end
end

describe "Line 15" do
Copy link
Contributor

Choose a reason for hiding this comment

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

minor thing but there's a section above context "subtractions" do that you could move these blocks into

let(:total_subtractions) { 100 }
it "outputs the total subtractions" do
allow_any_instance_of(Efile::Md::Md502Calculator).to receive(:calculate_line_15).and_return total_subtractions
expect(pdf_fields["Enter 15"].to_i).to eq total_subtractions
end
end

describe "Line 16" do
let(:state_adjusted_gross_income) { 150 }
it "outputs the total subtractions" do
allow_any_instance_of(Efile::Md::Md502Calculator).to receive(:calculate_line_16).and_return state_adjusted_gross_income
expect(pdf_fields["Enter 16"].to_i).to eq state_adjusted_gross_income
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,14 @@
end

context "subtractions section" do
let(:other_subtractions) { 100 }
let(:total_subtractions) { 150 }
let(:state_adjusted_income) { 300 }
context "when all relevant values are present in the DF XML" do
before do
allow_any_instance_of(Efile::Md::Md502SuCalculator).to receive(:calculate_line_1).and_return 100
allow_any_instance_of(Efile::Md::Md502Calculator).to receive(:calculate_line_13).and_return other_subtractions
allow_any_instance_of(Efile::Md::Md502Calculator).to receive(:calculate_line_15).and_return total_subtractions
allow_any_instance_of(Efile::Md::Md502Calculator).to receive(:calculate_line_16).and_return state_adjusted_income
intake.direct_file_data.total_qualifying_dependent_care_expenses = 1200
intake.direct_file_data.fed_taxable_ssb = 240
end
Expand All @@ -304,7 +309,15 @@
end

it "outputs the Subtractions from Form 502SU" do
expect(xml.at("Form502 Subtractions Other").text.to_i).to eq(100)
expect(xml.at("Form502 Subtractions Other").text.to_i).to eq(other_subtractions)
end

it "outputs the sum of the Subtractions" do
expect(xml.at("Form502 Subtractions Total").text.to_i).to eq(total_subtractions)
end

it 'outputs the state adjusted income' do
expect(xml.at("Form502 Subtractions StateAdjustedGrossIncome").text.to_i).to eq(state_adjusted_income)
end
end
end
Expand Down
Loading