Skip to content

Commit

Permalink
Disabling categories when import-items in disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
labhvam5 committed Dec 3, 2023
1 parent 80170b6 commit 0ed7559
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
32 changes: 28 additions & 4 deletions apps/mappings/queues.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,35 @@ 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):
"""
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,
Expand All @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions apps/workspaces/apis/import_settings/triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]):
Expand Down
2 changes: 1 addition & 1 deletion fyle_integrations_imports

0 comments on commit 0ed7559

Please sign in to comment.