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

use transaction date for line item too #68

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Changes from all 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
7 changes: 4 additions & 3 deletions apps/qbd/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def get_transaction_date(expenses: List[Expense], date_preference: str) -> str:

elif date_preference == 'spent_at':
return expenses[0].spent_at

elif date_preference == 'posted_at' and expenses[0].posted_at != None:
return expenses[0].posted_at

Expand Down Expand Up @@ -291,7 +291,7 @@ def create_bill_lineitems(expenses: List[Expense], bill: Bill, workspace_id: int

lineitem = BillLineitem.objects.create(
transaction_type='BILL',
date=expense.spent_at,
date=get_transaction_date(expenses, export_settings.reimbursable_expense_date),
account=export_settings.mileage_account_name if expense.category == 'Mileage' and \
export_settings.mileage_account_name else expense.category,
name=project_name,
Expand Down Expand Up @@ -681,6 +681,7 @@ def create_journal_lineitems(
:return: None
"""
field_mappings: FieldMapping = FieldMapping.objects.get(workspace_id=workspace_id)
date_preference = export_settings.credit_card_expense_date if fund_source == 'CCC' else export_settings.reimbursable_expense_date

lineitems = []
for expense in expenses:
Expand All @@ -690,7 +691,7 @@ def create_journal_lineitems(

lineitem = JournalLineitem.objects.create(
transaction_type='GENERAL JOURNAL',
date=expense.spent_at,
date=get_transaction_date(expenses, date_preference),
account=export_settings.mileage_account_name if fund_source != 'CCC' and expense.category == 'Mileage' \
and export_settings.mileage_account_name else expense.category,
name=journal.name,
Expand Down
Loading