Skip to content

Commit

Permalink
Nj 224 check claimed as dependent for lines 10 and 11 (#5312)
Browse files Browse the repository at this point in the history
* work in progress mark on lines that will need changes

* require to be claimed as dependent to count for either line 10 or 11

* work in progress -- comments to fix tests

* update xml and pdf tests to be independent from calculator

* no need to change the zeus_two_deps, just use sinatra

* remove comment

* simplify syntax
  • Loading branch information
mluedke2 authored Jan 6, 2025
1 parent 657998c commit ae5bf6c
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 80 deletions.
4 changes: 2 additions & 2 deletions app/lib/efile/nj/nj1040_calculator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def calculate_line_9
end

def calculate_line_10_count
@intake.direct_file_json_data.dependents.count do |dependent|
@intake.dependents.count do |dependent|
dependent.qualifying_child
end
end
Expand All @@ -233,7 +233,7 @@ def calculate_line_10_exemption
end

def calculate_line_11_count
@intake.direct_file_json_data.dependents.count do |dependent|
@intake.dependents.count do |dependent|
!dependent.qualifying_child
end
end
Expand Down
6 changes: 6 additions & 0 deletions spec/factories/state_file_nj_intakes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,12 @@
raw_direct_file_intake_data { StateFile::DirectFileApiResponseSampleService.new.read_json('nj_zeus_box_14') }
end

trait :df_data_hoh do
raw_direct_file_data { StateFile::DirectFileApiResponseSampleService.new.read_xml('nj_latifah_hoh') }
raw_direct_file_intake_data { StateFile::DirectFileApiResponseSampleService.new.read_json('nj_latifah_hoh') }
filing_status { "head_of_household" }
end

factory :state_file_nj_payment_info_intake do
after(:build) do |intake, _evaluator|
intake.direct_file_data.fed_agi = 10000
Expand Down
26 changes: 17 additions & 9 deletions spec/lib/efile/nj/nj1040_calculator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -366,23 +366,31 @@ def over_65_birth_year
end

describe 'line 10 and 11 dependents' do
context 'when 1 qualified child and 1 other dependent' do
let(:intake) { create(:state_file_nj_intake, :df_data_two_deps) }
it "sets lines 10 and 11 to 1" do
context 'when 1 qualified child claimed as dependent, 0 others claimed as dependent' do
let(:intake) { create(:state_file_nj_intake, :df_data_qss) }
it "sets lines 10 and 11 to 0" do
expect(instance.lines[:NJ1040_LINE_10_COUNT].value).to eq(1)
expect(instance.lines[:NJ1040_LINE_11_COUNT].value).to eq(1)
expect(instance.lines[:NJ1040_LINE_11_COUNT].value).to eq(0)
end
end

context 'when 10 qualified children and 1 other dependent' do
context 'when 10 qualified children and 1 other claimed dependent' do
let(:intake) { create(:state_file_nj_intake, :df_data_many_deps) }
it "sets line 10 to 10 and line 11 to 1" do
expect(instance.lines[:NJ1040_LINE_10_COUNT].value).to eq(10)
expect(instance.lines[:NJ1040_LINE_11_COUNT].value).to eq(1)
end
end

context 'when 0 qualified child and 0 other dependent' do
context 'when 1 qualified child but is not claimed dependent' do
let(:intake) { create(:state_file_nj_intake, :df_data_hoh) }
it "sets lines 10 and 11 to 0" do
expect(instance.lines[:NJ1040_LINE_10_COUNT].value).to eq(0)
expect(instance.lines[:NJ1040_LINE_11_COUNT].value).to eq(0)
end
end

context 'when 0 qualified child and 0 other claimed dependent' do
let(:intake) { create(:state_file_nj_intake, :df_data_minimal) }
it "sets lines 10 and 11 to 0" do
expect(instance.lines[:NJ1040_LINE_10_COUNT].value).to eq(0)
Expand Down Expand Up @@ -438,8 +446,8 @@ def over_65_birth_year
expect(instance.calculate_line_9).to eq(self_veteran)
qualified_children_exemption = 1_500
expect(instance.calculate_line_10_exemption).to eq(qualified_children_exemption)
other_dependents_exemption = 1_500
expect(instance.calculate_line_11_exemption).to eq(other_dependents_exemption)
other_claimed_dependents_exemption = 1_500
expect(instance.calculate_line_11_exemption).to eq(other_claimed_dependents_exemption)
dependents_in_college = 2_000
expect(instance.calculate_line_12).to eq(dependents_in_college)
expect(instance.lines[:NJ1040_LINE_13].value).to eq(
Expand All @@ -448,7 +456,7 @@ def over_65_birth_year
self_blind +
self_veteran +
qualified_children_exemption +
other_dependents_exemption +
other_claimed_dependents_exemption +
dependents_in_college
)
end
Expand Down
34 changes: 5 additions & 29 deletions spec/lib/pdf_filler/nj1040_pdf_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -553,40 +553,26 @@

describe "Line 10 exemptions" do
context "0 qualified dependent children" do
let(:submission) {
create :efile_submission, tax_return: nil, data_source: create(
:state_file_nj_intake
)
}
it "does not fill in" do
allow_any_instance_of(Efile::Nj::Nj1040Calculator).to receive(:calculate_line_10_count).and_return 0
expect(pdf_fields["Text47"]).to eq ""
expect(pdf_fields["undefined_12"]).to eq ""
expect(pdf_fields["x 1500"]).to eq ""
end
end

context "1 qualified dependent child" do
let(:submission) {
create :efile_submission, tax_return: nil, data_source: create(
:state_file_nj_intake,
:df_data_two_deps,
)
}
it "fills in 1 for count and $1500 for exception" do
allow_any_instance_of(Efile::Nj::Nj1040Calculator).to receive(:calculate_line_10_count).and_return 1
expect(pdf_fields["Text47"]).to eq ""
expect(pdf_fields["undefined_12"]).to eq "1"
expect(pdf_fields["x 1500"]).to eq "1500"
end
end

context "10 qualified dependent children" do
let(:submission) {
create :efile_submission, tax_return: nil, data_source: create(
:state_file_nj_intake,
:df_data_many_deps,
)
}
it "fills in 10 for count and $15000 for exception" do
allow_any_instance_of(Efile::Nj::Nj1040Calculator).to receive(:calculate_line_10_count).and_return 10
expect(pdf_fields["Text47"]).to eq "1"
expect(pdf_fields["undefined_12"]).to eq "0"
expect(pdf_fields["x 1500"]).to eq "15000"
Expand All @@ -596,27 +582,17 @@

describe "Line 11 exemptions" do
context "0 dependents not qualifying children" do
let(:submission) {
create :efile_submission, tax_return: nil, data_source: create(
:state_file_nj_intake,
:df_data_minimal,
)
}
it "does not fill in" do
allow_any_instance_of(Efile::Nj::Nj1040Calculator).to receive(:calculate_line_11_count).and_return 0
expect(pdf_fields["Text48"]).to eq ""
expect(pdf_fields["undefined_13"]).to eq ""
expect(pdf_fields["x 1500_2"]).to eq ""
end
end

context "1 dependent not qualifying child" do
let(:submission) {
create :efile_submission, tax_return: nil, data_source: create(
:state_file_nj_intake,
:df_data_two_deps,
)
}
it "fills in 1 for count and $1500 for exception" do
allow_any_instance_of(Efile::Nj::Nj1040Calculator).to receive(:calculate_line_11_count).and_return 1
expect(pdf_fields["Text48"]).to eq ""
expect(pdf_fields["undefined_13"]).to eq "1"
expect(pdf_fields["x 1500_2"]).to eq "1500"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,28 +249,20 @@
end

describe "qualified dependent children and other dependents" do
context 'when 1 qualified child and 1 other dependent' do
let(:intake) { create(:state_file_nj_intake, :df_data_two_deps) }
it "sets NumOfQualiDependChild and NumOfOtherDepend to 1" do
expect(xml.document.at('NumOfQualiDependChild').text).to eq "1"
expect(xml.document.at('NumOfOtherDepend').text).to eq "1"
end
end

context 'when 10 qualified children and 1 other dependent' do
let(:intake) { create(:state_file_nj_intake, :df_data_many_deps) }
it "sets NumOfQualiDependChild to 10 and NumOfOtherDepend to 1" do
expect(xml.document.at('NumOfQualiDependChild').text).to eq "10"
expect(xml.document.at('NumOfOtherDepend').text).to eq "1"
end
it "sets NumOfQualiDependChild to line 10 and NumOfOtherDepend to line 11" do
allow_any_instance_of(Efile::Nj::Nj1040Calculator).to receive(:calculate_line_10_count).and_return 1
allow_any_instance_of(Efile::Nj::Nj1040Calculator).to receive(:calculate_line_11_count).and_return 2

expect(xml.document.at('NumOfQualiDependChild').text).to eq "1"
expect(xml.document.at('NumOfOtherDepend').text).to eq "2"
end
context 'when 0 qualified child and 0 other dependent' do
let(:intake) { create(:state_file_nj_intake, :df_data_minimal) }
it "leaves NumOfQualiDependChild and NumOfOtherDepend blank" do
expect(xml.document.at('NumOfQualiDependChild')).to eq nil
expect(xml.document.at('NumOfOtherDepend')).to eq nil
end

it "leaves NumOfQualiDependChild and NumOfOtherDepend blank when lines 10 and 11 are empty" do
allow_any_instance_of(Efile::Nj::Nj1040Calculator).to receive(:calculate_line_10_count).and_return 0
allow_any_instance_of(Efile::Nj::Nj1040Calculator).to receive(:calculate_line_11_count).and_return 0

expect(xml.document.at('NumOfQualiDependChild')).to eq nil
expect(xml.document.at('NumOfOtherDepend')).to eq nil
end
end

Expand Down Expand Up @@ -383,25 +375,10 @@
end

describe "total exemption - lines 13 and 30" do
let(:intake) { create(:state_file_nj_intake, :primary_over_65, :primary_blind, :primary_veteran, :two_dependents_in_college) }
it "totals lines 6-12 and stores the result in both TotalExemptionAmountA and TotalExemptionAmountB" do
line_6_single_filer = 1_000
line_7_over_65 = 1_000
line_8_blind = 1_000
line_9_veteran = 6_000
line_10_qualified_children = 1_500
line_11_other_dependents = 1_500
line_12_dependents_attending_college = 2_000
expected_sum =
line_6_single_filer +
line_7_over_65 +
line_8_blind +
line_9_veteran +
line_10_qualified_children +
line_11_other_dependents +
line_12_dependents_attending_college
expect(xml.at("Exemptions TotalExemptionAmountA").text).to eq(expected_sum.to_s)
expect(xml.at("Body TotalExemptionAmountB").text).to eq(expected_sum.to_s)
it "stores line 13 and 30 (equivalent) in both TotalExemptionAmountA and TotalExemptionAmountB" do
allow_any_instance_of(Efile::Nj::Nj1040Calculator).to receive(:calculate_line_13).and_return 10_000
expect(xml.at("Exemptions TotalExemptionAmountA").text).to eq(10_000.to_s)
expect(xml.at("Body TotalExemptionAmountB").text).to eq(10_000.to_s)
end
end

Expand Down

0 comments on commit ae5bf6c

Please sign in to comment.