diff --git a/apps/qbd/models.py b/apps/qbd/models.py index 4b09c8c..e430128 100644 --- a/apps/qbd/models.py +++ b/apps/qbd/models.py @@ -598,13 +598,15 @@ def create_journal( date_preference = export_settings.credit_card_expense_date + corporate_card_name = get_corporate_card_name(expenses[0].corporate_card_id, workspace_id, export_settings) + default_memo = f'Credit Card Expenses by {expenses[0].employee_email}' \ if fund_source == 'CCC' else f'Reimbursable Expenses by {expenses[0].employee_email}' journal = Journal.objects.create( transaction_type='GENERAL JOURNAL', date=get_transaction_date(expenses, date_preference=date_preference), - account=export_settings.credit_card_account_name if fund_source == 'CCC' else export_settings.bank_account_name, + account=corporate_card_name if fund_source == 'CCC' else export_settings.bank_account_name, name=name, amount=sum([expense.amount for expense in expenses]), memo=get_top_purpose( diff --git a/tests/conftest.py b/tests/conftest.py index 814e651..940837c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -281,4 +281,13 @@ def add_ccc_mapping(): mappings = mapping_fixtures['create_qbd_mapping'] for workspace_id in [1, 2, 3]: - QBDMapping.update_or_create_mapping_objects(mappings, workspace_id) + for mapping in mappings: + QBDMapping.objects.update_or_create( + workspace_id= workspace_id, + source_value= mapping['value'], + attribute_type= mapping['attribute_type'], + defaults={ + 'source_id': mapping['source_id'], + 'destination_value': 'mastercard' if mapping['value'] == 'American Express - 055470' else None + } + ) diff --git a/tests/test_qbd/test_tasks.py b/tests/test_qbd/test_tasks.py index 86342ab..a0dd25c 100644 --- a/tests/test_qbd/test_tasks.py +++ b/tests/test_qbd/test_tasks.py @@ -361,6 +361,11 @@ def test_create_credit_card_purchases_iif_file_expense_employee( workspace_id=workspace_id, type='EXPORT_CREDIT_CARD_PURCHASES', status='ENQUEUED' ) + expense = Expense.objects.filter(workspace_id=workspace_id, exported=False).first() + + expense.corporate_card_id = 'bacc1DHywC3YAd' + expense.save() + create_credit_card_purchases_iif_file(workspace_id, accounting_export) expenses = Expense.objects.filter(workspace_id=workspace_id, exported=False) @@ -648,6 +653,11 @@ def test_create_journals_iif_file_ccc_report_employee( workspace_id=workspace_id, type='EXPORT_JOURNALS', status='ENQUEUED' ) + expense = Expense.objects.filter(workspace_id=workspace_id, exported=False).first() + + expense.corporate_card_id = 'bacc1DHywC3YAd' + expense.save() + # Testing for entity preference as Vendor create_journals_iif_file(workspace_id, accounting_export, 'CCC')