Skip to content

Commit

Permalink
fix: Disable items category (#674)
Browse files Browse the repository at this point in the history
* disable/enable items

* update submodule

* update submodule

* update submodule

* add tests for cov

* fix: disable items with trigger import settings

* update submodule
  • Loading branch information
Hrishabh17 committed Sep 30, 2024
1 parent b36a4c9 commit fd3f6df
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion apps/workspaces/apis/import_settings/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ def update(self, instance, validated):
category_import_log.last_successful_run_at = None
category_import_log.save()

pre_save_general_settings = WorkspaceGeneralSettings.objects.filter(workspace_id=instance.id).first()

workspace_general_settings_instance, _ = WorkspaceGeneralSettings.objects.update_or_create(
workspace=instance,
defaults={
Expand All @@ -108,7 +110,7 @@ def update(self, instance, validated):

trigger: ImportSettingsTrigger = ImportSettingsTrigger(workspace_general_settings=workspace_general_settings, mapping_settings=mapping_settings, workspace_id=instance.id)

trigger.post_save_workspace_general_settings(workspace_general_settings_instance)
trigger.post_save_workspace_general_settings(workspace_general_settings_instance, pre_save_general_settings)
trigger.pre_save_mapping_settings()

if workspace_general_settings['import_tax_codes']:
Expand Down
5 changes: 4 additions & 1 deletion apps/workspaces/apis/import_settings/triggers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import Dict, List

from django_q.tasks import async_task
from django.db.models import Q
from fyle_accounting_mappings.models import MappingSetting, ExpenseAttribute

Expand Down Expand Up @@ -70,10 +71,12 @@ def __update_expense_group_settings_for_departments(self):

self.add_department_grouping(department_setting['source_field'])

def post_save_workspace_general_settings(self, workspace_general_settings_instance: WorkspaceGeneralSettings):
def post_save_workspace_general_settings(self, workspace_general_settings_instance: WorkspaceGeneralSettings, old_workspace_general_settings: WorkspaceGeneralSettings):
"""
Post save action for workspace general settings
"""
if not workspace_general_settings_instance.import_items and old_workspace_general_settings.import_items:
async_task('fyle_integrations_imports.tasks.disable_items', workspace_id=self.__workspace_id, is_import_enabled=False)
new_schedule_or_delete_fyle_import_tasks(workspace_general_settings_instance)

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 fd3f6df

Please sign in to comment.