From b512b5dcfac72015a2694602656fe1f0b2cb0fe6 Mon Sep 17 00:00:00 2001 From: ruuushhh Date: Thu, 8 Feb 2024 12:12:34 +0530 Subject: [PATCH 1/6] Fix Connection --- apps/business_central/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/business_central/views.py b/apps/business_central/views.py index 0dbfcc3..c2123fb 100644 --- a/apps/business_central/views.py +++ b/apps/business_central/views.py @@ -44,4 +44,4 @@ class ConnectionView(generics.RetrieveAPIView): serializer_class = Connectionserializer def get(self, request, *args, **kwargs): - return Connectionserializer.get_company(kwargs['workspace_id']) + return Connectionserializer.get_company(self.kwargs['workspace_id']) From 427b866a89e23b90964edb547226ed3a6907fa0f Mon Sep 17 00:00:00 2001 From: ruuushhh Date: Thu, 8 Feb 2024 12:22:51 +0530 Subject: [PATCH 2/6] Fix Connection --- apps/business_central/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/business_central/views.py b/apps/business_central/views.py index c2123fb..53b8ef5 100644 --- a/apps/business_central/views.py +++ b/apps/business_central/views.py @@ -44,4 +44,4 @@ class ConnectionView(generics.RetrieveAPIView): serializer_class = Connectionserializer def get(self, request, *args, **kwargs): - return Connectionserializer.get_company(self.kwargs['workspace_id']) + return Connectionserializer().get_company(kwargs['workspace_id']) From ddcded020a0e73b0515071cb0d8d23991905213f Mon Sep 17 00:00:00 2001 From: ruuushhh Date: Thu, 8 Feb 2024 12:31:52 +0530 Subject: [PATCH 3/6] Fix Connection --- apps/business_central/serializers.py | 2 +- apps/business_central/utils.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/business_central/serializers.py b/apps/business_central/serializers.py index 45f1928..34d1d50 100644 --- a/apps/business_central/serializers.py +++ b/apps/business_central/serializers.py @@ -146,4 +146,4 @@ def get_company(self, workspace_id): business_central_credentials.refresh_token = None business_central_credentials.is_expired = True business_central_credentials.save() - return Response(data={'message': 'Invalid token or Business Central connection expired'}, status=status.HTTP_400_BAD_REQUEST) + return Response(data={'message': 'Invalid token or Business Central connection expired'}, status=status.HTTP_400_BAD_REQUEST) diff --git a/apps/business_central/utils.py b/apps/business_central/utils.py index faf9191..969aa15 100644 --- a/apps/business_central/utils.py +++ b/apps/business_central/utils.py @@ -30,7 +30,7 @@ def __init__(self, credentials_object: BusinessCentralCredentials, workspace_id: client_id=client_id, client_secret=client_secret, refresh_token=refresh_token, - company_id=business_central_company_id + company_id=business_central_company_id if business_central_company_id else None ) self.workspace_id = workspace_id From de7c5f0a286a4e0a3a263c31e907b974d9c4754e Mon Sep 17 00:00:00 2001 From: ruuushhh Date: Thu, 8 Feb 2024 12:37:20 +0530 Subject: [PATCH 4/6] Fix Connection --- apps/business_central/serializers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/business_central/serializers.py b/apps/business_central/serializers.py index 34d1d50..a3a7b5c 100644 --- a/apps/business_central/serializers.py +++ b/apps/business_central/serializers.py @@ -136,7 +136,7 @@ def get_company(self, workspace_id): business_central_connector = BusinessCentralConnector(business_central_credentials, workspace_id=workspace_id) - companies = business_central_connector.get_companies() + companies = business_central_connector.sync_companies() return Response(data=companies, status=status.HTTP_200_OK) except BusinessCentralCredentials.DoesNotExist: From baae7169e5b5d5705968df41d48978a0781c459e Mon Sep 17 00:00:00 2001 From: ruuushhh Date: Thu, 8 Feb 2024 13:28:34 +0530 Subject: [PATCH 5/6] bump version --- apps/business_central/helpers.py | 2 +- apps/business_central/serializers.py | 2 +- apps/business_central/utils.py | 4 +++- requirements.txt | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/business_central/helpers.py b/apps/business_central/helpers.py index 57a0ee0..077f2b7 100644 --- a/apps/business_central/helpers.py +++ b/apps/business_central/helpers.py @@ -48,7 +48,7 @@ def sync_dimensions(business_central_credential: BusinessCentralCredentials, wor business_central_connection = import_string('apps.business_central.utils.BusinessCentralConnector')(business_central_credential, workspace_id) # List of dimensions to sync - dimensions = ['accounts', 'vendors', 'employees', 'locations', 'companies'] + dimensions = ['companies', 'accounts', 'vendors', 'employees', 'locations'] for dimension in dimensions: try: diff --git a/apps/business_central/serializers.py b/apps/business_central/serializers.py index a3a7b5c..34d1d50 100644 --- a/apps/business_central/serializers.py +++ b/apps/business_central/serializers.py @@ -136,7 +136,7 @@ def get_company(self, workspace_id): business_central_connector = BusinessCentralConnector(business_central_credentials, workspace_id=workspace_id) - companies = business_central_connector.sync_companies() + companies = business_central_connector.get_companies() return Response(data=companies, status=status.HTTP_200_OK) except BusinessCentralCredentials.DoesNotExist: diff --git a/apps/business_central/utils.py b/apps/business_central/utils.py index 969aa15..5ec795e 100644 --- a/apps/business_central/utils.py +++ b/apps/business_central/utils.py @@ -30,7 +30,7 @@ def __init__(self, credentials_object: BusinessCentralCredentials, workspace_id: client_id=client_id, client_secret=client_secret, refresh_token=refresh_token, - company_id=business_central_company_id if business_central_company_id else None + company_id=business_central_company_id ) self.workspace_id = workspace_id @@ -93,6 +93,7 @@ def sync_companies(self): """ sync business central companies """ + print('sync_companies') companies = self.connection.companies.get_all() field_names = [] @@ -143,6 +144,7 @@ def get_companies(self): """ Get business central companies """ + self.connection.__company_id = None companies = self.connection.companies.get_all() return companies diff --git a/requirements.txt b/requirements.txt index 5a05c2a..7326e99 100644 --- a/requirements.txt +++ b/requirements.txt @@ -28,7 +28,7 @@ gunicorn==20.1.0 fyle==0.36.0 # Business central sdk -ms-dynamics-business-central-sdk==1.4.1 +ms-dynamics-business-central-sdk==1.4.2 # Reusable Fyle Packages fyle-rest-auth==1.6.0 From 6f1996abb4d4294bf7b6f5d61b3d3fc5bfcf3b19 Mon Sep 17 00:00:00 2001 From: ruuushhh Date: Thu, 8 Feb 2024 13:29:20 +0530 Subject: [PATCH 6/6] bump version --- apps/business_central/utils.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/business_central/utils.py b/apps/business_central/utils.py index 5ec795e..faf9191 100644 --- a/apps/business_central/utils.py +++ b/apps/business_central/utils.py @@ -93,7 +93,6 @@ def sync_companies(self): """ sync business central companies """ - print('sync_companies') companies = self.connection.companies.get_all() field_names = [] @@ -144,7 +143,6 @@ def get_companies(self): """ Get business central companies """ - self.connection.__company_id = None companies = self.connection.companies.get_all() return companies