From 0946f65c10b3bcf92f141205f4996922ffbe3772 Mon Sep 17 00:00:00 2001 From: ruuushhh <66899387+ruuushhh@users.noreply.github.com> Date: Thu, 10 Oct 2024 13:26:40 +0530 Subject: [PATCH] fix: expense group creation (#653) Co-authored-by: GitHub Actions --- apps/fyle/tasks.py | 7 +++++-- apps/workspaces/tasks.py | 8 ++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/apps/fyle/tasks.py b/apps/fyle/tasks.py index b60c600d..b957be4d 100644 --- a/apps/fyle/tasks.py +++ b/apps/fyle/tasks.py @@ -45,8 +45,11 @@ def get_task_log_and_fund_source(workspace_id: int): ) configuration = Configuration.objects.get(workspace_id=workspace_id) - fund_source = ['PERSONAL'] - if configuration.corporate_credit_card_expenses_object is not None: + fund_source = [] + + if configuration.reimbursable_expenses_object: + fund_source.append('PERSONAL') + if configuration.corporate_credit_card_expenses_object: fund_source.append('CCC') return task_log, fund_source, configuration diff --git a/apps/workspaces/tasks.py b/apps/workspaces/tasks.py index 83f963cd..c891fea9 100644 --- a/apps/workspaces/tasks.py +++ b/apps/workspaces/tasks.py @@ -104,10 +104,14 @@ def run_sync_schedule(workspace_id): ) configuration = Configuration.objects.get(workspace_id=workspace_id) - fund_source = ['PERSONAL'] + fund_source = [] + + if configuration.reimbursable_expenses_object: + fund_source.append('PERSONAL') if configuration.corporate_credit_card_expenses_object: fund_source.append('CCC') - if configuration.reimbursable_expenses_object: + + if configuration.reimbursable_expenses_object or configuration.corporate_credit_card_expenses_object: create_expense_groups( workspace_id=workspace_id, configuration=configuration, fund_source=fund_source, task_log=task_log )