Skip to content

Commit

Permalink
In progress bug (#264)
Browse files Browse the repository at this point in the history
* in progress bug fix

* issue resolved

---------

Co-authored-by: Ashutosh619-sudo <[email protected]>
  • Loading branch information
Ashutosh619-sudo and Ashutosh619-sudo authored Oct 9, 2023
1 parent 2c6be50 commit c64bec4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
3 changes: 3 additions & 0 deletions apps/xero/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,13 @@ def new_fn(*args):
expense_group_id = args[0]
expense_group = ExpenseGroup.objects.get(id=expense_group_id)
task_log_id = args[1]
xero_connection = args[2]
task_log = TaskLog.objects.get(id=task_log_id)
workspace_id = expense_group.workspace_id

try:
if not payment and not xero_connection:
raise XeroCredentials.DoesNotExist
func(*args)

except (FyleCredential.DoesNotExist, InvalidTokenError):
Expand Down
37 changes: 17 additions & 20 deletions apps/xero/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,29 +266,26 @@ def create_chain_and_export(chaining_attributes: list, workspace_id: int) -> Non
try:
xero_credentials = XeroCredentials.get_active_xero_credentials(workspace_id)
xero_connection = XeroConnector(xero_credentials, workspace_id)
except (UnsuccessfulAuthentication, XeroCredentials.DoesNotExist):
xero_connection = None

chain = Chain()
chain = Chain()

fyle_credentials = FyleCredential.objects.get(workspace_id=workspace_id)
chain.append("apps.fyle.tasks.sync_dimensions", fyle_credentials)

for group in chaining_attributes:
trigger_function = "apps.xero.tasks.create_{}".format(group["export_type"])
chain.append(
trigger_function,
group["expense_group_id"],
group["task_log_id"],
xero_connection,
group["last_export"],
)

if chain.length() > 1:
chain.run()
fyle_credentials = FyleCredential.objects.get(workspace_id=workspace_id)
chain.append("apps.fyle.tasks.sync_dimensions", fyle_credentials)

for group in chaining_attributes:
trigger_function = "apps.xero.tasks.create_{}".format(group["export_type"])
chain.append(
trigger_function,
group["expense_group_id"],
group["task_log_id"],
xero_connection,
group["last_export"],
)

except UnsuccessfulAuthentication:
logger.info("Xero refresh token is invalid for workspace_id - %s", workspace_id)
except XeroCredentials.DoesNotExist:
logger.info("Xero Credentials not found for workspace_id %s", workspace_id)
if chain.length() > 1:
chain.run()


def schedule_bills_creation(workspace_id: int, expense_group_ids: List[str]) -> list:
Expand Down

0 comments on commit c64bec4

Please sign in to comment.