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-552 add xml & pdf output for mailing and permanent address in maryland #4923

Merged
merged 6 commits into from
Nov 8, 2024
14 changes: 13 additions & 1 deletion app/lib/pdf_filler/md502_pdf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Md502Pdf
include PdfHelper

def source_pdf_name
"md502-TY2023"
"md502-TY2023-with-paren-edit"
end

def initialize(submission)
Expand Down Expand Up @@ -31,6 +31,18 @@ def hash_for_pdf
'Enter Spouse\'s First Name': @xml_document.at('Secondary TaxpayerName FirstName')&.text,
'Enter Spouse\'s middle initial': @xml_document.at('Secondary TaxpayerName MiddleInitial')&.text,
'Enter Spouse\'s last name': @xml_document.at('Secondary TaxpayerName LastName')&.text,

'Enter Current Mailing Address Line 1 (Street No. and Street Name or PO Box)': @xml_document.at('USAddress AddressLine1Txt')&.text,
'Enter Current Mailing Address Line 2 (Street No. and Street Name or PO Box)': @xml_document.at('USAddress AddressLine2Txt')&.text,
'Enter city or town': @xml_document.at('USAddress CityNm')&.text,
'Enter state': @xml_document.at('USAddress StateAbbreviationCd')&.text,
'Enter zip code + 4': @xml_document.at('USAddress ZIPCd')&.text,

'Enter Maryland Physical Address Line 1 (Street No. and Street Name) (No PO Box)': @xml_document.at('MarylandAddress AddressLine1Txt')&.text,
'Enter Maryland Physical Address Line 2 (Street No. and Street Name) (No PO Box)': @xml_document.at('MarylandAddress AddressLine2Txt')&.text,
'Enter city': @xml_document.at('MarylandAddress CityNm')&.text,
'2 Enter zip code + 4': @xml_document.at('MarylandAddress ZIPCd')&.text,

'Enter 4 Digit Political Subdivision Code (See Instruction 6)': @xml_document.at('MarylandSubdivisionCode')&.text,
'Enter Maryland Political Subdivision (See Instruction 6)': @submission.data_source.political_subdivision,
'Enter zip code + 5': @submission.data_source.residence_county,
Expand Down
Binary file added app/lib/pdfs/md502-TY2023-with-paren-edit.pdf
Binary file not shown.
15 changes: 15 additions & 0 deletions app/lib/submission_builder/ty2024/states/md/documents/md502.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,21 @@ def document
unless @intake.political_subdivision&.end_with?("- unincorporated")
xml.CityTownOrTaxingArea @intake.political_subdivision
end
xml.MarylandAddress do
if @intake.confirmed_permanent_address_yes?
xml.AddressLine1Txt sanitize_for_xml(@intake.direct_file_data.mailing_street, 35)
xml.AddressLine2Txt sanitize_for_xml(@intake.direct_file_data.mailing_apartment, 35)
xml.CityNm sanitize_for_xml(@intake.direct_file_data.mailing_city, 22)
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)
xml.CityNm sanitize_for_xml(@intake.permanent_city, 22)
xml.StateAbbreviationCd @intake.state_code.upcase
xml.ZIPCd @intake.permanent_zip
end
end
xml.MarylandCounty county_abbreviation
if @intake.direct_file_data.claimed_as_dependent?
xml.FilingStatus do
Expand Down
2 changes: 0 additions & 2 deletions app/models/state_file_md_intake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,13 @@ class StateFileMdIntake < StateFileBaseIntake
enum confirmed_permanent_address: { unfilled: 0, yes: 1, no: 2 }, _prefix: :confirmed_permanent_address
enum permanent_address_outside_md: { unfilled: 0, yes: 1, no: 2 }, _prefix: :permanent_address_outside_md


def disqualifying_df_data_reason
w2_states = direct_file_data.parsed_xml.css('W2StateLocalTaxGrp W2StateTaxGrp StateAbbreviationCd')
return :has_out_of_state_w2 if w2_states.any? do |state|
(state.text || '').upcase != state_code.upcase
end
end


