Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix duplicated expense_groups #653

Merged
merged 3 commits into from
Jul 23, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 36 additions & 34 deletions apps/fyle/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ def create_expense_groups_by_report_id_fund_source(
"""

expense_groups = []
filtered_corporate_credit_card_expense_groups = []
expense_group_settings = ExpenseGroupSettings.objects.get(
workspace_id=workspace_id
)
Expand Down Expand Up @@ -440,44 +441,45 @@ def create_expense_groups_by_report_id_fund_source(
filter(lambda expense: expense.fund_source == "CCC", expense_objects)
)

if (
general_settings.corporate_credit_card_expenses_object == 'CREDIT CARD PURCHASE' and
expense_group_settings.split_expense_grouping == 'MULTIPLE_LINE_ITEM'
):
ccc_expenses_without_bank_transaction = [
expense for expense in expense_objects
if not expense.bank_transaction_id
]

ccc_expenses_with_bank_transaction = [
expense for expense in expense_objects
if expense.bank_transaction_id
]

filtered_corporate_credit_card_expense_groups = _group_expenses(
ccc_expenses_without_bank_transaction,
corporate_credit_card_expense_group_field,
workspace_id,
)
if corporate_credit_card_expenses:
Hrishabh17 marked this conversation as resolved.
Show resolved Hide resolved
if (
general_settings.corporate_credit_card_expenses_object == 'CREDIT CARD PURCHASE' and
expense_group_settings.split_expense_grouping == 'MULTIPLE_LINE_ITEM'
):
ccc_expenses_without_bank_transaction = [
expense for expense in corporate_credit_card_expenses
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed expense_objects to corporate_credit_card_expenses

if not expense.bank_transaction_id
]

ccc_expenses_with_bank_transaction = [
expense for expense in corporate_credit_card_expenses
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here as well

if expense.bank_transaction_id
]

filtered_corporate_credit_card_expense_groups = _group_expenses(
ccc_expenses_without_bank_transaction,
corporate_credit_card_expense_group_field,
workspace_id,
)

corporate_credit_card_expense_group_field = [
field for field in corporate_credit_card_expense_group_field
if field not in {'expense_number', 'expense_id'}
]
corporate_credit_card_expense_group_field.append('bank_transaction_id')
filtered_corporate_credit_card_expense_groups.extend(
_group_expenses(
ccc_expenses_with_bank_transaction,
corporate_credit_card_expense_group_field = [
field for field in corporate_credit_card_expense_group_field
if field not in {'expense_number', 'expense_id'}
]
corporate_credit_card_expense_group_field.append('bank_transaction_id')
filtered_corporate_credit_card_expense_groups.extend(
_group_expenses(
ccc_expenses_with_bank_transaction,
corporate_credit_card_expense_group_field,
workspace_id,
)
)
else:
filtered_corporate_credit_card_expense_groups = _group_expenses(
corporate_credit_card_expenses,
corporate_credit_card_expense_group_field,
workspace_id,
)
)
else:
filtered_corporate_credit_card_expense_groups = _group_expenses(
corporate_credit_card_expenses,
corporate_credit_card_expense_group_field,
workspace_id,
)

if (
general_settings.corporate_credit_card_expenses_object == "BILL"
Expand Down
Loading