diff --git a/apps/fyle/actions.py b/apps/fyle/actions.py index 2f778110..dc7014ef 100644 --- a/apps/fyle/actions.py +++ b/apps/fyle/actions.py @@ -102,18 +102,19 @@ def update_expenses_in_progress(in_progress_expenses: List[Expense]) -> None: """ expense_to_be_updated = [] for expense in in_progress_expenses: - expense_to_be_updated.append( - Expense( - id=expense.id, - accounting_export_summary=get_updated_accounting_export_summary( - expense.expense_id, - 'IN_PROGRESS', - None, - '{}/workspaces/main/dashboard'.format(settings.QBO_INTEGRATION_APP_URL), - False + if expense.accounting_export_summary.get('state') != 'COMPLETE': + expense_to_be_updated.append( + Expense( + id=expense.id, + accounting_export_summary=get_updated_accounting_export_summary( + expense.expense_id, + 'IN_PROGRESS', + None, + '{}/workspaces/main/dashboard'.format(settings.QBO_INTEGRATION_APP_URL), + False + ) ) ) - ) __bulk_update_expenses(expense_to_be_updated) diff --git a/apps/quickbooks_online/queue.py b/apps/quickbooks_online/queue.py index db65214a..fcdf50e5 100644 --- a/apps/quickbooks_online/queue.py +++ b/apps/quickbooks_online/queue.py @@ -22,7 +22,13 @@ def schedule_bills_creation(workspace_id: int, expense_group_ids: List[str], is_ :return: None """ if expense_group_ids: - expense_groups = ExpenseGroup.objects.filter(Q(tasklog__id__isnull=True) | ~Q(tasklog__status__in=['IN_PROGRESS', 'COMPLETE']), workspace_id=workspace_id, id__in=expense_group_ids, bill__id__isnull=True, exported_at__isnull=True).all() + expense_groups = ExpenseGroup.objects.filter( + Q(tasklog__id__isnull=True) | ~Q(tasklog__status__in=['IN_PROGRESS', 'COMPLETE']), + workspace_id=workspace_id, + id__in=expense_group_ids, + bill__id__isnull=True, + exported_at__isnull=True + ).all() chain_tasks = [] in_progress_expenses = []