From 4fa88f3c4bf834225a5443a96857315f6a393546 Mon Sep 17 00:00:00 2001 From: jenny-heath <43800769+jenny-heath@users.noreply.github.com> Date: Thu, 22 Aug 2024 14:54:11 -0700 Subject: [PATCH] Fyst 328 add tests for SubmissionBuilder::ReturnHeader (#4714) --- .../state_file/questions/df_return_sample.xml | 1 + app/models/direct_file_data.rb | 4 + .../fed_return_xmls/2023/nc/nick.xml | 1 + .../ty2022/states/ny/ny_return_xml_spec.rb | 2 + .../ty2022/states/return_header_spec.rb | 125 +++++++++++++----- .../ty2024/states/nc/nc_return_xml_spec.rb | 4 +- 6 files changed, 102 insertions(+), 35 deletions(-) diff --git a/app/controllers/state_file/questions/df_return_sample.xml b/app/controllers/state_file/questions/df_return_sample.xml index d7f21c88fa..30cb31887f 100644 --- a/app/controllers/state_file/questions/df_return_sample.xml +++ b/app/controllers/state_file/questions/df_return_sample.xml @@ -27,6 +27,7 @@ TEST 123 Sesame St + A New York NY 10128 diff --git a/app/models/direct_file_data.rb b/app/models/direct_file_data.rb index 7ba29f37f7..32b319d03c 100644 --- a/app/models/direct_file_data.rb +++ b/app/models/direct_file_data.rb @@ -201,6 +201,10 @@ def mailing_apartment df_xml_value(__method__) end + def mailing_apartment=(value) + write_df_xml_value(__method__, value) + end + def mailing_state df_xml_value(__method__) end diff --git a/spec/fixtures/state_file/fed_return_xmls/2023/nc/nick.xml b/spec/fixtures/state_file/fed_return_xmls/2023/nc/nick.xml index 249b10b66b..7bf5266322 100644 --- a/spec/fixtures/state_file/fed_return_xmls/2023/nc/nick.xml +++ b/spec/fixtures/state_file/fed_return_xmls/2023/nc/nick.xml @@ -14,6 +14,7 @@ CAVE 123 Red Right Hand St Apt 1 + Apt 1 Raleigh NC 27513 diff --git a/spec/lib/submission_builder/ty2022/states/ny/ny_return_xml_spec.rb b/spec/lib/submission_builder/ty2022/states/ny/ny_return_xml_spec.rb index bfd243003d..e68fb2db67 100644 --- a/spec/lib/submission_builder/ty2022/states/ny/ny_return_xml_spec.rb +++ b/spec/lib/submission_builder/ty2022/states/ny/ny_return_xml_spec.rb @@ -299,6 +299,7 @@ let(:filing_status) { 'single' } before do intake.direct_file_data.mailing_street = '211212 SUBDIVISION DR POBOX #157' + intake.direct_file_data.mailing_apartment = '' end it 'truncates under 30 characters' do xml = described_class.build(submission).document @@ -313,6 +314,7 @@ let(:filing_status) { 'single' } before do intake.direct_file_data.mailing_street = '211212 SUBDIVISION DR Suite 157' + intake.direct_file_data.mailing_apartment = '' end it 'truncates before the key word' do xml = described_class.build(submission).document diff --git a/spec/lib/submission_builder/ty2022/states/return_header_spec.rb b/spec/lib/submission_builder/ty2022/states/return_header_spec.rb index abe112d0be..4942fa2bc4 100644 --- a/spec/lib/submission_builder/ty2022/states/return_header_spec.rb +++ b/spec/lib/submission_builder/ty2022/states/return_header_spec.rb @@ -1,55 +1,114 @@ require 'rails_helper' describe SubmissionBuilder::ReturnHeader do - describe '.document' do - context "filer DOBs" do + StateFile::StateInformationService.active_state_codes.each do |state_code| + describe '.document' do + let(:intake) { create "state_file_#{state_code}_intake".to_sym } let(:submission) { create(:efile_submission, data_source: intake) } + let(:doc) { SubmissionBuilder::ReturnHeader.new(submission).document } - context "single filer" do - let(:primary_birth_date) { 40.years.ago } - let(:intake) { - create( - :state_file_ny_intake, - primary_birth_date: primary_birth_date - ) - } + context "misc basic attributes" do + let(:mailing_street) { "1234 Main Street" } + let(:mailing_apartment) { "B" } + let(:mailing_city) { "Citayy" } + let(:mailing_zip) { "54321" } + let(:tax_return_year) { 2024 } + let(:efin) { "123455" } + let(:sin) { "223455" } + before do + intake.direct_file_data.mailing_street = mailing_street + intake.direct_file_data.mailing_apartment = mailing_apartment + intake.direct_file_data.mailing_city = mailing_city + intake.direct_file_data.mailing_zip = mailing_zip + intake.direct_file_data.tax_return_year = tax_return_year + allow(EnvironmentCredentials).to receive(:irs).with(:efin).and_return efin + allow(EnvironmentCredentials).to receive(:irs).with(:sin).and_return sin + end - it "generates xml with primary filer DOB only" do - doc = SubmissionBuilder::ReturnHeader.new(submission).document - expect(doc.at("Filer Primary DateOfBirth").text).to eq primary_birth_date.strftime("%F") - expect(doc.at("Filer Secondary DateOfBirth")).not_to be_present + it "generates xml with the right values" do + expect(doc.at("Jurisdiction").text).to eq "#{state_code.upcase}ST" + expect(doc.at("ReturnTs").text).to eq submission.created_at.strftime("%FT%T%:z") + expect(doc.at("TaxPeriodBeginDt").text).to eq Date.new(tax_return_year, 1, 1).strftime("%F") + expect(doc.at("TaxPeriodEndDt").text).to eq Date.new(tax_return_year, 12, 31).strftime("%F") + expect(doc.at("TaxYr").text).to eq tax_return_year.to_s + expect(doc.at("OriginatorGrp EFIN").text).to eq efin + expect(doc.at("OriginatorGrp OriginatorTypeCd").text).to eq "OnlineFiler" + expect(doc.at("SoftwareId").text).to eq sin + expect(doc.at("ReturnType").text).to eq StateFile::StateInformationService.return_type(state_code) + expect(doc.at("USAddress AddressLine1Txt").text).to eq mailing_street + expect(doc.at("USAddress AddressLine2Txt").text).to eq mailing_apartment + expect(doc.at("USAddress CityNm").text).to eq mailing_city + expect(doc.at("USAddress StateAbbreviationCd").text).to eq state_code.upcase + expect(doc.at("USAddress ZIPCd").text).to eq mailing_zip end end - context "filer with spouse" do - let(:primary_birth_date) { 40.years.ago } - let(:spouse_birth_date) { 42.years.ago } + context "filer personal info" do let(:intake) { create( - :state_file_ny_intake, + "state_file_#{state_code}_intake".to_sym, + filing_status: filing_status, primary_birth_date: primary_birth_date, - filing_status: "married_filing_jointly", - spouse_first_name: "Spouse", + primary_first_name: primary_first_name, + primary_middle_initial: primary_middle_initial, + primary_last_name: primary_last_name, + spouse_first_name: spouse_first_name, spouse_birth_date: spouse_birth_date, - raw_direct_file_data: StateFile::XmlReturnSampleService.new.read("ny_robert_mfj") + spouse_middle_initial: spouse_middle_initial, + spouse_last_name: spouse_last_name, ) } + let(:primary_birth_date) { 40.years.ago } + let(:primary_ssn) { "100000030" } + let(:primary_first_name) { "Prim" } + let(:primary_middle_initial) { "W" } + let(:primary_last_name) { "Filerton" } + let(:spouse_birth_date) { nil } + let(:spouse_ssn) { nil } + let(:spouse_first_name) { nil } + let(:spouse_middle_initial) { nil } + let(:spouse_last_name) { nil } + before do + intake.direct_file_data.primary_ssn = primary_ssn + intake.direct_file_data.spouse_ssn = spouse_ssn + end + + context "single filer" do + let(:filing_status) { "single" } - it "generates xml with primary and spouse DOBs" do - doc = SubmissionBuilder::ReturnHeader.new(submission).document - expect(doc.at("Filer Primary DateOfBirth").text).to eq primary_birth_date.strftime("%F") - expect(doc.at("Filer Secondary DateOfBirth").text).to eq spouse_birth_date.strftime("%F") + it "generates xml with primary filer DOB only" do + expect(doc.at("Filer Primary DateOfBirth").text).to eq primary_birth_date.strftime("%F") + expect(doc.at('Filer Primary TaxpayerSSN').content).to eq primary_ssn + expect(doc.at('Filer Primary TaxpayerName FirstName').content).to eq primary_first_name + expect(doc.at('Filer Primary TaxpayerName MiddleInitial').content).to eq primary_middle_initial + expect(doc.at('Filer Primary TaxpayerName LastName').content).to eq primary_last_name + + expect(doc.at("Filer Secondary DateOfBirth")).not_to be_present + expect(doc.at('Filer Secondary TaxpayerSSN')).not_to be_present + expect(doc.at('Filer Secondary TaxpayerName FirstName')).not_to be_present + expect(doc.at('Filer Secondary TaxpayerName MiddleInitial')).not_to be_present + expect(doc.at('Filer Secondary TaxpayerName LastName')).not_to be_present + end end - end - end - context "misc other attributes" do - let(:intake) { create :state_file_az_intake } - let(:submission) { create(:efile_submission, data_source: intake) } + context "filer with spouse" do + let(:filing_status) { "married_filing_jointly" } + let(:spouse_birth_date) { 42.years.ago } + let(:spouse_ssn) { "200000030" } + let(:spouse_first_name) { "Sec" } + let(:spouse_middle_initial) { "Z" } + let(:spouse_last_name) { "Filerton" } - it "generates xml with the right values" do - doc = SubmissionBuilder::ReturnHeader.new(submission).document - expect(doc.at("ReturnType").text).to eq "Form140" + it "generates xml with primary and spouse DOBs" do + expect(doc.at("Filer Primary DateOfBirth").text).to eq primary_birth_date.strftime("%F") + + expect(doc.at("Filer Secondary DateOfBirth").text).to eq spouse_birth_date.strftime("%F") + expect(doc.at('Filer Secondary TaxpayerSSN').content).to eq spouse_ssn + expect(doc.at('Filer Secondary TaxpayerName FirstName').content).to eq spouse_first_name + expect(doc.at('Filer Secondary TaxpayerName MiddleInitial').content).to eq spouse_middle_initial + expect(doc.at('Filer Secondary TaxpayerName LastName').content).to eq spouse_last_name + end + end end end end diff --git a/spec/lib/submission_builder/ty2024/states/nc/nc_return_xml_spec.rb b/spec/lib/submission_builder/ty2024/states/nc/nc_return_xml_spec.rb index 4e3cf68878..37501ce401 100644 --- a/spec/lib/submission_builder/ty2024/states/nc/nc_return_xml_spec.rb +++ b/spec/lib/submission_builder/ty2024/states/nc/nc_return_xml_spec.rb @@ -2,13 +2,13 @@ describe SubmissionBuilder::Ty2024::States::Nc::NcReturnXml, required_schema: "nc" do describe '.build' do - let(:intake) { create(:state_file_nc_intake, filing_status: :single) } + let(:intake) { create(:state_file_nc_intake) } let(:submission) { create(:efile_submission, data_source: intake) } let!(:initial_efile_device_info) { create :state_file_efile_device_info, :initial_creation, :filled, intake: intake } let!(:submission_efile_device_info) { create :state_file_efile_device_info, :submission, :filled, intake: intake } + let(:xml) { Nokogiri::XML::Document.parse(described_class.build(submission).document.to_xml) } it "generates basic components of return" do - xml = Nokogiri::XML::Document.parse(described_class.build(submission).document.to_xml) expect(xml.document.root.namespaces).to include({ "xmlns:efile" => "http://www.irs.gov/efile", "xmlns" => "http://www.irs.gov/efile" }) expect(xml.document.at('AuthenticationHeader').to_s).to include('xmlns="http://www.irs.gov/efile"') expect(xml.document.at('ReturnHeaderState').to_s).to include('xmlns="http://www.irs.gov/efile"')