Skip to content

Commit

Permalink
Merge branch 'trunk' into pt_187861724
Browse files Browse the repository at this point in the history
  • Loading branch information
saikumar9 authored Aug 12, 2024
2 parents 8bbfd0b + 47e3f4c commit 824f4d8
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 15 deletions.
25 changes: 13 additions & 12 deletions lib/aca_entities/crm/transformers/family_to/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ def transform_family(primary_family_member, family)
name: primary_person.person_name.full_name,
email1: primary_person.home_email || primary_person.work_email,
billing_address_street: fetch_address(primary_person, 'billing_address_street'),
billing_address_street2: fetch_address(primary_person, 'billing_address_street2'),
billing_address_street3: fetch_address(primary_person, 'billing_address_street3'),
billing_address_street4: nil,
billing_address_street_2: fetch_address(primary_person, 'billing_address_street_2'),
billing_address_street_3: fetch_address(primary_person, 'billing_address_street_3'),
billing_address_street_4: nil,
billing_address_city: fetch_address(primary_person, 'billing_address_city'),
billing_address_postalcode: fetch_address(primary_person, 'billing_address_postalcode'),
billing_address_state: fetch_address(primary_person, 'billing_address_state'),
Expand All @@ -71,9 +71,9 @@ def fetch_address(person, kind)
case kind
when 'billing_address_street'
address.try(:address_1)
when 'billing_address_street2'
when 'billing_address_street_2'
address.try(:address_2)
when 'billing_address_street3'
when 'billing_address_street_3'
address.try(:address_3)
when 'billing_address_city'
address.try(:city)
Expand Down Expand Up @@ -117,15 +117,16 @@ def fetch_relationship_to_primary(hbx_id, primary_person)

def transform_contacts(family_members, primary_person)
family_members.map do |family_member|
next unless family_member.person.present?
hbx_id = family_member.person.hbx_id
person = family_member.person
next unless person.present?
hbx_id = person.hbx_id
{
hbxid_c: hbx_id,
first_name: family_member.person.person_name.first_name,
last_name: family_member.person.person_name.last_name,
phone_mobile: fetch_and_format_phone(primary_person),
email1: primary_person.home_email || primary_person.work_email,
birthdate: family_member&.person&.person_demographics&.dob&.to_s,
first_name: person.person_name.first_name,
last_name: person.person_name.last_name,
phone_mobile: fetch_and_format_phone(person),
email1: person.home_email || person.work_email,
birthdate: person&.person_demographics&.dob&.to_s,
relationship_c: fetch_relationship_to_primary(hbx_id, primary_person)
}
end
Expand Down
18 changes: 18 additions & 0 deletions spec/aca_entities/crm/transformers/family_to/account_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
expect(@result.success[:billing_address_street]).to eq(addresses.first[:address_1])
end

it "returns transformed address 2" do
expect(@result.success[:billing_address_street_2]).to eq(addresses.first[:address_2])
end

it "returns transformed address city" do
expect(@result.success[:billing_address_city]).to eq(addresses.first[:city])
end
Expand Down Expand Up @@ -135,5 +139,19 @@
expect(result.success[:contacts].last[:relationship_c]).to eql(relationship_mapper)
end
end

it 'returns the correctly formatted phone number for contact' do
phone = family_cv[:family_members].last[:person][:phones].first

phone_number = phone[:area_code] + phone[:number]

formatted_number = phone_number.gsub(/(\d{3})(\d{3})(\d{4})/, '(\1) \2-\3')
expect(@result.success[:contacts].last[:phone_mobile]).to eql(formatted_number)
end

it 'returns the correct email for contact' do
email = family_cv[:family_members].last[:person][:emails].first[:address]
expect(@result.success[:contacts].last[:email1]).to eql(email)
end
end
end
29 changes: 26 additions & 3 deletions spec/support/shared_content/families/sample_cv_family.rb
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@
{
kind: "home",
address_1: "S Street NW",
address_2: "",
address_2: "Apt 101",
address_3: "",
city: "Washington",
county: "",
Expand All @@ -593,6 +593,29 @@
]
end

let(:dependent_phones) do
[
{
kind: "home",
country_code: "",
area_code: "202",
number: "5555555",
extension: "",
primary: true,
full_phone_number: "2025555555"
}
]
end

let(:dependent_emails) do
[
{
kind: "home",
address: "[email protected]"
}
]
end

let(:emails) do
[
{
Expand Down Expand Up @@ -661,8 +684,8 @@
verification_types: verification_types,
broker_role: broker_role,
addresses: addresses,
phones: phones,
emails: emails,
phones: dependent_phones,
emails: dependent_emails,
documents: documents,
timestamp: timestamp
}
Expand Down

0 comments on commit 824f4d8

Please sign in to comment.