Skip to content

Commit

Permalink
ccc mapping commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Fyle authored and Fyle committed Sep 20, 2023
1 parent cb23615 commit ec53609
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
4 changes: 3 additions & 1 deletion apps/qbd/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
11 changes: 10 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
)
10 changes: 10 additions & 0 deletions tests/test_qbd/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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')

Expand Down

0 comments on commit ec53609

Please sign in to comment.