Skip to content

Commit

Permalink
delete corporate card mapping bug fix (#206)
Browse files Browse the repository at this point in the history
* delete corporate card mapping bug fix

* moving function call to trigger

* removing line

* resolving comments
  • Loading branch information
labhvam5 authored Jan 31, 2023
1 parent ff56996 commit 4188259
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions apps/workspaces/apis/export_settings/triggers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from apps.mappings.tasks import schedule_auto_map_employees
from apps.workspaces.models import WorkspaceGeneralSettings
from fyle_accounting_mappings.models import MappingSetting
from apps.workspaces.utils import delete_cards_mapping_settings


class ExportSettingsTrigger:
Expand All @@ -23,5 +24,7 @@ def run_workspace_general_settings_triggers(workspace_general_settings_instance:
}
)

delete_cards_mapping_settings(workspace_general_settings_instance)

schedule_auto_map_employees(workspace_general_settings_instance.auto_map_employees,
workspace_general_settings_instance.workspace_id)
11 changes: 11 additions & 0 deletions apps/workspaces/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,14 @@ def generate_xero_identity(authorization_code: str, redirect_uri: str) -> str:

elif response.status_code == 500:
raise InternalServerError('Internal server error', response.text)


def delete_cards_mapping_settings(workspace_general_settings: WorkspaceGeneralSettings):
if not workspace_general_settings.corporate_credit_card_expenses_object:
mapping_setting = MappingSetting.objects.filter(
workspace_id=workspace_general_settings.workspace_id,
source_field='CORPORATE_CARD',
destination_field='BANK_ACCOUNT'
).first()
if mapping_setting:
mapping_setting.delete()

0 comments on commit 4188259

Please sign in to comment.