From cbc264979bce109d13abc1406fb0e7383474478e Mon Sep 17 00:00:00 2001 From: Matt Luedke Date: Tue, 24 Dec 2024 08:47:11 -0800 Subject: [PATCH 1/7] work in progress mark on lines that will need changes --- app/lib/efile/nj/nj1040_calculator.rb | 2 +- spec/lib/efile/nj/nj1040_calculator_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/lib/efile/nj/nj1040_calculator.rb b/app/lib/efile/nj/nj1040_calculator.rb index 9122449f6d..7e7e3a3376 100644 --- a/app/lib/efile/nj/nj1040_calculator.rb +++ b/app/lib/efile/nj/nj1040_calculator.rb @@ -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 # end end diff --git a/spec/lib/efile/nj/nj1040_calculator_spec.rb b/spec/lib/efile/nj/nj1040_calculator_spec.rb index c34ead3885..8a765808f7 100644 --- a/spec/lib/efile/nj/nj1040_calculator_spec.rb +++ b/spec/lib/efile/nj/nj1040_calculator_spec.rb @@ -365,7 +365,7 @@ def over_65_birth_year end end - describe 'line 10 and 11 dependents' do + 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 From 4caedd0ea36790a72e5c63e59ff6617a220fe508 Mon Sep 17 00:00:00 2001 From: Matt Luedke Date: Tue, 31 Dec 2024 13:23:33 -0800 Subject: [PATCH 2/7] require to be claimed as dependent to count for either line 10 or 11 --- app/lib/efile/nj/nj1040_calculator.rb | 4 +-- spec/factories/state_file_nj_intakes.rb | 6 +++++ .../fed_return_jsons/nj/zeus_two_deps.json | 2 +- spec/lib/efile/nj/nj1040_calculator_spec.rb | 26 ++++++++++++------- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/app/lib/efile/nj/nj1040_calculator.rb b/app/lib/efile/nj/nj1040_calculator.rb index 7e7e3a3376..01f02eeaef 100644 --- a/app/lib/efile/nj/nj1040_calculator.rb +++ b/app/lib/efile/nj/nj1040_calculator.rb @@ -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 end end @@ -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 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/fixtures/state_file/fed_return_jsons/nj/zeus_two_deps.json b/spec/fixtures/state_file/fed_return_jsons/nj/zeus_two_deps.json index 44c931fd65..5ea1d3e8f6 100644 --- a/spec/fixtures/state_file/fed_return_jsons/nj/zeus_two_deps.json +++ b/spec/fixtures/state_file/fed_return_jsons/nj/zeus_two_deps.json @@ -7,7 +7,7 @@ "dateOfBirth": "1920-01-01", "relationship": "parent", "eligibleDependent": true, - "isClaimedDependent": true, + "isClaimedDependent": false, "tin": "300-00-0029", "qualifyingChild": false }, diff --git a/spec/lib/efile/nj/nj1040_calculator_spec.rb b/spec/lib/efile/nj/nj1040_calculator_spec.rb index 8a765808f7..47719caec1 100644 --- a/spec/lib/efile/nj/nj1040_calculator_spec.rb +++ b/spec/lib/efile/nj/nj1040_calculator_spec.rb @@ -365,16 +365,16 @@ def over_65_birth_year end end - describe 'line 10 and 11 dependents' do # - context 'when 1 qualified child and 1 other dependent' do + describe 'line 10 and 11 dependents' do + context 'when 1 qualified child and 1 other who is not claimed dependent' do let(:intake) { create(:state_file_nj_intake, :df_data_two_deps) } - it "sets lines 10 and 11 to 1" do + 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 = 0 + 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 From be44157de0bd316a54e1fa6f46de5aeb550be785 Mon Sep 17 00:00:00 2001 From: Matt Luedke Date: Thu, 2 Jan 2025 08:41:08 -0800 Subject: [PATCH 3/7] work in progress -- comments to fix tests --- spec/lib/efile/nj/nj1040_calculator_spec.rb | 2 +- spec/lib/pdf_filler/nj1040_pdf_spec.rb | 2 +- .../ty2024/states/nj/documents/nj1040_spec.rb | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/lib/efile/nj/nj1040_calculator_spec.rb b/spec/lib/efile/nj/nj1040_calculator_spec.rb index 47719caec1..e0de4f6d94 100644 --- a/spec/lib/efile/nj/nj1040_calculator_spec.rb +++ b/spec/lib/efile/nj/nj1040_calculator_spec.rb @@ -446,7 +446,7 @@ 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_claimed_dependents_exemption = 0 + other_claimed_dependents_exemption = 1_500 # use other profile so this can stay the same 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) diff --git a/spec/lib/pdf_filler/nj1040_pdf_spec.rb b/spec/lib/pdf_filler/nj1040_pdf_spec.rb index 2be3ed28e6..795810db4c 100644 --- a/spec/lib/pdf_filler/nj1040_pdf_spec.rb +++ b/spec/lib/pdf_filler/nj1040_pdf_spec.rb @@ -618,7 +618,7 @@ } it "fills in 1 for count and $1500 for exception" do expect(pdf_fields["Text48"]).to eq "" - expect(pdf_fields["undefined_13"]).to eq "1" + expect(pdf_fields["undefined_13"]).to eq "1" #fails expect(pdf_fields["x 1500_2"]).to eq "1500" end end 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..b250d96f95 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 @@ -253,7 +253,7 @@ 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" + expect(xml.document.at('NumOfOtherDepend').text).to eq "1" #fails end end @@ -390,7 +390,7 @@ line_8_blind = 1_000 line_9_veteran = 6_000 line_10_qualified_children = 1_500 - line_11_other_dependents = 1_500 + line_11_other_dependents = 1_500 # becomes 0, mock instead line_12_dependents_attending_college = 2_000 expected_sum = line_6_single_filer + @@ -400,7 +400,7 @@ 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("Exemptions TotalExemptionAmountA").text).to eq(expected_sum.to_s) # fails expect(xml.at("Body TotalExemptionAmountB").text).to eq(expected_sum.to_s) end end From 2c66903af61016d53a10689c8185d0ad4ef2f801 Mon Sep 17 00:00:00 2001 From: Matt Luedke Date: Fri, 3 Jan 2025 15:44:54 -0800 Subject: [PATCH 4/7] update xml and pdf tests to be independent from calculator --- spec/lib/pdf_filler/nj1040_pdf_spec.rb | 36 ++---------- .../ty2024/states/nj/documents/nj1040_spec.rb | 57 ++++++------------- 2 files changed, 23 insertions(+), 70 deletions(-) diff --git a/spec/lib/pdf_filler/nj1040_pdf_spec.rb b/spec/lib/pdf_filler/nj1040_pdf_spec.rb index 795810db4c..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,15 +591,10 @@ 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" #fails + expect(pdf_fields["undefined_13"]).to eq "1" expect(pdf_fields["x 1500_2"]).to eq "1500" end end 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 b250d96f95..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" #fails - 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 # becomes 0, mock instead - 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) # fails - 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 From 48e97f4ee9e385edc979a77a4dbbfbeb8c8bbbe0 Mon Sep 17 00:00:00 2001 From: Matt Luedke Date: Fri, 3 Jan 2025 15:55:44 -0800 Subject: [PATCH 5/7] no need to change the zeus_two_deps, just use sinatra --- .../state_file/fed_return_jsons/nj/zeus_two_deps.json | 2 +- spec/lib/efile/nj/nj1040_calculator_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/fixtures/state_file/fed_return_jsons/nj/zeus_two_deps.json b/spec/fixtures/state_file/fed_return_jsons/nj/zeus_two_deps.json index 5ea1d3e8f6..44c931fd65 100644 --- a/spec/fixtures/state_file/fed_return_jsons/nj/zeus_two_deps.json +++ b/spec/fixtures/state_file/fed_return_jsons/nj/zeus_two_deps.json @@ -7,7 +7,7 @@ "dateOfBirth": "1920-01-01", "relationship": "parent", "eligibleDependent": true, - "isClaimedDependent": false, + "isClaimedDependent": true, "tin": "300-00-0029", "qualifyingChild": false }, diff --git a/spec/lib/efile/nj/nj1040_calculator_spec.rb b/spec/lib/efile/nj/nj1040_calculator_spec.rb index e0de4f6d94..51d20093c0 100644 --- a/spec/lib/efile/nj/nj1040_calculator_spec.rb +++ b/spec/lib/efile/nj/nj1040_calculator_spec.rb @@ -366,8 +366,8 @@ def over_65_birth_year end describe 'line 10 and 11 dependents' do - context 'when 1 qualified child and 1 other who is not claimed dependent' do - let(:intake) { create(:state_file_nj_intake, :df_data_two_deps) } + 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(0) From 59b230441eaebfad33151fd5f25d479e6d7a74de Mon Sep 17 00:00:00 2001 From: Matt Luedke Date: Fri, 3 Jan 2025 16:11:46 -0800 Subject: [PATCH 6/7] remove comment --- spec/lib/efile/nj/nj1040_calculator_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/lib/efile/nj/nj1040_calculator_spec.rb b/spec/lib/efile/nj/nj1040_calculator_spec.rb index 51d20093c0..4132d7a5b8 100644 --- a/spec/lib/efile/nj/nj1040_calculator_spec.rb +++ b/spec/lib/efile/nj/nj1040_calculator_spec.rb @@ -446,7 +446,7 @@ 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_claimed_dependents_exemption = 1_500 # use other profile so this can stay the same + 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) From 2cf53f64457f6ccbf2be88868a8c98c39d781320 Mon Sep 17 00:00:00 2001 From: Matt Luedke Date: Mon, 6 Jan 2025 08:55:20 -0800 Subject: [PATCH 7/7] simplify syntax --- app/lib/efile/nj/nj1040_calculator.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/lib/efile/nj/nj1040_calculator.rb b/app/lib/efile/nj/nj1040_calculator.rb index 01f02eeaef..3a13397015 100644 --- a/app/lib/efile/nj/nj1040_calculator.rb +++ b/app/lib/efile/nj/nj1040_calculator.rb @@ -223,8 +223,8 @@ def calculate_line_9 end def calculate_line_10_count - @intake.direct_file_json_data.dependents.count do |dependent| - dependent.qualifying_child && dependent.is_claimed_dependent + @intake.dependents.count do |dependent| + dependent.qualifying_child end end @@ -233,8 +233,8 @@ def calculate_line_10_exemption end def calculate_line_11_count - @intake.direct_file_json_data.dependents.count do |dependent| - !dependent.qualifying_child && dependent.is_claimed_dependent + @intake.dependents.count do |dependent| + !dependent.qualifying_child end end