Skip to content

Commit

Permalink
Merge branch 'release-0.2.0' into LCFS-1426-UploadFileAttachements-Co…
Browse files Browse the repository at this point in the history
…mplianceReports
  • Loading branch information
prv-proton authored Dec 19, 2024
2 parents 4b89511 + 2dca338 commit 275e8e1
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 61 deletions.
18 changes: 11 additions & 7 deletions backend/lcfs/web/api/fuel_supply/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)
Expand All @@ -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())
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand Down Expand Up @@ -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 (
Expand Down
21 changes: 15 additions & 6 deletions frontend/src/views/ComplianceReports/components/ReportDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ const ReportDetails = ({ currentStatus = 'Draft', isAnalystRole }) => {
),
useFetch: useGetFuelSupplies,
component: (data) =>
data.fuelSupplies.length > 0 && <FuelSupplySummary data={data} />
data.fuelSupplies.length > 0 && (
<FuelSupplySummary status={currentStatus} data={data} />
)
},
{
name: t('finalSupplyEquipment:fseTitle'),
Expand All @@ -113,7 +115,7 @@ const ReportDetails = ({ currentStatus = 'Draft', isAnalystRole }) => {
useFetch: useGetFinalSupplyEquipments,
component: (data) =>
data.finalSupplyEquipments.length > 0 && (
<FinalSupplyEquipmentSummary data={data} />
<FinalSupplyEquipmentSummary status={currentStatus} data={data} />
)
},
{
Expand All @@ -128,7 +130,7 @@ const ReportDetails = ({ currentStatus = 'Draft', isAnalystRole }) => {
useFetch: useGetAllocationAgreements,
component: (data) =>
data.allocationAgreements.length > 0 && (
<AllocationAgreementSummary data={data} />
<AllocationAgreementSummary status={currentStatus} data={data} />
)
},
{
Expand All @@ -142,7 +144,9 @@ const ReportDetails = ({ currentStatus = 'Draft', isAnalystRole }) => {
),
useFetch: useGetAllNotionalTransfers,
component: (data) =>
data.length > 0 && <NotionalTransferSummary data={data} />
data.length > 0 && (
<NotionalTransferSummary status={currentStatus} data={data} />
)
},
{
name: t('otherUses:summaryTitle'),
Expand All @@ -154,7 +158,10 @@ const ReportDetails = ({ currentStatus = 'Draft', isAnalystRole }) => {
).replace(':complianceReportId', complianceReportId)
),
useFetch: useGetAllOtherUses,
component: (data) => data.length > 0 && <OtherUsesSummary data={data} />
component: (data) =>
data.length > 0 && (
<OtherUsesSummary status={currentStatus} data={data} />
)
},
{
name: t('fuelExport:fuelExportTitle'),
Expand All @@ -167,7 +174,9 @@ const ReportDetails = ({ currentStatus = 'Draft', isAnalystRole }) => {
),
useFetch: useGetFuelExports,
component: (data) =>
!isArrayEmpty(data) && <FuelExportSummary data={data} />
!isArrayEmpty(data) && (
<FuelExportSummary status={currentStatus} data={data} />
)
}
],
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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 (
Expand Down
19 changes: 11 additions & 8 deletions frontend/src/views/FuelExports/FuelExportSummary.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 (
Expand Down
19 changes: 11 additions & 8 deletions frontend/src/views/FuelSupplies/FuelSupplySummary.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand Down Expand Up @@ -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 (
Expand Down
20 changes: 11 additions & 9 deletions frontend/src/views/NotionalTransfers/NotionalTransferSummary.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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 = [
Expand Down
19 changes: 11 additions & 8 deletions frontend/src/views/OtherUses/OtherUsesSummary.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down Expand Up @@ -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 (
Expand Down

0 comments on commit 275e8e1

Please sign in to comment.