From 2d541b357d57b09569ba389bc25fb4810f001628 Mon Sep 17 00:00:00 2001 From: John Chan Date: Fri, 21 Feb 2025 16:19:58 -0500 Subject: [PATCH] Revert commit 90c1bd7acd3bf6ff32b5193de5e092104b2e87ac --- .../questions/nj_review_controller.rb | 2 +- app/lib/efile/line_data.yml | 6 - app/lib/efile/nj/nj1040_calculator.rb | 25 +-- .../efile/nj/nj_retirement_income_helper.rb | 91 ----------- app/lib/pdf_filler/nj1040_pdf.rb | 88 +++-------- .../ty2024/states/nj/documents/nj1040.rb | 12 -- config/locales/en.yml | 1 - config/locales/es.yml | 1 - spec/factories/state_file_nj_intakes.rb | 14 -- .../state_file/nj/complete_intake_spec.rb | 12 +- spec/lib/efile/nj/nj1040_calculator_spec.rb | 63 +------- .../nj/nj_retirement_income_helper_spec.rb | 143 ------------------ spec/lib/pdf_filler/nj1040_pdf_spec.rb | 116 +------------- .../ty2024/states/nj/documents/nj1040_spec.rb | 51 ------- 14 files changed, 33 insertions(+), 592 deletions(-) delete mode 100644 app/lib/efile/nj/nj_retirement_income_helper.rb delete mode 100644 spec/lib/efile/nj/nj_retirement_income_helper_spec.rb diff --git a/app/controllers/state_file/questions/nj_review_controller.rb b/app/controllers/state_file/questions/nj_review_controller.rb index 05768491ee..6d2fbe9b74 100644 --- a/app/controllers/state_file/questions/nj_review_controller.rb +++ b/app/controllers/state_file/questions/nj_review_controller.rb @@ -10,7 +10,7 @@ def get_detailed_return_info { text_key: '16a_interest_income', value: line_or_zero(:NJ1040_LINE_16A) }, { text_key: '20a_retirement_income', value: line_or_zero(:NJ1040_LINE_20A) }, { text_key: '27_total_income', value: line_or_zero(:NJ1040_LINE_27) }, - { text_key: '28c_retirement_excluded_from_taxation', value: line_or_zero(:NJ1040_LINE_28C) }, + # { text_key: '28c_retirement_excluded_from_taxation', value: line_or_zero(:NJ1040_LINE_28C) }, { text_key: '29_nj_gross_income', value: line_or_zero(:NJ1040_LINE_29) }, { text_key: '30_exemptions', value: line_or_zero(:NJ1040_LINE_13) }, # same value for 13 and 30 { text_key: '31_medical', value: line_or_zero(:NJ1040_LINE_31) }, diff --git a/app/lib/efile/line_data.yml b/app/lib/efile/line_data.yml index ee722ee772..80e369e360 100644 --- a/app/lib/efile/line_data.yml +++ b/app/lib/efile/line_data.yml @@ -896,12 +896,6 @@ NJ1040_LINE_20B: label: '20b Excludable pension, annuity, and IRA distributions/withdrawals (See instr)' NJ1040_LINE_27: label: '27 Total Income (Add lines 15, 16a, and 20a)' -NJ1040_LINE_28A: - label: '28a Pension/Retirement Exclusion (See instructions)' -NJ1040_LINE_28B: - label: '28b Retirement Income Exclusion (See Worksheet D and instructions pages 20–21)' -NJ1040_LINE_28C: - label: '28c Total Exclusion Amount (Add lines 28a and 28b)' NJ1040_LINE_29: label: "29 New Jersey Gross Income (Subtract line 28c from line 27) (See instructions)" NJ1040_LINE_31: diff --git a/app/lib/efile/nj/nj1040_calculator.rb b/app/lib/efile/nj/nj1040_calculator.rb index e796e9174f..8a34e9d00d 100644 --- a/app/lib/efile/nj/nj1040_calculator.rb +++ b/app/lib/efile/nj/nj1040_calculator.rb @@ -21,7 +21,6 @@ def initialize(year:, intake:, include_source: false) intake: @intake, primary_or_spouse: :spouse ) - @nj_retirement_income_helper = Efile::Nj::NjRetirementIncomeHelper.new(@intake) end def calculate @@ -42,9 +41,6 @@ def calculate set_line(:NJ1040_LINE_20A, :calculate_line_20a) set_line(:NJ1040_LINE_20B, :calculate_line_20b) set_line(:NJ1040_LINE_27, :calculate_line_27) - set_line(:NJ1040_LINE_28A, :calculate_line_28a) - set_line(:NJ1040_LINE_28B, :calculate_line_28b) - set_line(:NJ1040_LINE_28C, :calculate_line_28c) set_line(:NJ1040_LINE_29, :calculate_line_29) set_line(:NJ1040_LINE_31, :calculate_line_31) set_line(:NJ1040_LINE_38, :calculate_line_38) @@ -335,27 +331,8 @@ def calculate_line_27 line_or_zero(:NJ1040_LINE_15) + line_or_zero(:NJ1040_LINE_16A) + line_or_zero(:NJ1040_LINE_20A) end - def calculate_line_28a - 0 - end - - def calculate_line_28b - return 0 unless @nj_retirement_income_helper.retirement_exclusion_eligible?( - line_or_zero(:NJ1040_LINE_15), - line_or_zero(:NJ1040_LINE_27), - line_or_zero(:NJ1040_LINE_28A)) - - total_income = line_or_zero(:NJ1040_LINE_27) - [@nj_retirement_income_helper.calculate_maximum_exclusion(total_income) - line_or_zero(:NJ1040_LINE_28A), - @nj_retirement_income_helper.total_eligible_nonretirement_income].min - end - - def calculate_line_28c - line_or_zero(:NJ1040_LINE_28A) + line_or_zero(:NJ1040_LINE_28B) - end - def calculate_line_29 - line_or_zero(:NJ1040_LINE_27) - line_or_zero(:NJ1040_LINE_28C) + line_or_zero(:NJ1040_LINE_27) end def calculate_line_31 diff --git a/app/lib/efile/nj/nj_retirement_income_helper.rb b/app/lib/efile/nj/nj_retirement_income_helper.rb deleted file mode 100644 index ada3881a9f..0000000000 --- a/app/lib/efile/nj/nj_retirement_income_helper.rb +++ /dev/null @@ -1,91 +0,0 @@ -module Efile - module Nj - class NjRetirementIncomeHelper - def initialize(intake) - @intake = intake - end - - def total_eligible_nonretirement_income - total_income = 0 - eligible_ssn = [] - if primary_62_and_older? - eligible_ssn.push(@intake.primary.ssn) - end - if @intake.spouse_birth_date.present? && spouse_62_and_older? - eligible_ssn.push(@intake.spouse.ssn) - end - @intake.state_file_w2s.each do |w2| - if w2.employee_ssn.in?(eligible_ssn) - total_income += w2.state_wages_amount.to_i - end - end - @intake.direct_file_json_data.interest_reports.each do |interest_report| - sanitized_recipient_tin = interest_report.recipient_tin.delete("-") - if sanitized_recipient_tin.in?(eligible_ssn) - total_income += (interest_report.amount_1099&.round || 0) + (interest_report.amount_no_1099&.round || 0) - end - end - total_income - end - - def primary_62_and_older? - @intake.calculate_age(@intake.primary_birth_date, inclusive_of_jan_1: false) >= 62 - end - - def spouse_62_and_older? - @intake.calculate_age(@intake.spouse_birth_date, inclusive_of_jan_1: false) >= 62 - end - - def retirement_exclusion_eligible?(line_15, line_27, line_28a) - if @intake.spouse_birth_date.present? - spouse_or_primary_is_age_eligible = spouse_62_and_older? || primary_62_and_older? - return false unless spouse_or_primary_is_age_eligible - elsif !primary_62_and_older? - return false - end - return false if line_15 > 3_000 - return false if line_27 > 150_000 - return false if line_28a > calculate_maximum_exclusion(line_27) - - true - end - - def calculate_maximum_exclusion(total_income) - if @intake.filing_status_mfs? - case total_income - when 0..100_000 - 50_000 - when 100_001..125_000 - (0.25 * total_income).round - when 125_001..150_000 - (0.125 * total_income).round - else - 0 - end - elsif @intake.filing_status_mfj? - case total_income - when 0..100_000 - 100_000 - when 100_001..125_000 - (0.5 * total_income).round - when 125_001..150_000 - (0.25 * total_income).round - else - 0 - end - else - case total_income - when 0..100_000 - 75_000 - when 100_001..125_000 - (0.375 * total_income).round - when 125_001..150_000 - (0.1875 * total_income).round - else - 0 - end - end - end - end - end -end \ No newline at end of file diff --git a/app/lib/pdf_filler/nj1040_pdf.rb b/app/lib/pdf_filler/nj1040_pdf.rb index c9a3396de9..af89db26f1 100644 --- a/app/lib/pdf_filler/nj1040_pdf.rb +++ b/app/lib/pdf_filler/nj1040_pdf.rb @@ -273,36 +273,35 @@ def hash_for_pdf if @xml_document.at("PensAnnuitAndIraWithdraw") taxable_retirement_income = @xml_document.at("PensAnnuitAndIraWithdraw").text.to_i answers.merge!(insert_digits_into_fields(taxable_retirement_income, [ - "141", - "140", - "139", - "138", - "137", - "136", - "undefined_56", - "undefined_55", - "undefined_54", - "20a" - ])) + "141", + "140", + "139", + "138", + "137", + "136", + "undefined_56", + "undefined_55", + "undefined_54", + "20a" + ])) end # line 20b if @xml_document.at("TaxExemptPensAnnuit") excludable_retirement_income = @xml_document.at("TaxExemptPensAnnuit").text.to_i answers.merge!(insert_digits_into_fields(excludable_retirement_income, [ - "146", - "undefined_59", - "145", - "144", - "undefined_58", - "143", - "142", - "undefined_57", - "20b" - ])) + "146", + "undefined_59", + "145", + "144", + "undefined_58", + "143", + "142", + "undefined_57", + "20b" + ])) end - # line 27 if @xml_document.at("TotalIncome").present? total_income = @xml_document.at("TotalIncome").text.to_i answers.merge!(insert_digits_into_fields(total_income, [ @@ -320,51 +319,6 @@ def hash_for_pdf ])) end - # line 28a - if @xml_document.at("PensionExclusion").present? - other_retirement_income_exclusion = @xml_document.at("PensionExclusion").text.to_i - answers.merge!(insert_digits_into_fields(other_retirement_income_exclusion, [ - "193", - "undefined_82", - "192", - "191", - "undefined_81", - "190", - "189", - "28a" - ])) - end - - # line 28b - if @xml_document.at("OtherRetireIncomeExclus").present? - other_retirement_income_exclusion = @xml_document.at("OtherRetireIncomeExclus").text.to_i - answers.merge!(insert_digits_into_fields(other_retirement_income_exclusion, [ - "198", - "undefined_84", - "197", - "196", - "undefined_83", - "195", - "194", - "28b" - ])) - end - - # line 28c - if @xml_document.at("TotalExclusionAmount").present? - other_retirement_income_exclusion = @xml_document.at("TotalExclusionAmount").text.to_i - answers.merge!(insert_digits_into_fields(other_retirement_income_exclusion, [ - "203", - "undefined_86", - "202", - "201", - "undefined_85", - "200", - "199", - "28c" - ])) - end - if @xml_document.at("GrossIncome").present? gross_income = @xml_document.at("GrossIncome").text.to_i answers.merge!(insert_digits_into_fields(gross_income, [ diff --git a/app/lib/submission_builder/ty2024/states/nj/documents/nj1040.rb b/app/lib/submission_builder/ty2024/states/nj/documents/nj1040.rb index e8ccd9fd8b..66d18e3889 100644 --- a/app/lib/submission_builder/ty2024/states/nj/documents/nj1040.rb +++ b/app/lib/submission_builder/ty2024/states/nj/documents/nj1040.rb @@ -137,18 +137,6 @@ def document xml.TotalIncome calculated_fields.fetch(:NJ1040_LINE_27) end - if calculated_fields.fetch(:NJ1040_LINE_28A).positive? - xml.PensionExclusion calculated_fields.fetch(:NJ1040_LINE_28A) - end - - if calculated_fields.fetch(:NJ1040_LINE_28B).positive? - xml.OtherRetireIncomeExclus calculated_fields.fetch(:NJ1040_LINE_28B) - end - - if calculated_fields.fetch(:NJ1040_LINE_28C).positive? - xml.TotalExclusionAmount calculated_fields.fetch(:NJ1040_LINE_28C) - end - if calculated_fields.fetch(:NJ1040_LINE_29).positive? xml.GrossIncome calculated_fields.fetch(:NJ1040_LINE_29) end diff --git a/config/locales/en.yml b/config/locales/en.yml index d2256522ad..b633b328b9 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -3689,7 +3689,6 @@ en: 16a_interest_income: Interest income 20a_retirement_income: Retirement income 27_total_income: Total income - 28c_retirement_excluded_from_taxation: Retirement income excluded from Taxation 29_nj_gross_income: New Jersey Gross Income 30_exemptions: Exemptions (based on the size of your family, disability status, veteran status) 31_medical: Medical expenses deducted diff --git a/config/locales/es.yml b/config/locales/es.yml index e086ac1826..52facff2a5 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -3661,7 +3661,6 @@ es: 16a_interest_income: Ingreso total 20a_retirement_income: Retirement income 27_total_income: Ingreso total - 28c_retirement_excluded_from_taxation: Ingresos de jubilación excluidos del impuesto 29_nj_gross_income: Ingreso Bruto de New Jersey 30_exemptions: Exenciones (según el tamaño de tu familia, estado de discapacidad, estado de veterano/a de guerra) 31_medical: Gastos médicos deducidos diff --git a/spec/factories/state_file_nj_intakes.rb b/spec/factories/state_file_nj_intakes.rb index 2ee8fa6813..1bf883f344 100644 --- a/spec/factories/state_file_nj_intakes.rb +++ b/spec/factories/state_file_nj_intakes.rb @@ -330,20 +330,6 @@ primary_birth_date { Date.new(1900, 1, 1) } end - trait :primary_over_62 do - primary_birth_date { Date.new(MultiTenantService.new(:statefile).current_tax_year - 62, 12, 31) } - end - - trait :primary_under_62 do - primary_birth_date { Date.new(MultiTenantService.new(:statefile).current_tax_year - 61, 1, 1) } - end - - trait :mfj_spouse_over_62 do - filing_status { "married_filing_jointly" } - spouse_birth_date { Date.new(MultiTenantService.new(:statefile).current_tax_year - 62, 12, 31) } - spouse_ssn { "123456789" } - end - trait :mfj_spouse_over_65 do filing_status { "married_filing_jointly" } spouse_birth_date { Date.new(1900, 1, 1) } diff --git a/spec/features/state_file/nj/complete_intake_spec.rb b/spec/features/state_file/nj/complete_intake_spec.rb index 6182c4f430..13d63a3c75 100644 --- a/spec/features/state_file/nj/complete_intake_spec.rb +++ b/spec/features/state_file/nj/complete_intake_spec.rb @@ -279,7 +279,7 @@ def check_xml_results click_on I18n.t("state_file.questions.nj_review.edit.reveal.header") amounts_in_calculation_details = page.all(:xpath, '//*[contains(@class,"main-content-inner")]/section[last()]//p[contains(text(),"$")]') - expect(amounts_in_calculation_details.count).to eq(21) + expect(amounts_in_calculation_details.count).to eq(20) expect(page).to be_axe_clean continue @@ -570,7 +570,7 @@ def expect_municipality_question_hidden expect_municipality_question_exists # unselect county - within find_by_id('county-question') do + within find('#county-question') do select I18n.t('general.select_prompt') end expect_county_question_exists @@ -581,7 +581,7 @@ def expect_municipality_question_hidden advance_to_start_of_intake("Minimal", expect_income_review: false) select "Atlantic" - within find_by_id('municipality-question') do + within find('#municipality-question') do expect(page.all("option").length).to eq(24) # 23 municipalities + 1 "- Select -" expect(page).to have_text "Absecon City" expect(page).to have_text "Atlantic City" @@ -590,7 +590,7 @@ def expect_municipality_question_hidden end select "Mercer" - within find_by_id('municipality-question') do + within find('#municipality-question') do expect(page.all("option").length).to eq(13) # 12 municipalities + 1 "- Select -" expect(page).to have_text "East Windsor Township" expect(page).to have_text "Hopewell Township" @@ -603,10 +603,10 @@ def expect_municipality_question_hidden select "Atlantic" select "Absecon City" - expect(find_by_id('state_file_nj_county_municipality_form_municipality_code').value).to eq("0101") + expect(find("#state_file_nj_county_municipality_form_municipality_code").value).to eq("0101") select "Mercer" - expect(find_by_id('state_file_nj_county_municipality_form_municipality_code').value).to eq("") + expect(find("#state_file_nj_county_municipality_form_municipality_code").value).to eq("") end end diff --git a/spec/lib/efile/nj/nj1040_calculator_spec.rb b/spec/lib/efile/nj/nj1040_calculator_spec.rb index af29144c32..13a4311173 100644 --- a/spec/lib/efile/nj/nj1040_calculator_spec.rb +++ b/spec/lib/efile/nj/nj1040_calculator_spec.rb @@ -623,71 +623,14 @@ def over_65_birth_year end end - describe 'line 28b - other retirement income exclusion' do - let(:intake) { create(:state_file_nj_intake) } - - context 'when taxpayer is ineligible' do - it 'sets line 28b to 0' do - allow_any_instance_of(Efile::Nj::NjRetirementIncomeHelper).to receive(:retirement_exclusion_eligible?).and_return false - instance.calculate - expect(instance.lines[:NJ1040_LINE_28B].value).to eq(0) - end - end - - context 'when taxpayer is eligible' do - context 'when maximum_exclusion minus 28a is greater than total_eligible_nonretirement_income' do - it 'sets line 28b to total_eligible_nonretirement_income' do - allow_any_instance_of(Efile::Nj::NjRetirementIncomeHelper).to receive(:retirement_exclusion_eligible?).and_return true - allow_any_instance_of(Efile::Nj::NjRetirementIncomeHelper).to receive(:calculate_maximum_exclusion).and_return 50_000 - allow(instance).to receive(:calculate_line_28a).and_return 48_000 - allow_any_instance_of(Efile::Nj::NjRetirementIncomeHelper).to receive(:total_eligible_nonretirement_income).and_return 1_999 - instance.calculate - expect(instance.lines[:NJ1040_LINE_28B].value).to eq(1_999) - end - end - - context 'when maximum_exclusion minus 28a is less than total_eligible_nonretirement_income' do - it 'sets line 28b to maximum_exclusion minus 28a' do - allow_any_instance_of(Efile::Nj::NjRetirementIncomeHelper).to receive(:retirement_exclusion_eligible?).and_return true - allow_any_instance_of(Efile::Nj::NjRetirementIncomeHelper).to receive(:calculate_maximum_exclusion).and_return 50_000 - allow(instance).to receive(:calculate_line_28a).and_return 1_000 - allow_any_instance_of(Efile::Nj::NjRetirementIncomeHelper).to receive(:total_eligible_nonretirement_income).and_return 49_001 - instance.calculate - expect(instance.lines[:NJ1040_LINE_28B].value).to eq(49_000) - end - end - - context 'when maximum_exclusion minus 28a is equal to total_eligible_nonretirement_income' do - it 'sets line 28b to total_eligible_nonretirement_income' do - allow_any_instance_of(Efile::Nj::NjRetirementIncomeHelper).to receive(:retirement_exclusion_eligible?).and_return true - allow_any_instance_of(Efile::Nj::NjRetirementIncomeHelper).to receive(:calculate_maximum_exclusion).and_return 50_000 - allow(instance).to receive(:calculate_line_28a).and_return 1_000 - allow_any_instance_of(Efile::Nj::NjRetirementIncomeHelper).to receive(:total_eligible_nonretirement_income).and_return 49_000 - instance.calculate - expect(instance.lines[:NJ1040_LINE_28B].value).to eq(49_000) - end - end - end - end - - describe 'line 28c - total exclusion amount' do - it 'sets line 28c to 28a plus 28b' do - allow(instance).to receive(:calculate_line_28a).and_return 1_000 - allow(instance).to receive(:calculate_line_28b).and_return 2_000 - instance.calculate - expect(instance.lines[:NJ1040_LINE_28C].value).to eq(3_000) - end - end - describe 'line 29 - gross income' do let(:intake) { create(:state_file_nj_intake) } - it 'sets line 29 to the sum of all state wage amounts minus 28c' do - allow(instance).to receive(:calculate_line_15).and_return 50_000 + it 'sets line 29 to the sum of all state wage amounts' do + allow(instance).to receive(:calculate_line_15).and_return 50000 allow(instance).to receive(:calculate_line_16a).and_return 1_000 - allow(instance).to receive(:calculate_line_28c).and_return 3_000 instance.calculate - expect(instance.lines[:NJ1040_LINE_29].value).to eq(48_000) + expect(instance.lines[:NJ1040_LINE_29].value).to eq(51_000) end end diff --git a/spec/lib/efile/nj/nj_retirement_income_helper_spec.rb b/spec/lib/efile/nj/nj_retirement_income_helper_spec.rb deleted file mode 100644 index 9652dbd60f..0000000000 --- a/spec/lib/efile/nj/nj_retirement_income_helper_spec.rb +++ /dev/null @@ -1,143 +0,0 @@ -require 'rails_helper' - -RSpec.describe Efile::Nj::NjRetirementIncomeHelper do - describe ".calculate_maximum_exclusion" do - [ - { total_income: 100_000, expected: 75_000 }, - { traits: [:head_of_household], total_income: 100_000, expected: 75_000 }, - { traits: [:qualifying_widow], total_income: 100_000, expected: 75_000 }, - { traits: [:married_filing_jointly], total_income: 100_000, expected: 100_000 }, - { traits: [:married_filing_separately], total_income: 100_000, expected: 50_000 }, - - { total_income: 100_001, expected: 37_500 }, - { traits: [:head_of_household], total_income: 100_001, expected: 37_500 }, - { traits: [:qualifying_widow], total_income: 100_001, expected: 37_500 }, - { traits: [:married_filing_jointly], total_income: 100_001, expected: 50_001 }, - { traits: [:married_filing_separately], total_income: 100_001, expected: 25_000 }, - - { total_income: 125_000, expected: 46_875 }, - { traits: [:head_of_household], total_income: 125_000, expected: 46_875 }, - { traits: [:qualifying_widow], total_income: 125_000, expected: 46_875 }, - { traits: [:married_filing_jointly], total_income: 125_000, expected: 62_500 }, - { traits: [:married_filing_separately], total_income: 125_000, expected: 31_250 }, - - { total_income: 125_001, expected: 23_438 }, - { traits: [:head_of_household], total_income: 125_001, expected: 23_438 }, - { traits: [:qualifying_widow], total_income: 125_001, expected: 23_438 }, - { traits: [:married_filing_jointly], total_income: 125_001, expected: 31_250 }, - { traits: [:married_filing_separately], total_income: 125_001, expected: 15_625 }, - - { total_income: 150_000, expected: 28_125 }, - { traits: [:head_of_household], total_income: 150_000, expected: 28_125 }, - { traits: [:qualifying_widow], total_income: 150_000, expected: 28_125 }, - { traits: [:married_filing_jointly], total_income: 150_000, expected: 37_500 }, - { traits: [:married_filing_separately], total_income: 150_000, expected: 18_750 }, - - { total_income: 150_001, expected: 0 }, - { traits: [:head_of_household], total_income: 150_001, expected: 0 }, - { traits: [:qualifying_widow], total_income: 150_001, expected: 0 }, - { traits: [:married_filing_jointly], total_income: 150_001, expected: 0 }, - { traits: [:married_filing_separately], total_income: 150_001, expected: 0 }, - ].each do |test_case| - context "when filing with #{test_case}" do - let(:intake) do - create(:state_file_nj_intake, *test_case[:traits]) - end - it "returns #{test_case[:expected]}" do - helper = Efile::Nj::NjRetirementIncomeHelper.new(intake) - result = helper.calculate_maximum_exclusion(test_case[:total_income]) - expect(result).to eq(test_case[:expected]) - end - end - end - - describe ".retirement_exclusion_eligible?" do - [ - { traits: [:mfj_spouse_over_62], line_15: 3_000, line_27: 150_000, line_28a: 37_500, expected: true }, - { traits: [:primary_over_62], line_15: 3_000, line_27: 150_000, line_28a: 28_125, expected: true }, - { traits: [:primary_under_62], line_15: 3_000, line_27: 150_000, line_28a: 28_125, expected: false }, - { traits: [:primary_over_62], line_15: 3_000, line_27: 150_001, line_28a: 0, expected: false }, - { traits: [:primary_over_62], line_15: 3_001, line_27: 99_999, line_28a: 0, expected: false }, - { traits: [:primary_over_62], line_15: 3_000, line_27: 150_000, line_28a: 100_000, expected: false }, - ].each do |test_case| - context "when filing with #{test_case}" do - let(:intake) do - create(:state_file_nj_intake, *test_case[:traits]) - end - let(:instance) do - Efile::Nj::Nj1040Calculator.new( - year: MultiTenantService.statefile.current_tax_year, - intake: intake - ) - end - let(:helper) do - Efile::Nj::NjRetirementIncomeHelper.new(intake) - end - before do - allow_any_instance_of(Efile::Nj::Nj1040Calculator).to receive(:calculate_line_15).and_return(test_case[:line_15]) - allow_any_instance_of(Efile::Nj::Nj1040Calculator).to receive(:calculate_line_27).and_return(test_case[:line_27]) - allow_any_instance_of(Efile::Nj::Nj1040Calculator).to receive(:calculate_line_28a).and_return(test_case[:line_28a]) - instance.calculate - end - - it "returns #{test_case[:expected]}" do - result = helper.retirement_exclusion_eligible?(test_case[:line_15], test_case[:line_27], test_case[:line_28a]) - expect(result).to eq(test_case[:expected]) - end - end - end - end - - describe ".total_eligible_nonretirement_income" do - let(:helper) do - Efile::Nj::NjRetirementIncomeHelper.new(intake) - end - before do - primary_ssn = 400000015 - spouse_ssn = 123456789 - first_w2 = intake.state_file_w2s.first - first_w2.update_attribute(:employee_ssn, primary_ssn) - first_w2.update_attribute(:state_wages_amount, 1_000) - first_1099_int = intake.direct_file_json_data.interest_reports.first - first_1099_int.recipient_tin = primary_ssn.to_s - first_1099_int.amount_1099 = 2_000 - first_1099_int.amount_no_1099 = nil - second_1099_int = intake.direct_file_json_data.interest_reports.second - second_1099_int.recipient_tin = spouse_ssn.to_s - second_1099_int.amount_1099 = nil - second_1099_int.amount_no_1099 = 4_000 - end - context "when primary and spouse are both over 62" do - let(:intake) { create(:state_file_nj_intake, :df_data_one_dep, :primary_over_62, :mfj_spouse_over_62) } - - it 'sums both spouse and primary wages in total eligible income' do - expect(helper.total_eligible_nonretirement_income).to eq(7_000) - end - end - - context "when only primary is over 62" do - let(:intake) { create(:state_file_nj_intake, :df_data_one_dep, :primary_over_62) } - - it 'sums only primary wages in total eligible income' do - expect(helper.total_eligible_nonretirement_income).to eq(3_000) - end - end - - context "when only spouse is over 62" do - let(:intake) { create(:state_file_nj_intake, :df_data_one_dep, :mfj_spouse_over_62) } - - it 'sums only spouse wages in total eligible income' do - expect(helper.total_eligible_nonretirement_income).to eq(4_000) - end - end - - context "when neither primary or spouse is over 62" do - let(:intake) { create(:state_file_nj_intake, :df_data_one_dep, :primary_under_62) } - - it 'sums neither filers wages in total eligible income' do - expect(helper.total_eligible_nonretirement_income).to eq(0) - end - end - end - end -end diff --git a/spec/lib/pdf_filler/nj1040_pdf_spec.rb b/spec/lib/pdf_filler/nj1040_pdf_spec.rb index df07aa8d11..e32fc86b21 100644 --- a/spec/lib/pdf_filler/nj1040_pdf_spec.rb +++ b/spec/lib/pdf_filler/nj1040_pdf_spec.rb @@ -1109,7 +1109,7 @@ context "when taxpayer has taxable retirement income of 0" do it "does not fill in any of the boxes on line 20a" do - allow_any_instance_of(Efile::Nj::Nj1040Calculator).to receive(:calculate_line_20a).and_return 0 + allow_any_instance_of(Efile::Nj::Nj1040Calculator).to receive(:calculate_line_20a).and_return 0 # millions expect(pdf_fields["20a"]).to eq "" @@ -1225,120 +1225,6 @@ end end - describe "line 28a - Pension/Retirement Exclusion" do - context "when taxpayer has pension/retirement income exclusion with 0" do - it "does not fill in the PDF line 28a boxes" do - allow_any_instance_of(Efile::Nj::Nj1040Calculator).to receive(:calculate_line_28a).and_return 0 - - # thousands - expect(pdf_fields["28a"]).to eq "" - expect(pdf_fields["189"]).to eq "" - expect(pdf_fields["190"]).to eq "" - # hundreds - expect(pdf_fields["undefined_81"]).to eq "" - expect(pdf_fields["191"]).to eq "" - expect(pdf_fields["192"]).to eq "" - # decimals - expect(pdf_fields["undefined_82"]).to eq "" - expect(pdf_fields["193"]).to eq "" - end - end - - context "when taxpayer has pension/retirement income exclusion with 123_456" do - it "fills in the PDF line 28a boxes with the rounded value" do - allow_any_instance_of(Efile::Nj::Nj1040Calculator).to receive(:calculate_line_28a).and_return 123_456 - - # thousands - expect(pdf_fields["28a"]).to eq "1" - expect(pdf_fields["189"]).to eq "2" - expect(pdf_fields["190"]).to eq "3" - # hundreds - expect(pdf_fields["undefined_81"]).to eq "4" - expect(pdf_fields["191"]).to eq "5" - expect(pdf_fields["192"]).to eq "6" - # decimals - expect(pdf_fields["undefined_82"]).to eq "0" - expect(pdf_fields["193"]).to eq "0" - end - end - end - - describe "line 28b - Other Retirement Income Exclusion" do - context "when taxpayer has exclusion with 0" do - it "does not fill in the PDF line 28b boxes" do - allow_any_instance_of(Efile::Nj::Nj1040Calculator).to receive(:calculate_line_28b).and_return 0 - - # thousands - expect(pdf_fields["28b"]).to eq "" - expect(pdf_fields["194"]).to eq "" - expect(pdf_fields["195"]).to eq "" - # hundreds - expect(pdf_fields["undefined_83"]).to eq "" - expect(pdf_fields["196"]).to eq "" - expect(pdf_fields["197"]).to eq "" - # decimals - expect(pdf_fields["undefined_84"]).to eq "" - expect(pdf_fields["198"]).to eq "" - end - end - - context "when taxpayer has exclusion with 123_456" do - it "fills in the PDF line 28b boxes with the rounded value" do - allow_any_instance_of(Efile::Nj::Nj1040Calculator).to receive(:calculate_line_28b).and_return 123_456 - - # thousands - expect(pdf_fields["28b"]).to eq "1" - expect(pdf_fields["194"]).to eq "2" - expect(pdf_fields["195"]).to eq "3" - # hundreds - expect(pdf_fields["undefined_83"]).to eq "4" - expect(pdf_fields["196"]).to eq "5" - expect(pdf_fields["197"]).to eq "6" - # decimals - expect(pdf_fields["undefined_84"]).to eq "0" - expect(pdf_fields["198"]).to eq "0" - end - end - end - - describe "line 28c - Total Retirement Income Exclusion" do - context "when taxpayer has total retirement income exclusion with 0" do - it "does not fill in the PDF line 28c boxes" do - allow_any_instance_of(Efile::Nj::Nj1040Calculator).to receive(:calculate_line_28c).and_return 0 - - # thousands - expect(pdf_fields["28c"]).to eq "" - expect(pdf_fields["199"]).to eq "" - expect(pdf_fields["200"]).to eq "" - # hundreds - expect(pdf_fields["undefined_85"]).to eq "" - expect(pdf_fields["201"]).to eq "" - expect(pdf_fields["202"]).to eq "" - # decimals - expect(pdf_fields["undefined_86"]).to eq "" - expect(pdf_fields["203"]).to eq "" - end - end - - context "when taxpayer has total retirement income exclusion with 123_456" do - it "fills in the PDF line 28c boxes with the rounded value" do - allow_any_instance_of(Efile::Nj::Nj1040Calculator).to receive(:calculate_line_28c).and_return 123_456 - - # thousands - expect(pdf_fields["28c"]).to eq "1" - expect(pdf_fields["199"]).to eq "2" - expect(pdf_fields["200"]).to eq "3" - # hundreds - expect(pdf_fields["undefined_85"]).to eq "4" - expect(pdf_fields["201"]).to eq "5" - expect(pdf_fields["202"]).to eq "6" - # decimals - expect(pdf_fields["undefined_86"]).to eq "0" - expect(pdf_fields["203"]).to eq "0" - end - end - end - describe "line 29 - gross income" do context "when taxpayer provides gross income with the sum 200,000" do let(:submission) { 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 bb588663db..c87772d2e5 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 @@ -497,57 +497,6 @@ end end - describe "Other Retirement Income Exclusion - line 28a" do - context "when line 28a has a value" do - it 'sets PensionExclusion to the line 28a value' do - expected = 5_000 - allow_any_instance_of(Efile::Nj::Nj1040Calculator).to receive(:calculate_line_28a).and_return expected - expect(xml.at("PensionExclusion").text).to eq(expected.to_s) - end - end - - context "when line 28a is 0" do - it 'does not set the PensionExclusion value in the XML' do - allow_any_instance_of(Efile::Nj::Nj1040Calculator).to receive(:calculate_line_28a).and_return 0 - expect(xml.at("PensionExclusion")).to be_nil - end - end - end - - describe "Other Retirement Income Exclusion - line 28b" do - context "when line 28b has a value" do - it 'sets OtherRetireIncomeExclus to the line 28b value' do - expected = 1_000 - allow_any_instance_of(Efile::Nj::Nj1040Calculator).to receive(:calculate_line_28b).and_return expected - expect(xml.at("OtherRetireIncomeExclus").text).to eq(expected.to_s) - end - end - - context "wwhen line 28b is 0" do - it "does not include TotalIncome in the XML" do - allow_any_instance_of(Efile::Nj::Nj1040Calculator).to receive(:calculate_line_28b).and_return 0 - expect(xml.at("OtherRetireIncomeExclus")).to eq(nil) - end - end - end - - describe "Other Retirement Income Exclusion - line 28c" do - context "when line 28c has a value" do - it 'sets TotalExclusionAmount to the line 28c value' do - expected = 2_000 - allow_any_instance_of(Efile::Nj::Nj1040Calculator).to receive(:calculate_line_28c).and_return expected - expect(xml.at("TotalExclusionAmount").text).to eq(expected.to_s) - end - end - - context "when Line 28c is 0" do - it 'does not set the TotalExclusionAmount value in the XML' do - allow_any_instance_of(Efile::Nj::Nj1040Calculator).to receive(:calculate_line_28c).and_return 0 - expect(xml.at("TotalExclusionAmount")).to be_nil - end - end - end - describe "gross income - line 29" do context "when filer submits w2 wages" do it "fills TotalIncome with the value from Line 15" do