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: Disable items category #674

Merged
merged 10 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 9 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
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
Loading