From 6c9e6b1abc51330ed452e3acfd1bc36e58ce1f83 Mon Sep 17 00:00:00 2001 From: Nilesh Pant Date: Thu, 30 Nov 2023 11:53:14 +0530 Subject: [PATCH] use transaction date for lineitem too --- apps/qbd/models.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/qbd/models.py b/apps/qbd/models.py index 59c4711..09429ea 100644 --- a/apps/qbd/models.py +++ b/apps/qbd/models.py @@ -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 @@ -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, @@ -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: @@ -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,