Skip to content

Commit

Permalink
bug fix for not deleting xero-credentails (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
labhvam5 authored Dec 13, 2022
1 parent 50b18eb commit b89465d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions apps/xero/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,11 @@ def create_bill(expense_group_id: int, task_log_id: int, xero_connection: XeroCo
handle_xero_error(exception=exception, expense_group=expense_group, task_log=task_log)

except NoPrivilegeError as exception:
# Deleting xero credentials since the account got disconnected
XeroCredentials.objects.filter(workspace_id=expense_group.workspace_id).delete()
xero_credentials = XeroCredentials.objects.filter(workspace_id=expense_group.workspace_id).first()
xero_credentials.refresh_token = None
xero_credentials.country = None
xero_credentials.is_expired = True
xero_credentials.save()
logger.error(exception.message)
task_log.status = 'FAILED'
task_log.detail = None
Expand Down Expand Up @@ -625,8 +628,11 @@ def create_bank_transaction(expense_group_id: int, task_log_id: int, xero_connec
handle_xero_error(exception=exception, expense_group=expense_group, task_log=task_log)

except NoPrivilegeError as exception:
# Deleting xero credentials since the account got disconnected
XeroCredentials.objects.filter(workspace_id=expense_group.workspace_id).delete()
xero_credentials = XeroCredentials.objects.filter(workspace_id=expense_group.workspace_id).first()
xero_credentials.refresh_token = None
xero_credentials.country = None
xero_credentials.is_expired = True
xero_credentials.save()
logger.error(exception.message)
task_log.status = 'FAILED'
task_log.detail = None
Expand Down

0 comments on commit b89465d

Please sign in to comment.