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-1778 MD wants more bank info in financial resolution on xml #5566

Merged
merged 8 commits into from
Feb 12, 2025
7 changes: 7 additions & 0 deletions app/lib/submission_builder/authentication_header.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ def document
build_xml_doc("AuthenticationHeader") do |xml|
xml.FilingLicenseTypeCd "O"
xml.FinancialResolution do
if @intake.has_banking_information_in_financial_resolution? && @intake.payment_or_deposit_type_direct_deposit?
xml.FirstInput do
xml.RoutingTransitNum sanitize_for_xml(@intake.routing_number) if @intake.routing_number.present?
xml.DepositorAccountNum sanitize_for_xml(@intake.account_number) if @intake.account_number.present?
xml.InputTimestamp @intake.primary_esigned_at.in_time_zone(StateFile::StateInformationService.timezone("md")).strftime("%FT%T%:z") if @intake.primary_esigned_at.present?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

found the strftime format needed to satisfy xsd schema https://apidock.com/ruby/DateTime/strftime

end
end
xml.Submission do
xml.RefundProductCIPCdSubmit "0"
refund_disbursement(xml)
Expand Down
4 changes: 4 additions & 0 deletions app/models/state_file_base_intake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ def allows_w2_editing?
true
end

def has_banking_information_in_financial_resolution?
false
end

class Person
attr_reader :first_name, :middle_initial, :last_name, :suffix, :birth_date, :ssn, :primary_or_spouse

Expand Down
4 changes: 4 additions & 0 deletions app/models/state_file_md_intake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,8 @@ def city_name_length_20?
def allows_refund_amount_in_xml?
false
end

def has_banking_information_in_financial_resolution?
true
end
end
13 changes: 13 additions & 0 deletions spec/factories/state_file_md_intakes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,19 @@
end
end

factory :state_file_md_owed_intake do
after(:build) do |intake|
intake.direct_file_data.fed_agi = 120000
intake.raw_direct_file_data = intake.direct_file_data.to_s
intake.payment_or_deposit_type = "direct_deposit"
intake.account_type = "checking"
intake.routing_number = 111111111
intake.account_number = 222222222
intake.date_electronic_withdrawal = Date.new(Rails.configuration.statefile_current_tax_year, 4, 15)
intake.withdraw_amount = 5
end
end

trait :with_efile_device_infos do
after(:build) do |intake|
create :state_file_efile_device_info, :filled, :initial_creation, intake: intake
Expand Down
24 changes: 10 additions & 14 deletions spec/lib/submission_builder/financial_transaction_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@

