Skip to content

Commit

Permalink
FYST-555 Add MD W2 info to XML
Browse files Browse the repository at this point in the history
  • Loading branch information
tahsinaislam committed Oct 31, 2024
1 parent 29f5aa3 commit 5c54246
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 1 deletion.
19 changes: 19 additions & 0 deletions app/lib/submission_builder/return_w2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,25 @@ def document
else
state_local_tax_grp_node.remove
end

if intake_w2.box14_stpickup.present? && intake_w2.box14_stpickup.positive?
stpickup_node = Nokogiri::XML::Node.new('OtherDeductionsBenefitsGrp', xml_node)

desc_node = Nokogiri::XML::Node.new('Desc', xml_node)
desc_node.content = 'STPICKUP'
amt_node = Nokogiri::XML::Node.new('Amt', xml_node)
amt_node.content = intake_w2.box14_stpickup.round.to_s

stpickup_node.add_child(desc_node)
stpickup_node.add_child(amt_node)

existing_deductions = xml_node.at(:OtherDeductionsBenefitsGrp)
if existing_deductions
existing_deductions.add_next_sibling(stpickup_node)
else
state_local_tax_grp_node.add_previous_sibling(stpickup_node)
end
end
end
locality_nm = xml_node.at(:LocalityNm)
if locality_nm.present?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@
<EmployerEIN>001245768</EmployerEIN>
<EmployerNameControlTxt>BTB</EmployerNameControlTxt>
<EmployerName>
<BusinessNameLine1Txt>Brendan T. Byrne State Forest</BusinessNameLine1Txt>
<BusinessNameLine1Txt>Brendan T Byrne State Forest</BusinessNameLine1Txt>
</EmployerName>
<EmployerUSAddress>
<AddressLine1Txt>31 Batsto Road</AddressLine1Txt>
Expand Down
90 changes: 90 additions & 0 deletions spec/lib/submission_builder/state_return_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,96 @@
end
end

describe "Maryland W2 Box 14 STPICKUP handling" do
let(:builder_class) { SubmissionBuilder::Ty2024::States::Md::MdReturnXml }
let(:intake) { create(:state_file_md_intake, :df_data_2_w2s, filing_status: 'single') }
let(:submission) { create(:efile_submission, data_source: intake) }
let(:w2_node_name) { "IRSW2" }

context "when W2 has box14_stpickup" do
let!(:state_file_w2) do
create(
:state_file_w2,
state_file_intake: intake,
w2_index: 0,
box14_stpickup: 750.50,
)
end
before do
xml = Nokogiri::XML(intake.raw_direct_file_data)
intake.update(raw_direct_file_data: xml.to_xml)
end

it "includes STPICKUP in OtherDeductionsBenefitsGrp with rounded amount" do
xml = Nokogiri::XML::Document.parse(builder_class.build(submission).document.to_xml)
w2_node = xml.css(w2_node_name).first
expect(xml.css("OtherDeductionsBenefitsGrp Desc").map(&:text)).to include("STPICKUP")
expect(w2_node.css("OtherDeductionsBenefitsGrp Desc")[1]&.text).to eq "STPICKUP"
expect(w2_node.css("OtherDeductionsBenefitsGrp Amt")[1]&.text).to eq "751"
end

it "preserves existing OtherDeductionsBenefitsGrp entries" do
xml = Nokogiri::XML::Document.parse(builder_class.build(submission).document.to_xml)
w2_node = xml.css(w2_node_name).first

expect(w2_node.css("OtherDeductionsBenefitsGrp Desc")[0]&.text).to eq "414HSUB"
expect(w2_node.css("OtherDeductionsBenefitsGrp Amt")[0]&.text).to eq "250"
end
end

context "when W2 has zero box14_stpickup" do
let!(:state_file_w2) do
create(
:state_file_w2,
state_file_intake: intake,
w2_index: 0,
box14_stpickup: "0",
employer_state_id_num: "12345",
state_wages_amount: "50000"
)
end

it "does not include STPICKUP in XML" do
xml = Nokogiri::XML::Document.parse(builder_class.build(submission).document.to_xml)
expect(xml.css("OtherDeductionsBenefitsGrp Desc").map(&:text)).not_to include("STPICKUP")
end

it "preserves existing OtherDeductionsBenefitsGrp entries" do
xml = Nokogiri::XML::Document.parse(builder_class.build(submission).document.to_xml)
w2_node = xml.css(w2_node_name).first

expect(w2_node.css("OtherDeductionsBenefitsGrp Desc")[0]&.text).to eq "414HSUB"
expect(w2_node.css("OtherDeductionsBenefitsGrp Amt")[0]&.text).to eq "250"
end
end

context "when W2 has nil box14_stpickup" do
let!(:state_file_w2) do
create(
:state_file_w2,
state_file_intake: intake,
w2_index: 0,
box14_stpickup: nil,
employer_state_id_num: "12345",
state_wages_amount: "50000"
)
end

it "does not include STPICKUP in XML" do
xml = Nokogiri::XML::Document.parse(builder_class.build(submission).document.to_xml)
expect(xml.css("OtherDeductionsBenefitsGrp Desc").map(&:text)).not_to include("STPICKUP")
end

it "preserves existing OtherDeductionsBenefitsGrp entries" do
xml = Nokogiri::XML::Document.parse(builder_class.build(submission).document.to_xml)
w2_node = xml.css(w2_node_name).first

expect(w2_node.css("OtherDeductionsBenefitsGrp Desc")[0]&.text).to eq "414HSUB"
expect(w2_node.css("OtherDeductionsBenefitsGrp Amt")[0]&.text).to eq "250"
end
end
end

states_requiring_1099gs = StateFile::StateInformationService.active_state_codes.excluding("nj")
states_requiring_1099gs.each do |state_code|
describe "#form1099gs", required_schema: state_code do
Expand Down

0 comments on commit 5c54246

Please sign in to comment.