Skip to content

Commit

Permalink
Fix misc vendor creation incase of no merchant selected (#332)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwin1111 authored Sep 27, 2022
1 parent edb1ea9 commit b248292
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions apps/quickbooks_online/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ def resolve_errors_for_exported_expense_group(expense_group: ExpenseGroup):
is_resolved=False
).update(is_resolved=True)

def get_or_create_misc_vendor(debit_card_expense: bool, qbo_connection: QBOConnector):
if debit_card_expense:
vendor = qbo_connection.get_or_create_vendor('Debit Card Misc', create=True)
else:
vendor = qbo_connection.get_or_create_vendor('Credit Card Misc', create=True)

return vendor

def get_or_create_credit_card_or_debit_card_vendor(workspace_id: int, merchant: str, debit_card_expense: bool, general_settings: WorkspaceGeneralSettings):
"""
Expand All @@ -85,10 +92,10 @@ def get_or_create_credit_card_or_debit_card_vendor(workspace_id: int, merchant:
except WrongParamsError as bad_request:
logger.error(bad_request.response)
if not vendor:
if debit_card_expense:
vendor = qbo_connection.get_or_create_vendor('Debit Card Misc', create=True)
else:
vendor = qbo_connection.get_or_create_vendor('Credit Card Misc', create=True)
vendor = get_or_create_misc_vendor(debit_card_expense, qbo_connection)

else:
vendor = get_or_create_misc_vendor(debit_card_expense, qbo_connection)

return vendor

Expand Down

0 comments on commit b248292

Please sign in to comment.