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

Fyst 462 implement some form d-400 ctc lines for both pdf and xml #4784

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
17 changes: 17 additions & 0 deletions app/lib/efile/nc/d400_calculator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class D400Calculator < ::Efile::TaxCalculator
attr_reader :lines

def calculate
set_line(:NCD400_LINE_10B, :calculate_line_10b)
set_line(:NCD400_LINE_20A, :calculate_line_20a)
set_line(:NCD400_LINE_20B, :calculate_line_20b)
set_line(:NCD400_LINE_23, :calculate_line_23)
Expand All @@ -16,6 +17,22 @@ def refund_or_owed_amount

private

def calculate_line_10b
income_ranges = if filing_status_single? || filing_status_mfs?
[0..20_000, 20_001..30_000, 30_001..40_000, 40_001..50_000, 50_001..60_000, 60_001..70_000, 70_001..Float::INFINITY]
elsif filing_status_hoh?
[0..30_000, 30_001..45_000, 45_001..60_000, 60_001..75_000, 75_001..90_000, 90_001..105_000, 105_001..Float::INFINITY]
elsif filing_status_mfj? || filing_status_qw?
[0..40_000, 40_001..60_000, 60_001..80_000, 80_001..100_000, 100_001..120_000, 120_001..140_000, 140_001..Float::INFINITY]
end
income_range_index = income_ranges.find_index { |range| range.include?(@direct_file_data.fed_agi) }

deduction_amounts = [3000, 2500, 2000, 1500, 1000, 500, 0]
amount_per_child = deduction_amounts[income_range_index]

amount_per_child * @direct_file_data.qualifying_children_under_age_ssn_count.to_i
end

def calculate_line_20a
@direct_file_data.w2s.reduce(0) do |sum, w2|
if w2.EmployeeSSN == @direct_file_data.primary_ssn
Expand Down
3 changes: 2 additions & 1 deletion app/lib/pdf_filler/nc_d400_pdf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ def hash_for_pdf
y_d400wf_li20b_pg2_good: @xml_document.at('IncTaxWithSpouse')&.text,
y_d400wf_li23_pg2_good: @xml_document.at('NCTaxPaid')&.text,
y_d400wf_li25_pg2_good: @xml_document.at('RemainingPayment')&.text,
y_d400wf_li10a_good: @xml_document.at('NumChildrenAllowed')&.text
y_d400wf_li10a_good: @xml_document.at('NumChildrenAllowed')&.text,
y_d400wf_li10b_good: @xml_document.at('ChildDeduction')&.text
}
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def document
xml.FAGIPlusAdditions @submission.data_source.direct_file_data.fed_agi
# line 9 DeductionsFromFAGI is blank
xml.NumChildrenAllowed @submission.data_source.direct_file_data.qualifying_children_under_age_ssn_count
xml.ChildDeduction calculated_fields.fetch(:NCD400_LINE_10B)
xml.NCStandardDeduction standard_deduction
# line 16 TaxCredits is blank
xml.IncTaxWith calculated_fields.fetch(:NCD400_LINE_20A)
Expand Down
49 changes: 49 additions & 0 deletions spec/lib/efile/nc/d400_calculator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,55 @@
)
end

describe "Line 10b: Child Deduction" do
[
[["single", "married_filing_separately"], [
[20_000, 6000],
[30_000, 5000],
[40_000, 4000],
[50_000, 3000],
[60_000, 2000],
[70_000, 1000],
[70_001, 0],
]],
[["head_of_household"], [
[30_000, 6000],
[45_000, 5000],
[60_000, 4000],
[75_000, 3000],
[90_000, 2000],
[105_000, 1000],
[105_001, 0]
]],
[["married_filing_jointly", "qualifying_widow"], [
[40_000, 6000],
[60_000, 5000],
[80_000, 4000],
[100_000, 3000],
[120_000, 2000],
[140_000, 1000],
[140_001, 0]
]]
].each do |filing_statuses, agis_to_deductions|
filing_statuses.each do |filing_status|
context "#{filing_status}" do
let(:intake) { create(:state_file_nc_intake, filing_status: filing_status, raw_direct_file_data: StateFile::XmlReturnSampleService.new.read("nc_shiloh_hoh")) }
let(:calculator_instance) { described_class.new(year: MultiTenantService.statefile.current_tax_year, intake: intake) }

agis_to_deductions.each do |fagi, deduction_amount|
it "returns the value corresponding to #{fagi} FAGI multiplied by number of QCs" do
intake.direct_file_data.fed_agi = fagi
intake.direct_file_data.qualifying_children_under_age_ssn_count = 2

calculator_instance.calculate
expect(calculator_instance.lines[:NCD400_LINE_10B].value).to eq(deduction_amount)
Copy link
Contributor

Choose a reason for hiding this comment

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

[Dust] can we rename the deduction_amount to deduction_amt_for_two_children to be more explicit about the amount -- I was initially confused that there wasn't x 2 math going on but realized you had doubled the deduction amounts.

end
end
end
end
end
end

describe "Line 20a: North Carolina Income Tax Withheld" do
let(:intake) { create(:state_file_nc_intake, :df_data_2_w2s) }

Expand Down
5 changes: 4 additions & 1 deletion spec/lib/pdf_filler/nc_d400_pdf_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,15 @@

context "CTC fields" do
let(:intake) { create(:state_file_nc_intake, filing_status: "single", raw_direct_file_data: StateFile::XmlReturnSampleService.new.read("nc_shiloh_hoh")) }
let(:child_deduction) { 2000 }
before do
intake.direct_file_data.qualifying_children_under_age_ssn_count = 5
allow_any_instance_of(Efile::Nc::D400Calculator).to receive(:calculate_line_10b).and_return child_deduction
end

it "sets the correct values" do
expect(pdf_fields['y_d400wf_li10a_good']).to eq '5'
expect(pdf_fields["y_d400wf_li10a_good"]).to eq "5"
expect(pdf_fields["y_d400wf_li10b_good"]).to eq child_deduction.to_s
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,16 @@

context "CTC-related values" do
let(:intake) { create(:state_file_nc_intake, filing_status: "head_of_household", raw_direct_file_data: StateFile::XmlReturnSampleService.new.read("nc_shiloh_hoh")) }
let(:child_deduction) { 2000 }

before do
intake.direct_file_data.qualifying_children_under_age_ssn_count = 3
allow_any_instance_of(Efile::Nc::D400Calculator).to receive(:calculate_line_10b).and_return child_deduction
end

it "pulls from DF" do
expect(xml.document.at('NumChildrenAllowed').text).to eq "3"
expect(xml.document.at('ChildDeduction').text).to eq child_deduction.to_s
end
end
end
Expand Down