From 0ca9e6ef0b182c67cf5c3038dacc04bd9b7960e5 Mon Sep 17 00:00:00 2001 From: Ashutosh singh <55102089+Ashutosh619-sudo@users.noreply.github.com> Date: Fri, 21 Jun 2024 12:47:19 +0530 Subject: [PATCH] Bug fix for marking expense paid (#630) * Bug fix for marking expense paid * flake resovled --- apps/quickbooks_online/tasks.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/apps/quickbooks_online/tasks.py b/apps/quickbooks_online/tasks.py index eafeb82a..a83f4d8b 100644 --- a/apps/quickbooks_online/tasks.py +++ b/apps/quickbooks_online/tasks.py @@ -690,10 +690,18 @@ def process_reimbursements(workspace_id): payloads.append({'id': report_id, 'paid_notify_at': datetime.now(timezone.utc).strftime('%Y-%m-%dT%H:%M:%S.%fZ')}) expenses_to_be_marked.extend(paid_expenses) - platform.reports.bulk_mark_as_paid(payloads) - if expenses_to_be_marked: - expense_ids_to_mark = [expense.id for expense in expenses_to_be_marked] - Expense.objects.filter(id__in=expense_ids_to_mark).update(paid_on_fyle=True) + if payloads: + try: + platform.reports.bulk_mark_as_paid(payloads) + if expenses_to_be_marked: + expense_ids_to_mark = [expense.id for expense in expenses_to_be_marked] + Expense.objects.filter(id__in=expense_ids_to_mark).update(paid_on_fyle=True) + except Exception as error: + error = traceback.format_exc() + error = { + 'error': error + } + logger.exception(error) def async_sync_accounts(workspace_id):