Skip to content

Commit

Permalink
Adding condition to skip already complete expenses
Browse files Browse the repository at this point in the history
  • Loading branch information
Shwetabhk committed Oct 10, 2023
1 parent 5db7efe commit bb7e07c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
21 changes: 11 additions & 10 deletions apps/fyle/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
8 changes: 7 additions & 1 deletion apps/quickbooks_online/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down

0 comments on commit bb7e07c

Please sign in to comment.