diff --git a/app/lib/efile/nj/nj1040_calculator.rb b/app/lib/efile/nj/nj1040_calculator.rb index 9122449f6d..3a13397015 100644 --- a/app/lib/efile/nj/nj1040_calculator.rb +++ b/app/lib/efile/nj/nj1040_calculator.rb @@ -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 @@ -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 diff --git a/spec/factories/state_file_nj_intakes.rb b/spec/factories/state_file_nj_intakes.rb index 9f8a54413a..3648da8bd6 100644 --- a/spec/factories/state_file_nj_intakes.rb +++ b/spec/factories/state_file_nj_intakes.rb @@ -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 diff --git a/spec/lib/efile/nj/nj1040_calculator_spec.rb b/spec/lib/efile/nj/nj1040_calculator_spec.rb index c34ead3885..4132d7a5b8 100644 --- a/spec/lib/efile/nj/nj1040_calculator_spec.rb +++ b/spec/lib/efile/nj/nj1040_calculator_spec.rb @@ -366,15 +366,15 @@ 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) @@ -382,7 +382,15 @@ def over_65_birth_year 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) @@ -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( @@ -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 diff --git a/spec/lib/pdf_filler/nj1040_pdf_spec.rb b/spec/lib/pdf_filler/nj1040_pdf_spec.rb index 2be3ed28e6..ff76d93f69 100644 --- a/spec/lib/pdf_filler/nj1040_pdf_spec.rb +++ b/spec/lib/pdf_filler/nj1040_pdf_spec.rb @@ -553,12 +553,8 @@ 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 "" @@ -566,13 +562,8 @@ 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" @@ -580,13 +571,8 @@ 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" @@ -596,13 +582,8 @@ 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 "" @@ -610,13 +591,8 @@ 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" diff --git a/spec/lib/submission_builder/ty2024/states/nj/documents/nj1040_spec.rb b/spec/lib/submission_builder/ty2024/states/nj/documents/nj1040_spec.rb index 3ce52a450b..fef77e1041 100644 --- a/spec/lib/submission_builder/ty2024/states/nj/documents/nj1040_spec.rb +++ b/spec/lib/submission_builder/ty2024/states/nj/documents/nj1040_spec.rb @@ -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 @@ -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