def disqualifying_eligibility_rules
# eligibility_filing_status_mfj is not strictly a disqualifier and just leads us to other questions
{
Expand Down
54 changes: 54 additions & 0 deletions spec/lib/pdf_filler/md502_pdf_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,60 @@
expect(missing_fields).to eq([])
end

context "US address from df" do
it "fills in correct fields" do
intake.direct_file_data.mailing_street = "312 Poppy Street"
intake.direct_file_data.mailing_apartment = "Apt B"
intake.direct_file_data.mailing_city = "Annapolis"
intake.direct_file_data.mailing_state = "MD"
intake.direct_file_data.mailing_zip = "21401"

expect(pdf_fields["Enter Current Mailing Address Line 1 (Street No. and Street Name or PO Box)"]).to eq("312 Poppy Street")
expect(pdf_fields["Enter Current Mailing Address Line 2 (Street No. and Street Name or PO Box)"]).to eq("Apt B")
expect(pdf_fields["Enter city or town"]).to eq("Annapolis")
expect(pdf_fields["Enter state"]).to eq("MD")
expect(pdf_fields["Enter zip code + 4"]).to eq("21401")
end
end

context "Physical address" do
context "when the filer has confirmed their DF address is correct" do
before do
intake.confirmed_permanent_address_yes!
intake.direct_file_data.mailing_street = "312 Poppy Street"
intake.direct_file_data.mailing_apartment = "Apt B"
intake.direct_file_data.mailing_city = "Annapolis"
intake.direct_file_data.mailing_state = "MD"
intake.direct_file_data.mailing_zip = "21401"
end

it "fills the fields with the DF address" do
expect(pdf_fields["Enter Maryland Physical Address Line 1 (Street No. and Street Name) (No PO Box)"]).to eq("312 Poppy Street")
expect(pdf_fields["Enter Maryland Physical Address Line 2 (Street No. and Street Name) (No PO Box)"]).to eq("Apt B")
expect(pdf_fields["Enter city"]).to eq("Annapolis")
expect(pdf_fields["2 Enter zip code + 4"]).to eq("21401")
end
end

context "when the filer has entered a different physical address" do
before do
intake.confirmed_permanent_address_no!

intake.permanent_street = "313 Poppy Street"
intake.permanent_apartment = "Apt A"
intake.permanent_city = "Baltimore"
intake.permanent_zip = "21201"
end

it "fills the fields with the entered address" do
expect(pdf_fields["Enter Maryland Physical Address Line 1 (Street No. and Street Name) (No PO Box)"]).to eq("313 Poppy Street")
expect(pdf_fields["Enter Maryland Physical Address Line 2 (Street No. and Street Name) (No PO Box)"]).to eq("Apt A")
expect(pdf_fields["Enter city"]).to eq("Baltimore")
expect(pdf_fields["2 Enter zip code + 4"]).to eq("21201")
end
end
end

context "county information" do
before do
intake.residence_county = "Allegany"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,52 @@
end
end

context "Physical address" do
before do
intake.direct_file_data.mailing_street = "312 Poppy Street"
intake.direct_file_data.mailing_apartment = "Apt B"
intake.direct_file_data.mailing_city = "Annapolis"
intake.direct_file_data.mailing_state = "MD"
intake.direct_file_data.mailing_zip = "21401"
end

context "when user confirms that address from DF is correct" do
before do
intake.confirmed_permanent_address_yes!
intake.direct_file_data.mailing_street = "312 Poppy Street"
intake.direct_file_data.mailing_apartment = "Apt B"
intake.direct_file_data.mailing_city = "Annapolis"
intake.direct_file_data.mailing_zip = "21401"
end

it "outputs their DF address as their physical address" do
expect(xml.at("MarylandAddress AddressLine1Txt").text).to eq "312 Poppy Street"
expect(xml.at("MarylandAddress AddressLine2Txt").text).to eq "Apt B"
expect(xml.at("MarylandAddress CityNm").text).to eq "Annapolis"
expect(xml.at("MarylandAddress StateAbbreviationCd").text).to eq "MD"
expect(xml.at("MarylandAddress ZIPCd").text).to eq "21401"
end
end

context "when the user has entered a different permanent address" do
before do
intake.confirmed_permanent_address_no!
intake.permanent_street = "313 Poppy Street"
intake.permanent_apartment = "Apt A"
intake.permanent_city = "Baltimore"
intake.permanent_zip = "21201"
end

it "outputs their entered address as their physical address" do
expect(xml.at("MarylandAddress AddressLine1Txt").text).to eq "313 Poppy Street"
expect(xml.at("MarylandAddress AddressLine2Txt").text).to eq "Apt A"
expect(xml.at("MarylandAddress CityNm").text).to eq "Baltimore"
expect(xml.at("MarylandAddress StateAbbreviationCd").text).to eq "MD"
expect(xml.at("MarylandAddress ZIPCd").text).to eq "21201"
end
end
end

context "Income section" do
context "when all relevant values are present in the DF XML" do
before do
Expand Down
Loading