From 0ed7559b73619a11e1ca3ddccca05b5e8ff22284 Mon Sep 17 00:00:00 2001 From: labhvam5 Date: Sun, 3 Dec 2023 14:20:27 +0530 Subject: [PATCH] Disabling categories when import-items in disabled --- apps/mappings/queues.py | 32 ++++++++++++++++--- .../apis/import_settings/triggers.py | 5 +++ fyle_integrations_imports | 2 +- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/apps/mappings/queues.py b/apps/mappings/queues.py index 061bc390..08de3e03 100644 --- a/apps/mappings/queues.py +++ b/apps/mappings/queues.py @@ -98,7 +98,17 @@ def schedule_auto_map_employees(employee_mapping_preference: str, workspace_id: def async_disable_category_for_items_mapping(workspace_id: int): - async_task('apps.mappings.tasks.disable_category_for_items_mapping', workspace_id) + print(""" + + async_disable_category_for_items_mapping: async_disable_category_for_items_mapping + """) + # credentials = QBOCredential.objects.get(workspace_id=workspace_id) + # async_task( + # 'fyle_integrations_imports.tasks.disable_category_for_items_mapping', + # workspace_id, + # 'apps.quickbooks_online.utils.QBOConnector', + # credentials + # ) def construct_tasks_and_chain_import_fields_to_fyle(workspace_id): @@ -106,10 +116,17 @@ def construct_tasks_and_chain_import_fields_to_fyle(workspace_id): Chain import fields to Fyle :param workspace_id: Workspace Id """ + print(""" + + construct_tasks_and_chain_import_fields_to_fyle + + """) mapping_settings = MappingSetting.objects.filter(workspace_id=workspace_id, import_to_fyle=True) workspace_general_settings = WorkspaceGeneralSettings.objects.get(workspace_id=workspace_id) credentials = QBOCredential.objects.get(workspace_id=workspace_id) + print(workspace_general_settings) + task_settings: TaskSetting = { 'import_tax': None, 'import_vendors_as_merchants': None, @@ -118,15 +135,22 @@ def construct_tasks_and_chain_import_fields_to_fyle(workspace_id): 'credentials': credentials, 'sdk_connection_string': 'apps.quickbooks_online.utils.QBOConnector', } - + destination_sync_methods = [] if workspace_general_settings.import_categories or workspace_general_settings.import_items: + print('import_categories or import_items') if workspace_general_settings.import_categories: + print('import_categories') destination_sync_methods = [SYNC_METHODS['ACCOUNT']] + print(destination_sync_methods) if workspace_general_settings.import_items: - items_sync_method = [SYNC_METHODS['ITEM']] + print('import_items') + items_sync_method = SYNC_METHODS['ITEM'] if destination_sync_methods: - destination_sync_methods = destination_sync_methods.append(SYNC_METHODS['ITEM']) if destination_sync_methods else items_sync_method + destination_sync_methods.extend([items_sync_method]) + else: + destination_sync_methods = [items_sync_method] + print(destination_sync_methods) task_settings['import_categories'] = { 'destination_field': 'ACCOUNT', 'destination_sync_methods': destination_sync_methods, diff --git a/apps/workspaces/apis/import_settings/triggers.py b/apps/workspaces/apis/import_settings/triggers.py index b6654958..ef9054ad 100644 --- a/apps/workspaces/apis/import_settings/triggers.py +++ b/apps/workspaces/apis/import_settings/triggers.py @@ -85,6 +85,11 @@ def post_save_workspace_general_settings(self, workspace_general_settings_instan new_schedule_or_delete_fyle_import_tasks(workspace_general_settings_instance) if not workspace_general_settings_instance.import_items: + print(""" + + post_save_workspace_general_settings: async_disable_category_for_items_mapping + + """) async_disable_category_for_items_mapping(self.__workspace_id) def __remove_old_department_source_field(self, current_mappings_settings: List[MappingSetting], new_mappings_settings: List[Dict]): diff --git a/fyle_integrations_imports b/fyle_integrations_imports index 1269907e..93ea7740 160000 --- a/fyle_integrations_imports +++ b/fyle_integrations_imports @@ -1 +1 @@ -Subproject commit 1269907ee9c8930c112e461f4e8dfb550837d147 +Subproject commit 93ea774070ee6d2c9f89685cb1127068bd19f313