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

Nj 224 check claimed as dependent for lines 10 and 11 #5312

Merged
merged 10 commits into from
Jan 6, 2025
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 @@ -224,7 +224,7 @@ def calculate_line_9

def calculate_line_10_count
@intake.direct_file_json_data.dependents.count do |dependent|
dependent.qualifying_child
dependent.qualifying_child && dependent.is_claimed_dependent
Copy link
Member

Choose a reason for hiding this comment

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

[dust] I'm ok with how this is, but so you know, the qualifying_child column in StateFileDependent is populated from direct_file_json_data during import, and all of the dependents in intake.dependents have already been filtered to be only claimed dependents.

It would be a better practice to avoid extracting data from the json when it is available in the database, especially, for example, if you needed to access other dependent fields from the database that aren't in the json.

Copy link
Contributor Author

@mluedke2 mluedke2 Jan 6, 2025

Choose a reason for hiding this comment

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

@mpidcock I didn't know that! When I search the codebase for either is_claimed_dependent or isClaimedDependent, I didn't come across any references that pointed me towards logic like that? Can you help me find it?

But regardless, I tried simplifying the logic as you said and sure enough the tests still pass. So I'll push a change to

def calculate_line_10_count
  @intake.dependents.count do |dependent|
    dependent.qualifying_child
  end
end

...

def calculate_line_11_count
  @intake.dependents.count do |dependent|
    !dependent.qualifying_child
  end
end

Copy link
Member

@mpidcock mpidcock Jan 6, 2025

Choose a reason for hiding this comment

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

@mluedke2 Well, we don't actually have a method to filter claimed dependents, because the list of dependents sourced from the XML is specifically a list of only claimed dependents. It was new this year to have json data for other members of the household, but since our database gets instantiated with the xml data and augmented by the json data, the non-dependent household members are simply never added to the list of dependents. I hope that helps and let me know if I can clarify anything else!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh ok that makes sense. Thanks!

end
end

Expand All @@ -234,7 +234,7 @@ def calculate_line_10_exemption

def calculate_line_11_count
@intake.direct_file_json_data.dependents.count do |dependent|
!dependent.qualifying_child
!dependent.qualifying_child && dependent.is_claimed_dependent
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
Copy link
Contributor

Choose a reason for hiding this comment

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

This is an improvement!

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
Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense to remove this, as it is covered in the calculator tests

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
Loading