describe SubmissionBuilder::FinancialTransaction do
describe '.build' do
let(:intake) { create(:state_file_az_owed_intake) }
let(:kwargs) { {} }
let(:submission) { create(:efile_submission, data_source: intake) }
let(:xml) {
Nokogiri::XML::Document.parse(
described_class.build(
submission, validate: false, kwargs: kwargs
).document.to_xml)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactored tests in FinancialTransaction (I was here accidentally, thought I was adding stuff here but turned out i was supposed to be adding to AuthenticationHeader 😓)

context "when filer owes money" do
let(:intake) { create(:state_file_az_owed_intake) }
let(:submission) { create(:efile_submission, data_source: intake) }
it "populates the StatePayment" do
xml = Nokogiri::XML::Document.parse(
described_class.build(
submission, validate: false
).document.to_xml)
expect(xml.at("StatePayment Checking").text).to eq "X"
expect(xml.at("StatePayment RoutingTransitNumber").text).to eq "111111111"
expect(xml.at("StatePayment BankAccountNumber").text).to eq "222222222"
Expand All @@ -29,10 +32,6 @@
let(:intake) { create(:state_file_nc_intake, :taxes_owed) }

it "populates the StatePayment with additional information" do
xml = Nokogiri::XML::Document.parse(
described_class.build(
submission, validate: false
).document.to_xml)
expect(xml.at("StatePayment Checking").text).to eq "X"
expect(xml.at("StatePayment RoutingTransitNumber").text).to eq "111111111"
expect(xml.at("StatePayment BankAccountNumber").text).to eq "222222222"
Expand All @@ -53,12 +52,9 @@
context "when filer gets a refund" do
let(:intake) { create(:state_file_az_refund_intake) }
let(:submission) { create(:efile_submission, data_source: intake) }
let(:kwargs) { { refund_amount: 5 } }

it "populates the RefundDirectDeposit" do
xml = Nokogiri::XML::Document.parse(
described_class.build(
submission, validate: false, kwargs: { refund_amount: 5 }
).document.to_xml)
expect(xml.at("RefundDirectDeposit Savings").text).to eq "X"
expect(xml.at("RefundDirectDeposit RoutingTransitNumber").text).to eq "111111111"
expect(xml.at("RefundDirectDeposit BankAccountNumber").text).to eq "222222222"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,89 @@
end
end
end

context "FirstInput" do
let(:submission) { create(:efile_submission, data_source: intake) }
let(:xml) { SubmissionBuilder::AuthenticationHeader.new(submission).document }

context "in a state that does not require banking information in FinancialResolution" do
context "refund" do
let(:intake) { create(:state_file_az_refund_intake) }

it "leaves FirstInput details blank" do
expect(xml.at("FirstInput RoutingTransitNum")).to be_nil
expect(xml.at("FirstInput DepositorAccountNum")).to be_nil
expect(xml.at("FirstInput InputTimestamp")).to be_nil
end
end

context "owed" do
let(:intake) { create(:state_file_az_owed_intake) }

it "leaves FirstInput details blank" do
expect(xml.at("FirstInput RoutingTransitNum")).to be_nil
expect(xml.at("FirstInput DepositorAccountNum")).to be_nil
expect(xml.at("FirstInput InputTimestamp")).to be_nil
end
end
end

context "in a state that requires banking information in FinancialResolution" do
context "refund" do
let(:intake) { create(:state_file_md_refund_intake, primary_esigned_at: DateTime.new(2025, 2, 15, 12).in_time_zone(StateFile::StateInformationService.timezone("md"))) }

context "with direct_deposit for their refund" do
before do
intake.update(payment_or_deposit_type: "direct_deposit")
end

it "fills out the FirstInput banking information" do
expect(xml.at("FirstInput RoutingTransitNum").text).to eq "111111111"
expect(xml.at("FirstInput DepositorAccountNum").text).to eq "222222222"
expect(xml.at("FirstInput InputTimestamp").text).to eq "2025-02-15T07:00:00-05:00"
end
end

context "with mail selected for their refund" do
before do
intake.update(payment_or_deposit_type: "mail")
end

it "leaves FirstInput details blank" do
expect(xml.at("FirstInput RoutingTransitNum")).to be_nil
expect(xml.at("FirstInput DepositorAccountNum")).to be_nil
expect(xml.at("FirstInput InputTimestamp")).to be_nil
end
end
end

context "owed" do
let(:intake) { create(:state_file_md_owed_intake, primary_esigned_at: DateTime.new(2025, 2, 15, 12).in_time_zone(StateFile::StateInformationService.timezone("md"))) }

context "with direct_deposit for their refund" do
before do
intake.update(payment_or_deposit_type: "direct_deposit")
end

it "fills out the FirstInput banking information" do
expect(xml.at("FirstInput RoutingTransitNum").text).to eq "111111111"
expect(xml.at("FirstInput DepositorAccountNum").text).to eq "222222222"
expect(xml.at("FirstInput InputTimestamp").text).to eq "2025-02-15T07:00:00-05:00"
end
end

context "with mail selected for their refund" do
before do
intake.update(payment_or_deposit_type: "mail")
end

it "leaves FirstInput details blank" do
expect(xml.at("FirstInput RoutingTransitNum")).to be_nil
expect(xml.at("FirstInput DepositorAccountNum")).to be_nil
expect(xml.at("FirstInput InputTimestamp")).to be_nil
end
end
end
end
end
end
Loading