From 9b194b961fabad10561df7a53e226eeb7ea1b1e0 Mon Sep 17 00:00:00 2001 From: Anne LoVerso Date: Tue, 4 Feb 2025 15:02:04 -0500 Subject: [PATCH 1/4] NJ 269 - populate fill if paying by check/card in PDF --- app/lib/efile/nj/nj1040_calculator.rb | 5 +++++ app/lib/pdf_filler/nj1040_pdf.rb | 3 +++ spec/lib/efile/nj/nj1040_calculator_spec.rb | 18 ++++++++++++++++++ spec/lib/pdf_filler/nj1040_pdf_spec.rb | 12 ++++++++++++ 4 files changed, 38 insertions(+) diff --git a/app/lib/efile/nj/nj1040_calculator.rb b/app/lib/efile/nj/nj1040_calculator.rb index 3232245015..5ea82e8698 100644 --- a/app/lib/efile/nj/nj1040_calculator.rb +++ b/app/lib/efile/nj/nj1040_calculator.rb @@ -78,6 +78,7 @@ def calculate set_line(:NJ1040_LINE_77, :calculate_line_77) set_line(:NJ1040_LINE_78, :calculate_line_78) set_line(:NJ1040_LINE_79, :calculate_line_79) + set_line(:NJ1040_LINE_79_CHECKBOX, :calculate_line_79_checkbox) set_line(:NJ1040_LINE_80, :calculate_line_80) @nj2450_primary.calculate if line_59_primary || line_61_primary @nj2450_spouse.calculate if line_59_spouse || line_61_spouse @@ -601,6 +602,10 @@ def calculate_line_79 0 end + def calculate_line_79_checkbox + @intake.payment_or_deposit_type_direct_deposit? + end + def calculate_line_80 if line_or_zero(:NJ1040_LINE_68).positive? # Line 78 is always 0 now diff --git a/app/lib/pdf_filler/nj1040_pdf.rb b/app/lib/pdf_filler/nj1040_pdf.rb index 0185844b58..f84c9e0e34 100644 --- a/app/lib/pdf_filler/nj1040_pdf.rb +++ b/app/lib/pdf_filler/nj1040_pdf.rb @@ -89,6 +89,9 @@ def hash_for_pdf # line 65 nj child tax credit '64': @xml_document.at("Body NJChildTCNumOfDep")&.text, + # line 79 payment checkbox + Line77bdue: calculated_fields_not_in_xml.fetch(:NJ1040_LINE_79_CHECKBOX) ? "On" : "Off", + # Gubernatorial elections fund Group245: @xml_document.at("Body PrimGubernElectFund").present? ? 'Choice1' : 'Choice2', Group246: if get_mfj_spouse_ssn diff --git a/spec/lib/efile/nj/nj1040_calculator_spec.rb b/spec/lib/efile/nj/nj1040_calculator_spec.rb index f808241a67..f88447266a 100644 --- a/spec/lib/efile/nj/nj1040_calculator_spec.rb +++ b/spec/lib/efile/nj/nj1040_calculator_spec.rb @@ -2147,6 +2147,24 @@ def over_65_birth_year end end + describe 'line 79 checkbox' do + context 'when user selected pay by mail' do + let(:intake) { create(:state_file_nj_intake, payment_or_deposit_type: :mail) } + + it 'returns false' do + expect(instance.lines[:NJ1040_LINE_79_CHECKBOX].value).to eq(false) + end + end + + context 'when user selected pay by direct debit' do + let(:intake) { create(:state_file_nj_intake, payment_or_deposit_type: :direct_deposit) } + + it 'returns true' do + expect(instance.lines[:NJ1040_LINE_79_CHECKBOX].value).to eq(true) + end + end + end + describe 'line 80 Refund amount' do it 'returns 0 when line 68 is not above 0' do allow(instance).to receive(:calculate_line_68).and_return 0 diff --git a/spec/lib/pdf_filler/nj1040_pdf_spec.rb b/spec/lib/pdf_filler/nj1040_pdf_spec.rb index a2921bd30b..4b685b4555 100644 --- a/spec/lib/pdf_filler/nj1040_pdf_spec.rb +++ b/spec/lib/pdf_filler/nj1040_pdf_spec.rb @@ -2201,6 +2201,18 @@ end end + describe 'line 79 - paying by e-check / credit card checkbox' do + it 'checks box when calculated is true' do + allow_any_instance_of(Efile::Nj::Nj1040Calculator).to receive(:calculate_line_79_checkbox).and_return true + expect(pdf_fields["Line77bdue"]).to eq "On" + end + + it 'does not check box when calculated is false' do + allow_any_instance_of(Efile::Nj::Nj1040Calculator).to receive(:calculate_line_79_checkbox).and_return false + expect(pdf_fields["Line77bdue"]).to eq "Off" + end + end + describe 'line 80 - Refund amount' do it 'inserts xml output' do allow_any_instance_of(Efile::Nj::Nj1040Calculator).to receive(:calculate_line_80).and_return 12_345_678 From 5b836e9f342f691350891d9605c6500aa323ef99 Mon Sep 17 00:00:00 2001 From: Anne LoVerso Date: Tue, 4 Feb 2025 15:33:58 -0500 Subject: [PATCH 2/4] only check box if owes balance --- app/lib/efile/nj/nj1040_calculator.rb | 2 +- spec/lib/efile/nj/nj1040_calculator_spec.rb | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/app/lib/efile/nj/nj1040_calculator.rb b/app/lib/efile/nj/nj1040_calculator.rb index 5ea82e8698..490e99f536 100644 --- a/app/lib/efile/nj/nj1040_calculator.rb +++ b/app/lib/efile/nj/nj1040_calculator.rb @@ -603,7 +603,7 @@ def calculate_line_79 end def calculate_line_79_checkbox - @intake.payment_or_deposit_type_direct_deposit? + @intake.payment_or_deposit_type_direct_deposit? && line_or_zero(:NJ1040_LINE_79).positive? end def calculate_line_80 diff --git a/spec/lib/efile/nj/nj1040_calculator_spec.rb b/spec/lib/efile/nj/nj1040_calculator_spec.rb index f88447266a..361093cb8d 100644 --- a/spec/lib/efile/nj/nj1040_calculator_spec.rb +++ b/spec/lib/efile/nj/nj1040_calculator_spec.rb @@ -2148,21 +2148,37 @@ def over_65_birth_year end describe 'line 79 checkbox' do - context 'when user selected pay by mail' do + def stub_balance_owed(balance) + allow(instance).to receive(:calculate_line_67).and_return balance + instance.calculate + end + + context 'when user selected pay by mail & owes a balance' do let(:intake) { create(:state_file_nj_intake, payment_or_deposit_type: :mail) } it 'returns false' do + stub_balance_owed(100) expect(instance.lines[:NJ1040_LINE_79_CHECKBOX].value).to eq(false) end end - context 'when user selected pay by direct debit' do + context 'when user selected pay by direct debit & owes a balance' do let(:intake) { create(:state_file_nj_intake, payment_or_deposit_type: :direct_deposit) } it 'returns true' do + stub_balance_owed(100) expect(instance.lines[:NJ1040_LINE_79_CHECKBOX].value).to eq(true) end end + + context 'when user selected pay by direct debit but is not owing a balance' do + let(:intake) { create(:state_file_nj_intake, payment_or_deposit_type: :direct_deposit) } + + it 'returns false' do + stub_balance_owed(0) + expect(instance.lines[:NJ1040_LINE_79_CHECKBOX].value).to eq(false) + end + end end describe 'line 80 Refund amount' do From e005ef9f42c8293dd07adc750bcc8f4a2fdf64aa Mon Sep 17 00:00:00 2001 From: Anne LoVerso Date: Tue, 4 Feb 2025 15:56:03 -0500 Subject: [PATCH 3/4] line data --- app/lib/efile/line_data.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/lib/efile/line_data.yml b/app/lib/efile/line_data.yml index 4cac2eb5d4..6adab629b2 100644 --- a/app/lib/efile/line_data.yml +++ b/app/lib/efile/line_data.yml @@ -956,6 +956,8 @@ NJ1040_LINE_78: label: '78 Total Adjustments to Tax Due/Overpayment amount (Add lines 69 through 77)' NJ1040_LINE_79: label: '79 Balance due (If line 67 is more than zero, add line 67 and line 78)' +NJ1040_LINE_79_CHECKBOX: + label: 'Fill in if paying by e-check or credit card' NJ1040_LINE_80: label: '80 Refund amount (If line 68 is more than zero, subtract line 78 from line 68)' NJ2450_COLUMN_A_TOTAL_PRIMARY: From 2fc62af60dacedb2e6e0a69459044d9ad88cf5e9 Mon Sep 17 00:00:00 2001 From: Anne LoVerso Date: Wed, 5 Feb 2025 10:51:50 -0500 Subject: [PATCH 4/4] test variables lazy declare --- spec/lib/efile/nj/nj1040_calculator_spec.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/spec/lib/efile/nj/nj1040_calculator_spec.rb b/spec/lib/efile/nj/nj1040_calculator_spec.rb index 361093cb8d..a70e1fb17c 100644 --- a/spec/lib/efile/nj/nj1040_calculator_spec.rb +++ b/spec/lib/efile/nj/nj1040_calculator_spec.rb @@ -2148,13 +2148,15 @@ def over_65_birth_year end describe 'line 79 checkbox' do + let(:intake) { create(:state_file_nj_intake, payment_or_deposit_type: payment_or_deposit_type) } + def stub_balance_owed(balance) allow(instance).to receive(:calculate_line_67).and_return balance instance.calculate end context 'when user selected pay by mail & owes a balance' do - let(:intake) { create(:state_file_nj_intake, payment_or_deposit_type: :mail) } + let(:payment_or_deposit_type) { :mail } it 'returns false' do stub_balance_owed(100) @@ -2163,7 +2165,7 @@ def stub_balance_owed(balance) end context 'when user selected pay by direct debit & owes a balance' do - let(:intake) { create(:state_file_nj_intake, payment_or_deposit_type: :direct_deposit) } + let(:payment_or_deposit_type) { :direct_deposit } it 'returns true' do stub_balance_owed(100) @@ -2172,7 +2174,7 @@ def stub_balance_owed(balance) end context 'when user selected pay by direct debit but is not owing a balance' do - let(:intake) { create(:state_file_nj_intake, payment_or_deposit_type: :direct_deposit) } + let(:payment_or_deposit_type) { :direct_deposit } it 'returns false' do stub_balance_owed(0)