From 6630dbb96bb4d9e7aa85b78e55676c7097d1eaa7 Mon Sep 17 00:00:00 2001 From: Tahsina Islam <79296603+tahsinaislam@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:12:12 -0600 Subject: [PATCH] Fix return header for MD (#5232) --- app/lib/submission_builder/document.rb | 10 +++--- app/lib/submission_builder/return_header.rb | 4 ++- .../ty2024/states/md/documents/md502.rb | 8 ++--- app/models/state_file_base_intake.rb | 4 +++ app/models/state_file_md_intake.rb | 4 +++ .../ty2022/states/return_header_spec.rb | 32 +++++++++++++++++++ .../ty2024/states/md/documents/md502_spec.rb | 10 +++--- 7 files changed, 57 insertions(+), 15 deletions(-) diff --git a/app/lib/submission_builder/document.rb b/app/lib/submission_builder/document.rb index 9a3a21005f..54ae915349 100644 --- a/app/lib/submission_builder/document.rb +++ b/app/lib/submission_builder/document.rb @@ -122,11 +122,11 @@ def extract_apartment_from_mailing_street(xml) truncated_mailing_street = mailing_street[0...key_position].rstrip excess_characters = mailing_street[key_position..].lstrip - xml.AddressLine1Txt sanitize_for_xml(truncated_mailing_street, 35) + xml.AddressLine1Txt sanitize_for_xml(truncated_mailing_street, 30) if @submission.data_source.direct_file_data.mailing_apartment.present? apartment = sanitize_for_xml(@submission.data_source.direct_file_data.mailing_apartment) - if apartment.length + excess_characters.length > 35 - truncated_apartment = apartment[0, 35 - excess_characters.length].rpartition(' ').first + if apartment.length + excess_characters.length > 30 + truncated_apartment = apartment[0, 30 - excess_characters.length].rpartition(' ').first xml.AddressLine2Txt "#{excess_characters} #{truncated_apartment}" else xml.AddressLine2Txt "#{excess_characters} #{apartment}" @@ -135,8 +135,8 @@ def extract_apartment_from_mailing_street(xml) xml.AddressLine2Txt excess_characters end else - xml.AddressLine1Txt sanitize_for_xml(mailing_street, 35) - xml.AddressLine2Txt sanitize_for_xml(@submission.data_source.direct_file_data.mailing_apartment, 35) if @submission.data_source.direct_file_data.mailing_apartment.present? + xml.AddressLine1Txt sanitize_for_xml(mailing_street, 30) + xml.AddressLine2Txt sanitize_for_xml(@submission.data_source.direct_file_data.mailing_apartment, 30) if @submission.data_source.direct_file_data.mailing_apartment.present? end end diff --git a/app/lib/submission_builder/return_header.rb b/app/lib/submission_builder/return_header.rb index 2a9087a38b..137ec1cddc 100644 --- a/app/lib/submission_builder/return_header.rb +++ b/app/lib/submission_builder/return_header.rb @@ -55,7 +55,9 @@ def document xml.AddressLine1Txt sanitize_for_xml(@submission.data_source.direct_file_data.mailing_street, 35) if @submission.data_source.direct_file_data.mailing_street.present? xml.AddressLine2Txt sanitize_for_xml(@submission.data_source.direct_file_data.mailing_apartment, 35) if @submission.data_source.direct_file_data.mailing_apartment.present? end - xml.CityNm sanitize_for_xml(@submission.data_source.direct_file_data.mailing_city, 22) if @submission.data_source.direct_file_data.mailing_city.present? + if @submission.data_source.direct_file_data.mailing_city.present? + xml.CityNm sanitize_for_xml(@submission.data_source.direct_file_data.mailing_city, @submission.data_source.city_name_length_20? ? 20 : 22) + end xml.StateAbbreviationCd @submission.data_source.state_code.upcase xml.ZIPCd @submission.data_source.direct_file_data.mailing_zip if @submission.data_source.direct_file_data.mailing_zip.present? end diff --git a/app/lib/submission_builder/ty2024/states/md/documents/md502.rb b/app/lib/submission_builder/ty2024/states/md/documents/md502.rb index 5d7776410a..c093eacec8 100644 --- a/app/lib/submission_builder/ty2024/states/md/documents/md502.rb +++ b/app/lib/submission_builder/ty2024/states/md/documents/md502.rb @@ -47,13 +47,13 @@ def document xml.MarylandAddress do if @intake.confirmed_permanent_address_yes? extract_apartment_from_mailing_street(xml) - xml.CityNm sanitize_for_xml(@intake.direct_file_data.mailing_city, 22) + xml.CityNm sanitize_for_xml(@intake.direct_file_data.mailing_city, 20) xml.StateAbbreviationCd @intake.state_code.upcase xml.ZIPCd @intake.direct_file_data.mailing_zip elsif @intake.confirmed_permanent_address_no? - xml.AddressLine1Txt sanitize_for_xml(@intake.permanent_street, 35) - xml.AddressLine2Txt sanitize_for_xml(@intake.permanent_apartment, 35) if @intake.permanent_apartment.present? - xml.CityNm sanitize_for_xml(@intake.permanent_city, 22) + xml.AddressLine1Txt sanitize_for_xml(@intake.permanent_street, 30) + xml.AddressLine2Txt sanitize_for_xml(@intake.permanent_apartment, 30) if @intake.permanent_apartment.present? + xml.CityNm sanitize_for_xml(@intake.permanent_city, 20) xml.StateAbbreviationCd @intake.state_code.upcase xml.ZIPCd @intake.permanent_zip end diff --git a/app/models/state_file_base_intake.rb b/app/models/state_file_base_intake.rb index de947b17c7..a40409aef1 100644 --- a/app/models/state_file_base_intake.rb +++ b/app/models/state_file_base_intake.rb @@ -246,6 +246,10 @@ def extract_apartment_from_mailing_street? false end + def city_name_length_20? + false + end + def ask_spouse_esign? filing_status_mfj? && !spouse_deceased? end diff --git a/app/models/state_file_md_intake.rb b/app/models/state_file_md_intake.rb index 3deb0ea570..a59a8323dc 100644 --- a/app/models/state_file_md_intake.rb +++ b/app/models/state_file_md_intake.rb @@ -209,6 +209,10 @@ def extract_apartment_from_mailing_street? true end + def city_name_length_20? + true + end + def allows_refund_amount_in_xml? false end 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 1ae9c490fb..922f8e959d 100644 --- a/spec/lib/submission_builder/ty2022/states/return_header_spec.rb +++ b/spec/lib/submission_builder/ty2022/states/return_header_spec.rb @@ -222,6 +222,38 @@ end end + context "city field character limit" do + let(:mailing_city) { "This is a Very Long City Name" } + + before do + intake.direct_file_data.mailing_city = mailing_city + end + + StateFile::StateInformationService.active_state_codes.without("md").each do |state_code| + context "if state is not MD" 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 } + + it "truncates city name to 22 characters" do + expect(doc.at("USAddress CityNm").text.length).to be 22 + expect(doc.at("USAddress CityNm").text).to eq('This is a Very Long Ci') + end + end + end + + context "if state is MD" do + let(:intake) { create :state_file_md_intake } + let(:submission) { create(:efile_submission, data_source: intake) } + let(:doc) { SubmissionBuilder::ReturnHeader.new(submission).document } + + it "truncates city name to 20 characters" do + expect(doc.at("USAddress CityNm").text.length).to be 19 + expect(doc.at("USAddress CityNm").text).to eq('This is a Very Long') + end + end + end + context "MD filer personal info includes signature PINs" do let(:intake) { create( diff --git a/spec/lib/submission_builder/ty2024/states/md/documents/md502_spec.rb b/spec/lib/submission_builder/ty2024/states/md/documents/md502_spec.rb index 21048d2d5c..25ba733b7d 100644 --- a/spec/lib/submission_builder/ty2024/states/md/documents/md502_spec.rb +++ b/spec/lib/submission_builder/ty2024/states/md/documents/md502_spec.rb @@ -100,22 +100,22 @@ end it 'puts apartment on second address line' do - expect(xml.at("MarylandAddress AddressLine1Txt").text.length).to be <= 35 + expect(xml.at("MarylandAddress AddressLine1Txt").text.length).to be 26 expect(xml.at("MarylandAddress AddressLine1Txt").text).to eq('2598 HICKORY HEIGHTS DRIVE') expect(xml.at("MarylandAddress AddressLine2Txt").text).to eq('APT 21') end end - context "when mailing address is longer than 35 characters" do + context "when mailing address is longer than 30 characters" do before do intake.confirmed_permanent_address_yes! intake.direct_file_data.mailing_street = '211212 SUBDIVISION DRIVE POST OFFICE BOX NUMBER 157' intake.direct_file_data.mailing_apartment = '' end - it 'truncates mailing address under 35 characters' do - expect(xml.at("MarylandAddress AddressLine1Txt").text.length).to be <= 35 - expect(xml.at("MarylandAddress AddressLine1Txt").text).to eq('211212 SUBDIVISION DRIVE POST OFFIC') + it 'truncates mailing address to 30 characters' do + expect(xml.at("MarylandAddress AddressLine1Txt").text.length).to be 29 + expect(xml.at("MarylandAddress AddressLine1Txt").text).to eq('211212 SUBDIVISION DRIVE POST') expect(xml.at("MarylandAddress AddressLine2Txt")).not_to be_present end end