Skip to content

Commit

Permalink
Fix: Remove code for adding department in expense group settings (#665)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashutosh619-sudo committed Nov 14, 2024
1 parent 2100c6d commit c88e867
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions apps/workspaces/apis/import_settings/triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,6 @@ def add_department_grouping(self, source_field: str):

expense_group_settings.save()

def __update_expense_group_settings_for_departments(self):
"""
Should group expenses by department source field in case the export is journal entries
"""
department_setting = list(filter(lambda setting: setting['destination_field'] == 'DEPARTMENT', self.__mapping_settings))

if department_setting:
department_setting = department_setting[0]

self.add_department_grouping(department_setting['source_field'])

def post_save_configurations(self, configurations_instance: Configuration):
"""
Expand All @@ -77,16 +67,6 @@ def post_save_configurations(self, configurations_instance: Configuration):
mapping_settings=self.__mapping_settings
)

def __remove_old_department_source_field(self, current_mappings_settings: List[MappingSetting], new_mappings_settings: List[Dict]):
"""
Should remove Department Source field from Reimbursable settings in case of deletion and updation
"""
old_department_setting = current_mappings_settings.filter(destination_field='DEPARTMENT').first()

new_department_setting = list(filter(lambda setting: setting['destination_field'] == 'DEPARTMENT', new_mappings_settings))

if old_department_setting and new_department_setting and old_department_setting.source_field != new_department_setting[0]['source_field']:
self.remove_department_grouping(old_department_setting.source_field.lower())

def __unset_auto_mapped_flag(self, current_mapping_settings: List[MappingSetting], new_mappings_settings: List[Dict]):
"""
Expand Down Expand Up @@ -119,8 +99,6 @@ def pre_save_mapping_settings(self):

# Update department mapping to some other Fyle field
current_mapping_settings = MappingSetting.objects.filter(workspace_id=self.__workspace_id).all()

self.__remove_old_department_source_field(current_mappings_settings=current_mapping_settings, new_mappings_settings=mapping_settings)
self.__unset_auto_mapped_flag(current_mapping_settings=current_mapping_settings, new_mappings_settings=mapping_settings)

def post_save_mapping_settings(self, configurations_instance: Configuration):
Expand All @@ -139,8 +117,6 @@ def post_save_mapping_settings(self, configurations_instance: Configuration):

MappingSetting.objects.filter(~Q(destination_field__in=destination_fields), workspace_id=self.__workspace_id).delete()

self.__update_expense_group_settings_for_departments()

new_schedule_or_delete_fyle_import_tasks(
configuration_instance=configurations_instance,
mapping_settings=self.__mapping_settings
Expand Down

0 comments on commit c88e867

Please sign in to comment.