Skip to content

Commit

Permalink
do not include non tax filer spouse (#538)
Browse files Browse the repository at this point in the history
* do not include non tax filer spouse

* remove whitespace

* fix formatting
  • Loading branch information
jacobkagon authored Dec 23, 2024
1 parent a0a67e4 commit c49743b
Show file tree
Hide file tree
Showing 3 changed files with 629 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/aca_entities/atp/functions/tax_return_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ def call(cache)
primary_tax_filer = find_primary_tax_filer(members).first.to_s
primary_role_reference = { ref: "pe#{primary_tax_filer}" }
primary_hash = { role_reference: primary_role_reference } if primary_tax_filer.present?

spouse_tax_filer = find_spouse_tax_filer(members)
spouse_tax_filer = find_spouse_tax_filer(members, @applicants_hash.values)
spouse_role_reference = { ref: "pe#{spouse_tax_filer}" }
spouse_hash = { role_reference: spouse_role_reference } if spouse_tax_filer.present?

Expand Down Expand Up @@ -74,9 +73,10 @@ def find_primary_tax_filer(members)
members.map(&:to_sym) & @applicants_hash.select {|_k, v| v[:is_primary_applicant].present?}.keys
end

def find_spouse_tax_filer(members)
def find_spouse_tax_filer(members, applicants)
spouse = @person_relationships.detect {|h| h[:relationship_code] == "02" && members.include?(h[:other_id])}
return unless spouse
return unless applicants.detect {|applicant| applicant[:person_hbx_id] == spouse[:other_id]}[:is_required_to_file_taxes]
spouse[:other_id]
end

Expand Down
17 changes: 17 additions & 0 deletions spec/aca_entities/atp/operations/aces/generate_xml_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,23 @@
expect(texts.present?).to be_truthy
end
end

context 'spouse is not filing taxes' do
let(:spouse_non_filer_payload) { File.read('spec/support/atp/sample_payloads/non_filing_spouse_th.json') }
let(:payload_hash) { JSON.parse(spouse_non_filer_payload, symbolize_names: true) }
before do
param_flags = { 'family_flags' => { 'invert_person_association' => true } }
flagged_family = payload_hash[:family].merge(param_flags)
payload_hash['family'] = flagged_family
end

it 'should not include SpouseTaxFiler tags in the payload' do
result = described_class.new.call(payload_hash.to_json)
doc = Nokogiri::XML.parse(result.value!)
texts = doc.xpath("//hix-ee:TaxReturn/hix-ee:TaxHousehold/hix-ee:SpouseTaxFiler", namespaces)
expect(texts.present?).to be_falsey
end
end
end
end
end
Expand Down
Loading

0 comments on commit c49743b

Please sign in to comment.