Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Connection #92

Merged
merged 6 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/business_central/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion apps/business_central/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 2 additions & 0 deletions apps/business_central/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def sync_companies(self):
"""
sync business central companies
"""
print('sync_companies')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the print statement from the sync_companies method for production readiness.

-        print('sync_companies')

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
print('sync_companies')

companies = self.connection.companies.get_all()
field_names = []

Expand Down Expand Up @@ -143,6 +144,7 @@ def get_companies(self):
"""
Get business central companies
"""
self.connection.__company_id = None
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid directly accessing private attributes like __company_id. Consider implementing a method in the Dynamics class for resetting or managing the company ID.

-        self.connection.__company_id = None
+        # Suggested: Implement a method in the Dynamics class for this operation.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
self.connection.__company_id = None
# Suggested: Implement a method in the Dynamics class for this operation.

companies = self.connection.companies.get_all()
return companies

Expand Down
2 changes: 1 addition & 1 deletion apps/business_central/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(kwargs['workspace_id'])
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading