Skip to content

Commit

Permalink
Merge pull request #1658 from bcgov/LCFS-1207-AddFuelCodeCIColumnsFue…
Browse files Browse the repository at this point in the history
…lsOtherUse_v2

LCFS-1659: Incorrect fuel type list in Fuels for other use
  • Loading branch information
areyeslo authored Jan 16, 2025
2 parents e783917 + e73dba9 commit 3ac4f0f
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
"""Update other_uses_fossil_derived in fuel_type
Revision ID: fe03799b4018
Revises: fa98709e7952
Create Date: 2025-01-14 18:12:43.683691
"""

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "fe03799b4018"
down_revision = "5163af6ba4a4"
branch_labels = None
depends_on = None


def upgrade() -> None:
# Set other_uses_fossil_derived to false
op.execute("""
UPDATE fuel_type
SET other_uses_fossil_derived = false
WHERE fuel_type IN (
'CNG', 'Electricity', 'Hydrogen', 'LNG', 'Propane',
'Natural gas-based gasoline', 'Petroleum-based diesel',
'Petroleum-based gasoline'
)
""")

# Set other_uses_fossil_derived to true
op.execute("""
UPDATE fuel_type
SET other_uses_fossil_derived = true
WHERE fuel_type IN (
'Alternative jet fuel', 'Biodiesel', 'Ethanol', 'HDRD',
'Other diesel fuel', 'Renewable gasoline', 'Renewable naphtha'
)
""")

def downgrade() -> None:
# Revert `other_uses_fossil_derived` to original values for false
op.execute("""
UPDATE fuel_type
SET other_uses_fossil_derived = true
WHERE fuel_type IN (
'CNG', 'Electricity', 'Hydrogen', 'LNG', 'Propane',
'Natural gas-based gasoline', 'Petroleum-based diesel',
'Petroleum-based gasoline'
)
""")

# Revert `other_uses_fossil_derived` to original values for true
op.execute("""
UPDATE fuel_type
SET other_uses_fossil_derived = false
WHERE fuel_type IN (
'Alternative jet fuel', 'Biodiesel', 'Ethanol', 'HDRD',
'Other diesel fuel', 'Renewable gasoline', 'Renewable naphtha'
)
""")
1 change: 1 addition & 0 deletions backend/lcfs/web/api/other_uses/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ async def get_formatted_fuel_types(
joinedload(FuelType.provision_1),
joinedload(FuelType.provision_2),
)
.order_by(FuelType.fuel_type)
)

result = await self.db.execute(query)
Expand Down
9 changes: 9 additions & 0 deletions frontend/src/views/OtherUses/AddEditOtherUses.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,15 @@ export const AddEditOtherUses = () => {

params.node.setDataValue('fuelCategory', categoryValue)

// Auto populate the "provisionOfTheAct" field
const provisions = fuelType.provisionOfTheAct.map(
(provision) => provision.name
)

const provisionValue =
provisions.length === 1 ? provisions[0] : null
params.node.setDataValue('provisionOfTheAct', provisionValue)

// Auto-populate the "fuelCode" field
const fuelCodeOptions = fuelType.fuelCodes.map(
(code) => code.fuelCode
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/OtherUses/OtherUsesSummary.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const OtherUsesSummary = ({ data, status }) => {
minWidth: 200
},
{
headerName: t('otherUses:otherUsesColLabels.rationale'),
headerName: t('otherUses:otherUsesColLabels.otherExpectedUse'),
field: 'rationale',
floatingFilter: false,
flex: 1,
Expand Down

0 comments on commit 3ac4f0f

Please sign in to comment.