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

Xml override #187136591 #4307

Merged
merged 3 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 0 additions & 16 deletions app/helpers/df_xml_crud_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,4 @@ def setter_symbol_to_selector(method_name)
def to_pretty_s
Nokogiri::XML(node.to_s, &:noblanks).to_xhtml(indent: 2)
end

def delete_blank_nodes(node)
return unless [1, 9].include?(node.node_type) # <nodesWithChildren></nodesWithChildren>
node.children.to_a.each do |child|
delete_blank_nodes(child)
end
content = node.inner_html.strip
if content == "" || content == "0"
node.remove
return
end
node.inner_html = content
if node.children.empty?
node.remove
end
end
end
17 changes: 17 additions & 0 deletions app/helpers/xml_methods.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module XmlMethods
def delete_blank_nodes(node)
return unless [1, 9].include?(node.node_type) # <nodesWithChildren></nodesWithChildren>
node.children.to_a.each do |child|
delete_blank_nodes(child)
end
content = node.inner_html.strip
if content == "" || content == "0"
node.remove
return
end
node.inner_html = content
if node.children.empty?
node.remove
end
end
end
4 changes: 4 additions & 0 deletions app/lib/efile/ny/it201.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ def initialize(year:, intake:, include_source: false)
@intake = intake
@filing_status = intake.filing_status.to_sym # single, married_filing_jointly, that's all we support for now
@direct_file_data = intake.direct_file_data
intake.state_file_w2s.each do |w2|
dest_w2 = @direct_file_data.w2s[w2.w2_index]
dest_w2.node.at("W2StateLocalTaxGrp").inner_html = w2.state_tax_group_xml_node
end
@eligibility_lived_in_state = intake.eligibility_lived_in_state
@dependent_count = intake.dependents.length

Expand Down
5 changes: 4 additions & 1 deletion app/models/state_file_w2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# index_state_file_w2s_on_state_file_intake (state_file_intake_type,state_file_intake_id)
#
class StateFileW2 < ApplicationRecord
include XmlMethods
STATE_TAX_GRP_TEMPLATE = <<~XML
<W2StateTaxGrp>
<StateAbbreviationCd></StateAbbreviationCd>
Expand Down Expand Up @@ -87,6 +88,8 @@ def state_tax_group_xml_node
xml_template.at(:LocalIncomeTaxAmt).content = local_income_tax_amt
xml_template.at(:LocalityNm).content = locality_nm

xml_template.at(:W2StateTaxGrp).to_xml
result = xml_template.at(:W2StateTaxGrp)
delete_blank_nodes(result)
result.to_xml
end
end
2 changes: 1 addition & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2340,7 +2340,7 @@ en:
ny_w2:
edit:
box15_html: |
<strong>Box 15</strong>: State and Employer’s State ID number<br />
<strong>Box 15</strong>: Employer’s State ID number<br />
If Box 15 is blank on your W-2, enter the number from <strong>Box b Employer Identification number (EIN)</strong> here instead.
box16_html: "<strong>Box 16</strong>: State wages, tips, etc."
box17_html: "<strong>Box 17</strong>: State income tax"
Expand Down
2 changes: 1 addition & 1 deletion config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2338,7 +2338,7 @@ es:
ny_w2:
edit:
box15_html: |
<strong>Casilla 15</strong>: Estado y número de identificación estatal del empleador<br />
<strong>Casilla 15</strong>: Número de identificación estatal del empleador<br />
Si la casilla 15 está en blanco en su W-2, ingrese aquí el número del <strong>casilla b Número de identificación del empleador (EIN)</strong>.
box16_html: "<strong>Recuadro 16</strong>: Salarios estatales, propinas, etc."
box17_html: "<strong>Cuadro 17</strong>: Impuesto estatal sobre la renta"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

describe DfXmlCrudMethods do
describe XmlMethods do
describe "#delete_blank_nodes" do
it "deletes nodes" do
content = <<~XML
Expand All @@ -12,7 +12,7 @@
</outer>
XML
xml = Nokogiri::XML(content)
Class.new.extend(DfXmlCrudMethods).delete_blank_nodes(xml)
Class.new.extend(XmlMethods).delete_blank_nodes(xml)
result = "<?xml version=\"1.0\"?>\n<outer>\n <inner3>1</inner3>\n</outer>\n"
expect(xml.to_xml).to eq result
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
end

context "when the intake has state_file_w2s" do
xcontext "create, update, delete nodes" do
context "create, update, delete nodes" do
let(:raw_direct_file_data) { File.read(Rails.root.join("spec/fixtures/files/fed_return_batman_ny.xml")) }
let(:direct_file_xml) do
xml = Nokogiri::XML(raw_direct_file_data)
Expand Down
Loading