Skip to content

Commit

Permalink
Fixes #786: error creating new customer when address provided (#787)
Browse files Browse the repository at this point in the history
  • Loading branch information
vaddenz authored Feb 19, 2024
1 parent f0d57e3 commit 0ea71f7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions backend/api/serializers/model_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,17 +888,17 @@ def create(self, validated_data):
shipping_address = validated_data.pop("shipping_address", None)
customer = Customer.objects.create(**validated_data)
if address:
address = Address.objects.get_or_create(
address, _ = Address.objects.get_or_create(
**address, organization=self.context["organization"]
)
customer.billing_address = address
if billing_address:
billing_address = Address.objects.get_or_create(
billing_address, _ = Address.objects.get_or_create(
**billing_address, organization=self.context["organization"]
)
customer.billing_address = billing_address
if shipping_address:
shipping_address = Address.objects.get_or_create(
shipping_address, _ = Address.objects.get_or_create(
**shipping_address, organization=self.context["organization"]
)
customer.shipping_address = shipping_address
Expand Down
8 changes: 4 additions & 4 deletions backend/metering_billing/views/crm_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ def sync_customers_with_salesforce(organization):
fuzzy_country = None

try:
billing_address = Address.objects.get_or_create(
billing_address, _ = Address.objects.get_or_create(
line1=billing_address["street"],
city=billing_address["city"],
state=billing_address["state"],
Expand All @@ -372,7 +372,7 @@ def sync_customers_with_salesforce(organization):
except Exception:
try:
normalized = normalize_address_record(billing_address["street"])
billing_address = Address.objects.get_or_create(
billing_address, _ = Address.objects.get_or_create(
line1=normalized["address_line_1"],
line2=normalized["address_line_2"],
city=normalized["city"],
Expand All @@ -391,7 +391,7 @@ def sync_customers_with_salesforce(organization):
fuzzy_country = None

try:
shipping_address = Address.objects.get_or_create(
shipping_address, _ = Address.objects.get_or_create(
line1=shipping_address["street"],
city=shipping_address["city"],
state=shipping_address["state"],
Expand All @@ -403,7 +403,7 @@ def sync_customers_with_salesforce(organization):
normalized = normalize_address_record(
shipping_address["street"]
)
shipping_address = Address.objects.get_or_create(
shipping_address, _ = Address.objects.get_or_create(
line1=normalized["address_line_1"],
line2=normalized["address_line_2"],
city=normalized["city"],
Expand Down

0 comments on commit 0ea71f7

Please sign in to comment.