From 09adf8d7779fbaa167110feb3e89e2b7e8809f5e Mon Sep 17 00:00:00 2001 From: Hamed Valiollahi Date: Mon, 24 Feb 2025 07:06:40 -0800 Subject: [PATCH] fix: include missing transactions in export and add Compliance Report transactions --- backend/lcfs/utils/constants.py | 2 ++ backend/lcfs/web/api/transaction/services.py | 19 +++++++------------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/backend/lcfs/utils/constants.py b/backend/lcfs/utils/constants.py index e499a5423..be64b4152 100644 --- a/backend/lcfs/utils/constants.py +++ b/backend/lcfs/utils/constants.py @@ -78,12 +78,14 @@ class FILE_MEDIA_TYPE(Enum): "Transfer": "CT", "AdminAdjustment": "AA", "InitiativeAgreement": "IA", + "ComplianceReport": "CR", } id_prefix_to_transaction_type_map = { "CT": "Transfer", "AA": "AdminAdjustment", "IA": "InitiativeAgreement", + "CR": "ComplianceReport", } default_ci = {"Gasoline": 93.67, "Diesel": 100.21, "Jet fuel": 88.83} diff --git a/backend/lcfs/web/api/transaction/services.py b/backend/lcfs/web/api/transaction/services.py index d8952f476..d548a6829 100644 --- a/backend/lcfs/web/api/transaction/services.py +++ b/backend/lcfs/web/api/transaction/services.py @@ -88,15 +88,15 @@ def apply_transaction_filters(self, pagination, conditions): # check if the date string is selected for filter if filter.filter is None: filter_value = [ - datetime.strptime(filter.date_from, "%Y-%m-%d %H:%M:%S").strftime( - "%Y-%m-%d" - ) + datetime.strptime( + filter.date_from, "%Y-%m-%d %H:%M:%S" + ).strftime("%Y-%m-%d") ] if filter.date_to: filter_value.append( - datetime.strptime(filter.date_to, "%Y-%m-%d %H:%M:%S").strftime( - "%Y-%m-%d" - ) + datetime.strptime( + filter.date_to, "%Y-%m-%d %H:%M:%S" + ).strftime("%Y-%m-%d") ) if filter.field == "status": field = cast( @@ -189,12 +189,7 @@ async def export_transactions( results = await self.repo.get_transactions_paginated( 0, None, - [ - or_( - TransactionView.status == "Approved", - TransactionView.status == "Recorded", - ) - ], + [TransactionView.status != "Deleted"], [], organization_id, )