From 414e387159c6c3d3e9528aded9aa711754c7d11d Mon Sep 17 00:00:00 2001 From: ruuushhh <66899387+ruuushhh@users.noreply.github.com> Date: Fri, 28 Apr 2023 16:44:47 +0530 Subject: [PATCH] Duplicate vendor name exist error resolved (#421) * Duplicate vendor name exist error resolved * Duplicate vendor name exist error resolved --- apps/quickbooks_online/utils.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/apps/quickbooks_online/utils.py b/apps/quickbooks_online/utils.py index 031042de..edcd2120 100644 --- a/apps/quickbooks_online/utils.py +++ b/apps/quickbooks_online/utils.py @@ -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 @@ -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 @@ -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': (