From 2ea85f72e001b0f24a4e6bab7ace4585df028f1c Mon Sep 17 00:00:00 2001 From: Ashutosh619-sudo Date: Thu, 21 Nov 2024 21:15:15 +0530 Subject: [PATCH] flake fixed --- apps/business_central/exports/journal_entry/tasks.py | 6 ++---- apps/business_central/exports/purchase_invoice/tasks.py | 3 --- apps/business_central/utils.py | 4 +--- apps/mappings/imports/modules/base.py | 1 - 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/apps/business_central/exports/journal_entry/tasks.py b/apps/business_central/exports/journal_entry/tasks.py index 504e8ce..09e509d 100644 --- a/apps/business_central/exports/journal_entry/tasks.py +++ b/apps/business_central/exports/journal_entry/tasks.py @@ -101,10 +101,8 @@ def post(self, accounting_export, item, lineitem): ) ) response["dimension_line_responses"] = dimension_line_responses - expenses = accounting_export.expenses.all() - # Load attachments to Business Central for i in range(1, len(response["responses"])): load_attachments( @@ -115,12 +113,12 @@ def post(self, accounting_export, item, lineitem): accounting_export) return response - + def construct_dimension_set_line_payload(self, dimensions: list, exported_response: dict): """ construct payload for setting dimension for Journal Entry """ - + dimension_payload = [] for response in exported_response: diff --git a/apps/business_central/exports/purchase_invoice/tasks.py b/apps/business_central/exports/purchase_invoice/tasks.py index 4c49c0a..30f7cd6 100644 --- a/apps/business_central/exports/purchase_invoice/tasks.py +++ b/apps/business_central/exports/purchase_invoice/tasks.py @@ -71,12 +71,10 @@ def __construct_purchase_invoice(self, body: PurchaseInvoice, lineitems: List[Pu return purchase_invoice_payload, batch_purchase_invoice_lineitem_payload, dimensions - def post(self, accounting_export, item, lineitem): ''' Export the Journal Entry to Business Central. ''' - purchase_invoice_payload, batch_purchase_invoice_payload, dimensions = self.__construct_purchase_invoice(item, lineitem) logger.info('WORKSPACE_ID: {0}, ACCOUNTING_EXPORT_ID: {1}, PURCHASE_INVOICE_PAYLOAD: {2}, BATCH_PURCHASE_INVOICE_PAYLOAD: {3}'.format(accounting_export.workspace_id, accounting_export.id, purchase_invoice_payload, batch_purchase_invoice_payload)) business_central_credentials = BusinessCentralCredentials.get_active_business_central_credentials(accounting_export.workspace_id) @@ -120,7 +118,6 @@ def construct_dimension_set_line_payload(self, dimensions: list, exported_respon if response.get('body') and 'description2' in response['body'] and 'id' in response['body'] } - for dimension in dimensions: expense_number = dimension.get('expense_number') parent_id = document_mapping.get(expense_number) diff --git a/apps/business_central/utils.py b/apps/business_central/utils.py index 10dc100..22e903a 100644 --- a/apps/business_central/utils.py +++ b/apps/business_central/utils.py @@ -1,7 +1,6 @@ import base64 import logging from typing import Dict, List -from collections import defaultdict from datetime import datetime from django.utils import timezone @@ -313,7 +312,7 @@ def get_lineitem_by_id(module_type: str, item_id: int): for dimension_line_payload in dimension_line_payloads: exported_module_id = dimension_line_payload.pop('exported_module_id') - + try: if export_module_type == 'JOURNAL_ENTRY': response = self.connection.journal_line_items.post_journal_entry_dimensions( @@ -338,7 +337,6 @@ def get_lineitem_by_id(module_type: str, item_id: int): return exception_response - def post_attachments( self, ref_type: str, ref_id: str, attachments: List[Dict] ) -> List: diff --git a/apps/mappings/imports/modules/base.py b/apps/mappings/imports/modules/base.py index c81860e..a40e9bb 100644 --- a/apps/mappings/imports/modules/base.py +++ b/apps/mappings/imports/modules/base.py @@ -183,7 +183,6 @@ def sync_destination_attributes(self, business_central_attribute_type: str): business_central_credentials = BusinessCentralCredentials.get_active_business_central_credentials(self.workspace_id) business_central_connection = BusinessCentralConnector(credentials_object=business_central_credentials, workspace_id=self.workspace_id) - sync_methods = { 'ACCOUNT': business_central_connection.sync_accounts, 'COMPANY': business_central_connection.sync_companies,