From e553d1f543c1325dfb9ba16427b996d3d616cda6 Mon Sep 17 00:00:00 2001 From: Ashutosh singh <55102089+Ashutosh619-sudo@users.noreply.github.com> Date: Fri, 21 Jun 2024 12:47:39 +0530 Subject: [PATCH] Bug Fix for reports to be marked paid (#603) --- apps/netsuite/tasks.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/apps/netsuite/tasks.py b/apps/netsuite/tasks.py index 60a7e942..279b95f8 100644 --- a/apps/netsuite/tasks.py +++ b/apps/netsuite/tasks.py @@ -1353,18 +1353,19 @@ def process_reimbursements(workspace_id): if all_expense_paid: 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) - try: - platform.reports.bulk_mark_as_paid(payloads) - except Exception as error: - error = traceback.format_exc() - error = { - 'error': error - } - logger.exception(error) - 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 schedule_reimbursements_sync(sync_netsuite_to_fyle_payments, workspace_id): if sync_netsuite_to_fyle_payments: