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

Fyst 663 implement form 502 su xml pdf part 1 #4942

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion app/lib/efile/line_data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,10 @@ MD502CR_PART_B_LINE_4:
label: "4 Multiply line 2 by line 3. Enter here and on Part AA, line 2"
MD502CR_PART_M_LINE_1:
label: "1 Enter the credit claimed here and on Part AA, line 13 (See Instructions)"
MD502_SU_LINE_AB:
label: "AB Income from U.S. Government obligations"
MD502_SU_LINE_1:
label: "1 Add lines a. through yc. and enter this amount on line 13 of Form 502 with the appropriate code letters"
NCD400_LINE_9:
label: '9 Deductions From Federal Adjusted Gross Income (From Form D-400 Schedule S, Part B, Line 41)'
NCD400_LINE_10B:
Expand Down Expand Up @@ -576,7 +580,7 @@ NJ1040_LINE_15:
label: '15 Wages, salaries, tips, and other employee compensation (State wages from Box 16 of enclosed W-2(s))'
NJ1040_LINE_16A:
label: 'Taxable interest income (Enclose federal Schedule B if over $1,500) (See instructions)'
NJ1040_LINE_16B:
NJ1040_LINE_16B:
label: 'Tax-exempt interest income (Enclose schedule) (See instructions) Do not include on line 16a'
NJ1040_LINE_27:
label: '27 Total Income (Add lines 15, 16a, and 20a)'
Expand Down Expand Up @@ -636,6 +640,8 @@ MD502_LINE_D_COUNT_TOTAL:
label: 'D Total Exemption Count: add lines A, B and C counts'
MD502_LINE_D_AMOUNT_TOTAL:
label: 'D Total Exemption Dollar Amount: add lines A, B and C amounts'
MD502_LINE_13:
label: '13 Subtractions from attached Form 502SU'
MD502B_LINE_1:
label: '1 Total number of Regular dependents'
MD502B_LINE_2:
Expand Down
13 changes: 13 additions & 0 deletions app/lib/efile/md/md502_calculator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ def initialize(year:, intake:, include_source: false)
lines: @lines,
intake: @intake
)

@md502_su = Efile::Md::Md502SuCalculator.new(
value_access_tracker: @value_access_tracker,
lines: @lines,
intake: @intake
)
end

def calculate
Expand All @@ -18,6 +24,8 @@ def calculate
set_line(:MD502_LINE_1B, @direct_file_data, :fed_wages_salaries_tips)
set_line(:MD502_LINE_1D, @direct_file_data, :fed_taxable_pensions)
set_line(:MD502_LINE_1E, :calculate_line_1e)
@md502_su.calculate
set_line(:MD502_LINE_13, :calculate_line_13)

# Exemptions
set_line(:MD502_LINE_A_PRIMARY, :calculate_line_a_primary)
Expand All @@ -40,6 +48,7 @@ def calculate
set_line( :MD502CR_PART_B_LINE_3, :calculate_md502_cr_part_b_line_3)
set_line(:MD502CR_PART_B_LINE_4, :calculate_md502_cr_part_b_line_4)
set_line(:MD502CR_PART_M_LINE_1, :calculate_md502_cr_part_m_line_1)

@lines.transform_values(&:value)
end

Expand Down Expand Up @@ -258,6 +267,10 @@ def calculate_line_d_amount_total

end

def calculate_line_13
@lines[:MD502_SU_LINE_1].value
end

def filing_status_dependent?
@filing_status == :dependent
end
Expand Down
29 changes: 29 additions & 0 deletions app/lib/efile/md/md502_su_calculator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module Efile
module Md
class Md502SuCalculator < ::Efile::TaxCalculator
attr_reader :lines, :value_access_tracker

def initialize(value_access_tracker:, lines:, intake:)
@value_access_tracker = value_access_tracker
@lines = lines
@intake = intake
Copy link
Contributor

Choose a reason for hiding this comment

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

[pebble] aside from the assignment on line 10, the intake isn't referenced so i don't believe we need to allocate an instance variable for it.

Copy link
Contributor Author

@anisharamnani anisharamnani Nov 4, 2024

Choose a reason for hiding this comment

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

ah, this is what happens when you're new and copy pasta what you've seen in other files, you're completely right. there's no need to allocate an instance variable.

@direct_file_json_data = intake.direct_file_json_data
end

def calculate
set_line(:MD502_SU_LINE_1, :calculate_line_1)
set_line(:MD502_SU_LINE_AB, :calculate_line_ab)
end

private

def calculate_line_1
calculate_line_ab
end

