From 0d90b7e25a4ab9925fe0e162265a558f56c08f8a Mon Sep 17 00:00:00 2001 From: Yejee Arin Choi Date: Fri, 24 Jan 2025 14:09:46 -0800 Subject: [PATCH] Do not attempt to fill out account holder names if taxes are owed (account holder info is only provided if refund) (#5443) --- app/lib/pdf_filler/md502_pdf.rb | 4 +++- spec/lib/pdf_filler/md502_pdf_spec.rb | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/lib/pdf_filler/md502_pdf.rb b/app/lib/pdf_filler/md502_pdf.rb index 9bc3984619..e2844cedbf 100644 --- a/app/lib/pdf_filler/md502_pdf.rb +++ b/app/lib/pdf_filler/md502_pdf.rb @@ -178,7 +178,7 @@ def generate_codes_for_502_su def full_names_of_bank_account_holders intake = @submission.data_source - return nil unless intake.payment_or_deposit_type.to_sym == :direct_deposit + return nil unless intake.payment_or_deposit_type.to_sym == :direct_deposit && intake.refund_or_owe_taxes_type == :refund if intake.has_joint_account_holder_yes? account_holder_full_name + " and " + account_holder_full_name(for_joint: true) @@ -191,6 +191,8 @@ def account_holder_full_name(for_joint: false) attributes = %w[FirstName MiddleInitial LastName NameSuffix] account_holder_xmls = @xml_document.css('Form502 NameOnBankAccount') account_holder_xml = for_joint ? account_holder_xmls[1] : account_holder_xmls[0] + return if account_holder_xml.nil? + attributes.map { |attr| account_holder_xml.at(attr)&.text }.filter_map(&:presence).join(" ") end diff --git a/spec/lib/pdf_filler/md502_pdf_spec.rb b/spec/lib/pdf_filler/md502_pdf_spec.rb index 87ac8341da..f0dea9b024 100644 --- a/spec/lib/pdf_filler/md502_pdf_spec.rb +++ b/spec/lib/pdf_filler/md502_pdf_spec.rb @@ -495,6 +495,21 @@ expect(pdf_fields["50"]).to eq "100" expect(pdf_fields["50 decimal"]).to eq "00" end + + context "direct deposit payment is chosen" do + before do + intake.update( + payment_or_deposit_type: :direct_deposit, + routing_number: "123456789", + account_number: "87654321", + account_type: "checking" + ) + end + + it "should not try to fill out names on bank account" do + expect(pdf_fields["51d Names as it appears on the bank account"]).to eq "" + end + end end context "when there is a refund" do