Skip to content

Commit

Permalink
Duplicate vendor name exist error resolved (#421)
Browse files Browse the repository at this point in the history
* Duplicate vendor name exist error resolved

* Duplicate vendor name exist error resolved
  • Loading branch information
ruuushhh authored Apr 28, 2023
1 parent fc40089 commit 414e387
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions apps/quickbooks_online/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def get_or_create_vendor(self, vendor_name: str, email: str = None, create: bool
:param create: False to just Get and True to Get or Create if not exists
:return: Vendor
"""
original_vendor_name = vendor_name
vendor_name = vendor_name.replace("'", "\\'") # Replacing ' with \\'
vendor_name = vendor_name.replace('#', '%23') # Replace '#' with %23
vendor_name = vendor_name.replace('&', '%26') # Replace '&' with %26
Expand All @@ -87,7 +88,7 @@ def get_or_create_vendor(self, vendor_name: str, email: str = None, create: bool
#safe check to avoid duplicate vendor name exist error
if DestinationAttribute.objects.filter(attribute_type__in=['CUSTOMER', 'EMPLOYEE'], value=vendor_name, workspace_id=self.workspace_id).exists():
return
created_vendor = self.post_vendor(vendor_name, email)
created_vendor = self.post_vendor(original_vendor_name, email)
return self.create_vendor_destionation_attribute(created_vendor)
else:
return
Expand Down Expand Up @@ -358,10 +359,6 @@ def post_vendor(self, vendor_name: str, email: str):
"""
currency = Workspace.objects.get(id=self.workspace_id).fyle_currency

vendor_name = vendor_name.replace("'", "\\'") # Replacing ' with \\'
vendor_name = vendor_name.replace('#', '%23') # Replace '#' with %23
vendor_name = vendor_name.replace('&', '%26') # Replace '&' with %26

vendor = {
'GivenName': vendor_name.split(' ')[0] if email else None,
'FamilyName': (
Expand Down

0 comments on commit 414e387

Please sign in to comment.