Skip to content

Commit

Permalink
use transaction date for lineitem too
Browse files Browse the repository at this point in the history
  • Loading branch information
NileshPant1999 committed Nov 30, 2023
1 parent 1999027 commit 6c9e6b1
Showing 1 changed file with 4 additions and 3 deletions.
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

0 comments on commit 6c9e6b1

Please sign in to comment.