def calculate_line_ab
@direct_file_json_data.interest_reports.sum(&:interest_on_government_bonds).round
end
end
end
end
1 change: 1 addition & 0 deletions app/lib/pdf_filler/md502_pdf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def hash_for_pdf
'D. Enter Dollar Amount Total Exemptions (Add A, B and C.) ': @xml_document.at('Exemptions Total Amount')&.text,
'Enter 9': @xml_document.at('Form502 Subtractions ChildAndDependentCareExpenses')&.text,
'Enter 11': @xml_document.at('Form502 Subtractions SocialSecurityRailRoadBenefits')&.text,
'Enter 13': @xml_document.at('Form502 Subtractions Other')&.text,
'Text Box 96': @xml_document.at('ReturnHeaderState Filer Primary USPhone')&.text,
}
end
Expand Down
36 changes: 36 additions & 0 deletions app/lib/pdf_filler/md502_su_pdf.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module PdfFiller
class Md502SuPdf
include PdfHelper

def source_pdf_name
"md502SU-TY2023"
end

def initialize(submission)
@submission = submission
builder = StateFile::StateInformationService.submission_builder_class(:md)
@xml_document = builder.new(submission).document
Copy link
Contributor

Choose a reason for hiding this comment

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

[pebble] similar to previous comment -- doesn't look like this instance variable is referenced anywhere in this class. could it be removed?

end

def hash_for_pdf
{
'Your First Name' => @submission.data_source.primary.first_name,
'Text1' => @submission.data_source.primary.middle_initial,
'Your Last Name' => @submission.data_source.primary.last_name,
'Your Social Security Number' => @submission.data_source.primary.ssn,
'Spouses First Name' => @submission.data_source.spouse.first_name,
'Text2' => @submission.data_source.spouse.middle_initial,
'Spouses Last Name' => @submission.data_source.spouse.last_name,
'Spouses Social Security Number' => @submission.data_source.spouse.ssn,
'ab Income from US Government obligations See Instruction 13 ab' => calculated_fields.fetch(:MD502_SU_LINE_AB),
'appropriate code letters TOTAL 1' => calculated_fields.fetch(:MD502_SU_LINE_1),
}
end

private

def calculated_fields
@calculated_fields ||= @submission.data_source.tax_calculator.calculate
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def document
xml.Subtractions do
xml.ChildAndDependentCareExpenses @direct_file_data.total_qualifying_dependent_care_expenses
xml.SocialSecurityRailRoadBenefits @direct_file_data.fed_taxable_ssb
xml.Other calculated_fields.fetch(:MD502_LINE_13)
end
xml.DaytimePhoneNumber @direct_file_data.phone_number if @direct_file_data.phone_number.present?
end
Expand Down Expand Up @@ -150,4 +151,4 @@ def add_element_if_present(xml, tag, line_id)
value = calculated_fields.fetch(line_id)
xml.send(tag, value) if value.present?
end
end
end
33 changes: 33 additions & 0 deletions app/lib/submission_builder/ty2024/states/md/documents/md502_su.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string_literal: true

module SubmissionBuilder
module Ty2024
module States
module Md
module Documents
class Md502Su < SubmissionBuilder::Document
include SubmissionBuilder::FormattingMethods

def document
build_xml_doc("Form502SU", documentId: "Form502SU") do |xml|
xml.Subtractions do |subtractions|
subtractions.Total calculated_fields.fetch(:MD502_SU_LINE_1)
Copy link
Contributor

Choose a reason for hiding this comment

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

[pebble] is there supposed to be an = here or is Total a method name receiving a parameter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is intentional! the build_xml_doc method generates the xml for the state return. therefore the value for Total will be assigned from this method.

end
end
end

private

def intake
@submission.data_source
end

def calculated_fields
@md502_su_fields ||= intake.tax_calculator.calculate
end
end
end
end
end
end
end
5 changes: 5 additions & 0 deletions app/lib/submission_builder/ty2024/states/md/md_return_xml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ def supported_documents
xml: SubmissionBuilder::Ty2024::States::Md::Documents::Md502Cr,
pdf: PdfFiller::Md502CrPdf,
include: true,
},
{
xml: SubmissionBuilder::Ty2024::States::Md::Documents::Md502Su,
pdf: PdfFiller::Md502SuPdf,
include: true,
}
]

Expand Down
11 changes: 11 additions & 0 deletions spec/lib/efile/md/md502_calculator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -681,4 +681,15 @@
expect(instance.lines[:MD502_LINE_D_AMOUNT_TOTAL].value).to eq 3200
end
end

describe "#calculate_line_13" do
before do
allow_any_instance_of(Efile::Md::Md502SuCalculator).to receive(:calculate_line_1).and_return 100
end

it 'the sums the amount from line A-C' do
instance.calculate
expect(instance.lines[:MD502_LINE_13].value).to eq 100
end
end
end
39 changes: 39 additions & 0 deletions spec/lib/efile/md/md502_su_calculator_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
require 'rails_helper'

describe Efile::Md::Md502SuCalculator do
let(:intake) { create(:state_file_md_intake) }
let(:main_calculator) do
Efile::Md::Md502Calculator.new(
year: MultiTenantService.statefile.current_tax_year,
intake: intake
)
end
let(:instance) { main_calculator.instance_variable_get(:@md502_su) }

describe 'line ab' do
before do
instance.calculate
end

context 'without interest reports' do
it 'does not set line ab' do
expect(instance.lines[:MD502_SU_LINE_AB].value).to eq(0)
end
end

