diff --git a/backend/lcfs/web/api/fuel_supply/repo.py b/backend/lcfs/web/api/fuel_supply/repo.py
index 77a8c3852..dca195539 100644
--- a/backend/lcfs/web/api/fuel_supply/repo.py
+++ b/backend/lcfs/web/api/fuel_supply/repo.py
@@ -443,20 +443,23 @@ async def get_effective_fuel_supplies(
query = (
select(FuelSupply)
.options(
- # Use joinedload for scalar relationships
- joinedload(FuelSupply.fuel_code).options(
- joinedload(FuelCode.fuel_code_status),
- joinedload(FuelCode.fuel_code_prefix),
+ # Use selectinload for collections
+ selectinload(FuelSupply.fuel_code).options(
+ selectinload(FuelCode.fuel_code_status),
+ selectinload(FuelCode.fuel_code_prefix),
),
- joinedload(FuelSupply.fuel_category).options(
- joinedload(FuelCategory.target_carbon_intensities),
- joinedload(FuelCategory.energy_effectiveness_ratio),
+ # Use selectinload for one-to-many relationships
+ selectinload(FuelSupply.fuel_category).options(
+ selectinload(FuelCategory.target_carbon_intensities),
+ selectinload(FuelCategory.energy_effectiveness_ratio),
),
+ # Use joinedload for many-to-one relationships
joinedload(FuelSupply.fuel_type).options(
joinedload(FuelType.energy_density),
joinedload(FuelType.additional_carbon_intensity),
joinedload(FuelType.energy_effectiveness_ratio),
),
+ # Use joinedload for single relationships
joinedload(FuelSupply.provision_of_the_act),
selectinload(FuelSupply.end_use_type),
)
@@ -467,6 +470,7 @@ async def get_effective_fuel_supplies(
FuelSupply.version == valid_fuel_supplies_subq.c.max_version,
user_type_priority == valid_fuel_supplies_subq.c.max_role_priority,
),
+ isouter=False # Explicit inner join
)
.order_by(FuelSupply.create_date.asc())
)
diff --git a/frontend/src/views/AllocationAgreements/AllocationAgreementSummary.jsx b/frontend/src/views/AllocationAgreements/AllocationAgreementSummary.jsx
index 30b1a9f02..70a536d18 100644
--- a/frontend/src/views/AllocationAgreements/AllocationAgreementSummary.jsx
+++ b/frontend/src/views/AllocationAgreements/AllocationAgreementSummary.jsx
@@ -8,8 +8,9 @@ import { useEffect, useMemo, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { useLocation, useParams, useNavigate } from 'react-router-dom'
import { v4 as uuid } from 'uuid'
+import { COMPLIANCE_REPORT_STATUSES } from '@/constants/statuses.js'
-export const AllocationAgreementSummary = ({ data }) => {
+export const AllocationAgreementSummary = ({ data, status }) => {
const [alertMessage, setAlertMessage] = useState('')
const [alertSeverity, setAlertSeverity] = useState('info')
const [gridKey, setGridKey] = useState(`allocation-agreements-grid`)
@@ -137,12 +138,14 @@ export const AllocationAgreementSummary = ({ data }) => {
}
const handleRowClicked = (params) => {
- navigate(
- ROUTES.REPORTS_ADD_ALLOCATION_AGREEMENTS.replace(
- ':compliancePeriod',
- compliancePeriod
- ).replace(':complianceReportId', complianceReportId)
- )
+ if (status === COMPLIANCE_REPORT_STATUSES.DRAFT) {
+ navigate(
+ ROUTES.REPORTS_ADD_ALLOCATION_AGREEMENTS.replace(
+ ':compliancePeriod',
+ compliancePeriod
+ ).replace(':complianceReportId', complianceReportId)
+ )
+ }
}
return (
diff --git a/frontend/src/views/ComplianceReports/components/ReportDetails.jsx b/frontend/src/views/ComplianceReports/components/ReportDetails.jsx
index 02edbe97d..f14545f29 100644
--- a/frontend/src/views/ComplianceReports/components/ReportDetails.jsx
+++ b/frontend/src/views/ComplianceReports/components/ReportDetails.jsx
@@ -99,7 +99,9 @@ const ReportDetails = ({ currentStatus = 'Draft', isAnalystRole }) => {
),
useFetch: useGetFuelSupplies,
component: (data) =>
- data.fuelSupplies.length > 0 &&
+ data.fuelSupplies.length > 0 && (
+
+ )
},
{
name: t('finalSupplyEquipment:fseTitle'),
@@ -113,7 +115,7 @@ const ReportDetails = ({ currentStatus = 'Draft', isAnalystRole }) => {
useFetch: useGetFinalSupplyEquipments,
component: (data) =>
data.finalSupplyEquipments.length > 0 && (
-
+
)
},
{
@@ -128,7 +130,7 @@ const ReportDetails = ({ currentStatus = 'Draft', isAnalystRole }) => {
useFetch: useGetAllocationAgreements,
component: (data) =>
data.allocationAgreements.length > 0 && (
-
+
)
},
{
@@ -142,7 +144,9 @@ const ReportDetails = ({ currentStatus = 'Draft', isAnalystRole }) => {
),
useFetch: useGetAllNotionalTransfers,
component: (data) =>
- data.length > 0 &&
+ data.length > 0 && (
+
+ )
},
{
name: t('otherUses:summaryTitle'),
@@ -154,7 +158,10 @@ const ReportDetails = ({ currentStatus = 'Draft', isAnalystRole }) => {
).replace(':complianceReportId', complianceReportId)
),
useFetch: useGetAllOtherUses,
- component: (data) => data.length > 0 &&
+ component: (data) =>
+ data.length > 0 && (
+
+ )
},
{
name: t('fuelExport:fuelExportTitle'),
@@ -167,7 +174,9 @@ const ReportDetails = ({ currentStatus = 'Draft', isAnalystRole }) => {
),
useFetch: useGetFuelExports,
component: (data) =>
- !isArrayEmpty(data) &&
+ !isArrayEmpty(data) && (
+
+ )
}
],
[
diff --git a/frontend/src/views/FinalSupplyEquipments/FinalSupplyEquipmentSummary.jsx b/frontend/src/views/FinalSupplyEquipments/FinalSupplyEquipmentSummary.jsx
index 1869f3c63..a8c7935a1 100644
--- a/frontend/src/views/FinalSupplyEquipments/FinalSupplyEquipmentSummary.jsx
+++ b/frontend/src/views/FinalSupplyEquipments/FinalSupplyEquipmentSummary.jsx
@@ -9,8 +9,9 @@ import { useTranslation } from 'react-i18next'
import { useLocation, useParams, useNavigate } from 'react-router-dom'
import { v4 as uuid } from 'uuid'
import { numberFormatter } from '@/utils/formatters.js'
+import { COMPLIANCE_REPORT_STATUSES } from '@/constants/statuses.js'
-export const FinalSupplyEquipmentSummary = ({ data }) => {
+export const FinalSupplyEquipmentSummary = ({ data, status }) => {
const [alertMessage, setAlertMessage] = useState('')
const [alertSeverity, setAlertSeverity] = useState('info')
const [gridKey, setGridKey] = useState('final-supply-equipments-grid')
@@ -187,13 +188,15 @@ export const FinalSupplyEquipmentSummary = ({ data }) => {
setGridKey(`final-supply-equipments-grid-${uuid()}`)
}
- const handleRowClicked = (params) => {
- navigate(
- ROUTES.REPORTS_ADD_FINAL_SUPPLY_EQUIPMENTS.replace(
- ':compliancePeriod',
- compliancePeriod
- ).replace(':complianceReportId', complianceReportId)
- )
+ const handleRowClicked = () => {
+ if (status === COMPLIANCE_REPORT_STATUSES.DRAFT) {
+ navigate(
+ ROUTES.REPORTS_ADD_FINAL_SUPPLY_EQUIPMENTS.replace(
+ ':compliancePeriod',
+ compliancePeriod
+ ).replace(':complianceReportId', complianceReportId)
+ )
+ }
}
return (
diff --git a/frontend/src/views/FuelExports/FuelExportSummary.jsx b/frontend/src/views/FuelExports/FuelExportSummary.jsx
index 4cab9c377..76898317f 100644
--- a/frontend/src/views/FuelExports/FuelExportSummary.jsx
+++ b/frontend/src/views/FuelExports/FuelExportSummary.jsx
@@ -9,8 +9,9 @@ import { useTranslation } from 'react-i18next'
import { useLocation, useParams, useNavigate } from 'react-router-dom'
import i18n from '@/i18n'
import { ROUTES } from '@/constants/routes'
+import { COMPLIANCE_REPORT_STATUSES } from '@/constants/statuses.js'
-export const FuelExportSummary = ({ data }) => {
+export const FuelExportSummary = ({ data, status }) => {
const [alertMessage, setAlertMessage] = useState('')
const [alertSeverity, setAlertSeverity] = useState('info')
const { complianceReportId, compliancePeriod } = useParams()
@@ -124,13 +125,15 @@ export const FuelExportSummary = ({ data }) => {
return params.data.fuelExportId.toString()
}
- const handleRowClicked = (params) => {
- navigate(
- ROUTES.REPORTS_ADD_FUEL_EXPORTS.replace(
- ':compliancePeriod',
- compliancePeriod
- ).replace(':complianceReportId', complianceReportId)
- )
+ const handleRowClicked = () => {
+ if (status === COMPLIANCE_REPORT_STATUSES.DRAFT) {
+ navigate(
+ ROUTES.REPORTS_ADD_FUEL_EXPORTS.replace(
+ ':compliancePeriod',
+ compliancePeriod
+ ).replace(':complianceReportId', complianceReportId)
+ )
+ }
}
return (
diff --git a/frontend/src/views/FuelSupplies/FuelSupplySummary.jsx b/frontend/src/views/FuelSupplies/FuelSupplySummary.jsx
index 2e913d8dd..6944b0383 100644
--- a/frontend/src/views/FuelSupplies/FuelSupplySummary.jsx
+++ b/frontend/src/views/FuelSupplies/FuelSupplySummary.jsx
@@ -10,8 +10,9 @@ import { useLocation, useNavigate, useParams } from 'react-router-dom'
import { v4 as uuid } from 'uuid'
import i18n from '@/i18n'
import { StandardCellWarningAndErrors } from '@/utils/grid/errorRenderers'
+import { COMPLIANCE_REPORT_STATUSES } from '@/constants/statuses.js'
-export const FuelSupplySummary = ({ data }) => {
+export const FuelSupplySummary = ({ data, status }) => {
const [alertMessage, setAlertMessage] = useState('')
const [alertSeverity, setAlertSeverity] = useState('info')
const [gridKey, setGridKey] = useState(`fuel-supplies-grid`)
@@ -126,13 +127,15 @@ export const FuelSupplySummary = ({ data }) => {
setGridKey(`fuel-supplies-grid-${uuid()}`)
}
- const handleRowClicked = (params) => {
- navigate(
- ROUTES.REPORTS_ADD_SUPPLY_OF_FUEL.replace(
- ':compliancePeriod',
- compliancePeriod
- ).replace(':complianceReportId', complianceReportId)
- )
+ const handleRowClicked = () => {
+ if (status === COMPLIANCE_REPORT_STATUSES.DRAFT) {
+ navigate(
+ ROUTES.REPORTS_ADD_SUPPLY_OF_FUEL.replace(
+ ':compliancePeriod',
+ compliancePeriod
+ ).replace(':complianceReportId', complianceReportId)
+ )
+ }
}
return (
diff --git a/frontend/src/views/NotionalTransfers/NotionalTransferSummary.jsx b/frontend/src/views/NotionalTransfers/NotionalTransferSummary.jsx
index e93d2502f..daa71fae1 100644
--- a/frontend/src/views/NotionalTransfers/NotionalTransferSummary.jsx
+++ b/frontend/src/views/NotionalTransfers/NotionalTransferSummary.jsx
@@ -8,8 +8,9 @@ import { useTranslation } from 'react-i18next'
import { useLocation, useParams, useNavigate } from 'react-router-dom'
import { formatNumberWithCommas as valueFormatter } from '@/utils/formatters'
import { ROUTES } from '@/constants/routes'
+import { COMPLIANCE_REPORT_STATUSES } from '@/constants/statuses.js'
-export const NotionalTransferSummary = ({ data }) => {
+export const NotionalTransferSummary = ({ data, status }) => {
const [alertMessage, setAlertMessage] = useState('')
const [alertSeverity, setAlertSeverity] = useState('info')
const { complianceReportId, compliancePeriod } = useParams()
@@ -34,14 +35,15 @@ export const NotionalTransferSummary = ({ data }) => {
[]
)
- const handleRowClicked = (params) => {
- console.log('Row clicked', params)
- navigate(
- ROUTES.REPORTS_ADD_NOTIONAL_TRANSFERS.replace(
- ':compliancePeriod',
- compliancePeriod
- ).replace(':complianceReportId', complianceReportId)
- )
+ const handleRowClicked = () => {
+ if (status === COMPLIANCE_REPORT_STATUSES.DRAFT) {
+ navigate(
+ ROUTES.REPORTS_ADD_NOTIONAL_TRANSFERS.replace(
+ ':compliancePeriod',
+ compliancePeriod
+ ).replace(':complianceReportId', complianceReportId)
+ )
+ }
}
const columns = [
diff --git a/frontend/src/views/OtherUses/OtherUsesSummary.jsx b/frontend/src/views/OtherUses/OtherUsesSummary.jsx
index 797ff8476..4c6a203ed 100644
--- a/frontend/src/views/OtherUses/OtherUsesSummary.jsx
+++ b/frontend/src/views/OtherUses/OtherUsesSummary.jsx
@@ -11,8 +11,9 @@ import {
} from '@/utils/formatters'
import { useTranslation } from 'react-i18next'
import { ROUTES } from '@/constants/routes'
+import { COMPLIANCE_REPORT_STATUSES } from '@/constants/statuses.js'
-export const OtherUsesSummary = ({ data }) => {
+export const OtherUsesSummary = ({ data, status }) => {
const [alertMessage, setAlertMessage] = useState('')
const [alertSeverity, setAlertSeverity] = useState('info')
const { t } = useTranslation(['common', 'otherUses'])
@@ -86,13 +87,15 @@ export const OtherUsesSummary = ({ data }) => {
const getRowId = (params) => params.data.otherUsesId
- const handleRowClicked = (params) => {
- navigate(
- ROUTES.REPORTS_ADD_OTHER_USE_FUELS.replace(
- ':compliancePeriod',
- compliancePeriod
- ).replace(':complianceReportId', complianceReportId)
- )
+ const handleRowClicked = () => {
+ if (status === COMPLIANCE_REPORT_STATUSES.DRAFT) {
+ navigate(
+ ROUTES.REPORTS_ADD_OTHER_USE_FUELS.replace(
+ ':compliancePeriod',
+ compliancePeriod
+ ).replace(':complianceReportId', complianceReportId)
+ )
+ }
}
return (