context 'with interest report' do
let(:intake) { create(:state_file_md_intake, :df_data_1099_int) }
it 'sets line ab' do
expect(instance.lines[:MD502_SU_LINE_AB].value).to eq(2)
end
end
end

describe 'line 1' do
it 'totals lines a through yc' do
allow(instance).to receive(:calculate_line_ab).and_return 100
instance.calculate
expect(instance.lines[:MD502_SU_LINE_1].value).to eq(100)
end
end
end
2 changes: 2 additions & 0 deletions spec/lib/pdf_filler/md502_pdf_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,15 @@

context "subtractions" do
before do
allow_any_instance_of(Efile::Md::Md502SuCalculator).to receive(:calculate_line_1).and_return 100
intake.direct_file_data.total_qualifying_dependent_care_expenses = 1200
intake.direct_file_data.fed_taxable_ssb = 240
end

it "fills out subtractions fields correctly" do
expect(pdf_fields["Enter 9"].to_i).to eq intake.direct_file_data.total_qualifying_dependent_care_expenses
expect(pdf_fields["Enter 11"].to_i).to eq intake.direct_file_data.fed_taxable_ssb
expect(pdf_fields["Enter 13"].to_i).to eq 100
end
end
end
Expand Down
68 changes: 68 additions & 0 deletions spec/lib/pdf_filler/md502_su_pdf_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
require "rails_helper"

RSpec.describe PdfFiller::Md502SuPdf do
include PdfSpecHelper
let(:intake) { create :state_file_md_intake }
let(:submission) { create :efile_submission, tax_return: nil, data_source: intake }
let(:pdf) { described_class.new(submission) }

describe "#hash_for_pdf" do
let(:file_path) { described_class.new(submission).output_file.path }
let(:pdf_fields) { filled_in_values(file_path) }

it 'uses field names that exist in the pdf' do
missing_fields = pdf.hash_for_pdf.keys.map { |k| k.to_s.gsub("'", "&apos;").to_s } - pdf_fields.keys
expect(missing_fields).to eq([])
end

context 'without interest reports' do
let(:primary_ssn) { "345678901" }
let(:spouse_ssn) { "987654321" }
let(:intake) do
create(
:state_file_md_intake,
primary_first_name: "Janet",
primary_middle_initial: "G",
primary_last_name: "Jormp",
spouse_first_name: "Jane",
spouse_middle_initial: "M",
spouse_last_name: "Jomp",
)
end

before do
intake.direct_file_data.primary_ssn = primary_ssn
intake.direct_file_data.spouse_ssn = spouse_ssn
end

it "sets fields to the correct values" do
expect(pdf_fields["Your First Name"]).to eq "Janet"
expect(pdf_fields["Text1"]).to eq "G"
expect(pdf_fields["Your Last Name"]).to eq "Jormp"
expect(pdf_fields["Your Social Security Number"]).to eq primary_ssn
expect(pdf_fields["Spouses First Name"]).to eq "Jane"
expect(pdf_fields["Text2"]).to eq "M"
expect(pdf_fields["Spouses Last Name"]).to eq "Jomp"
expect(pdf_fields["Spouses Social Security Number"]).to eq spouse_ssn
expect(pdf_fields["ab Income from US Government obligations See Instruction 13 ab"]).to eq("0")
expect(pdf_fields["appropriate code letters TOTAL 1"]).to eq("0")
end
end

context 'with interest report' do
let(:intake) { create(:state_file_md_intake, :df_data_1099_int) }
it "sets fields to the correct values" do
expect(pdf_fields["Your First Name"]).to eq "Mary"
expect(pdf_fields["Text1"]).to eq "A"
expect(pdf_fields["Your Last Name"]).to eq "Lando"
expect(pdf_fields["Your Social Security Number"]).to eq "123456789"
expect(pdf_fields["Spouses First Name"]).to eq ""
expect(pdf_fields["Text2"]).to eq ""
expect(pdf_fields["Spouses Last Name"]).to eq ""
expect(pdf_fields["Spouses Social Security Number"]).to eq ""
expect(pdf_fields["ab Income from US Government obligations See Instruction 13 ab"]).to eq("2")
expect(pdf_fields["appropriate code letters TOTAL 1"]).to eq("2")
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@
context "subtractions section" do
context "when all relevant values are present in the DF XML" do
before do
allow_any_instance_of(Efile::Md::Md502SuCalculator).to receive(:calculate_line_1).and_return 100
intake.direct_file_data.total_qualifying_dependent_care_expenses = 1200
intake.direct_file_data.fed_taxable_ssb = 240
end
Expand All @@ -255,8 +256,12 @@
it "outputs Taxable Social Security and RR benefits" do
expect(xml.at("Form502 Subtractions SocialSecurityRailRoadBenefits").text.to_i).to eq(intake.direct_file_data.fed_taxable_ssb)
end

it "outputs the Subtractions from Form 502SU" do
expect(xml.at("Form502 Subtractions Other").text.to_i).to eq(100)
end
end
end
end
end
end
end
Loading
Loading