-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LCFS-1207: Adding new columns to Other Use #1269
base: release-0.2.0
Are you sure you want to change the base?
Conversation
d78f715
to
714de3f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests needs to be fixed
85c1f6e
to
22d783f
Compare
Tests passing :) |
22d783f
to
1d5a193
Compare
@@ -136,9 +136,27 @@ async def test_save_other_uses_row_create( | |||
) as mock_validate_organization_access: | |||
set_mock_user(fastapi_app, [RoleEnum.SUPPLIER]) | |||
url = fastapi_app.url_path_for("save_other_uses_row") | |||
payload = create_mock_schema({}).model_dump() | |||
payload = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you moving away from the create_mock_schema helper?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
"quantitySupplied": "Quantity supplied", | ||
"addressForService": "Address for service", | ||
"legalName": "Legal name", | ||
"complianceReportId": "Compliance Report ID", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't use title case normally, was this part of the requirements?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
params.colDef.field | ||
) | ||
) { | ||
let ciOfFuel = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put this in a helper function so I can better understand what its trying to do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering the following object:
{
"fuelTypeId": 1,
"fuelType": "Biodiesel",
"fossilDerived": null,
"provision1Id": null,
"provision2Id": null,
"defaultCarbonIntensity": 100.21,
"fuelCodes": [
{
"fuelCodeId": 2,
"fuelCode": "BCLCF124.4",
"carbonIntensity": 3.62
},
{
"fuelCodeId": 3,
"fuelCode": "BCLCF125.4",
"carbonIntensity": -2.14
},
{
"fuelCodeId": 4,
"fuelCode": "BCLCF138.5",
"carbonIntensity": 4.26
},
{
"fuelCodeId": 6,
"fuelCode": "BCLCF251.2",
"carbonIntensity": 0.35
},
{
"fuelCodeId": 8,
"fuelCode": "BCLCF274.2",
"carbonIntensity": -15.03
},
{
"fuelCodeId": 15,
"fuelCode": "BCLCF362.1",
"carbonIntensity": -1
}
],
"provisionOfTheAct": [
{
"provisionOfTheActId": 2,
"name": "Fuel code - section 19 (b) (i)"
},
{
"provisionOfTheActId": 3,
"name": "Default carbon intensity - section 19 (b) (ii)"
}
],
"units": "L"
}
We are just checking if provision_of_the_act is 'Fuel code - section 19 (b) (i)', If it is the case, then we find the fuel_code associated to the fuel_type selected and provide the value to ciOfFuel. Otherwise, just take the value from defaultCarbonIntensity in fuel_type. which in this case is 100.21.
@@ -107,6 +107,38 @@ export const AddEditOtherUses = () => { | |||
} | |||
} | |||
|
|||
const onCellValueChanged = useCallback( | |||
async (params) => { | |||
if (params.colDef.field === 'provisionOfTheAct') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this only applies to a single value, it should be in the valueSetter of that column in _schema
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you see this comment?
headerName: t('otherUses:otherUsesColLabels.ciOfFuel'), | ||
field: 'ciOfFuel', | ||
floatingFilter: false, | ||
valueFormatter: (params) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use decimalFormatter instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
dac6903
to
7708949
Compare
@@ -92,7 +98,7 @@ export const otherUsesColDefs = (optionsData, errors) => [ | |||
}, | |||
{ | |||
field: 'fuelCategory', | |||
headerName: i18n.t('otherUses:otherUsesColLabels.fuelCategory'), | |||
headerName: i18n.t('otherUses:otherUsesColLabels.fuelCategory'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spacing
@@ -119,7 +219,8 @@ export const otherUsesColDefs = (optionsData, errors) => [ | |||
min: 0, | |||
showStepperButtons: false | |||
}, | |||
cellStyle: (params) => StandardCellErrors(params, errors) | |||
cellStyle: (params) => StandardCellErrors(params, errors), | |||
minWidth: 200 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spacing
}, | ||
{ | ||
field: 'rationale', | ||
flex: 1, | ||
headerName: i18n.t('otherUses:otherUsesColLabels.otherExpectedUse'), | ||
cellEditor: 'agTextCellEditor', | ||
cellDataType: 'text', | ||
editable: (params) => params.data.expectedUse === 'Other' | ||
editable: (params) => params.data.expectedUse === 'Other', | ||
minWidth: 300 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spacing
@@ -155,15 +291,17 @@ export const otherUsesColDefs = (optionsData, errors) => [ | |||
suppressKeyboardEvent, | |||
cellRenderer: (params) => | |||
params.value || <Typography variant="body4">Select</Typography>, | |||
cellStyle: (params) => StandardCellErrors(params, errors) | |||
cellStyle: (params) => StandardCellErrors(params, errors), | |||
minWidth: 200 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spacing
@@ -107,6 +107,38 @@ export const AddEditOtherUses = () => { | |||
} | |||
} | |||
|
|||
const onCellValueChanged = useCallback( | |||
async (params) => { | |||
if (params.colDef.field === 'provisionOfTheAct') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you see this comment?
@@ -47,6 +47,20 @@ export const AddEditOtherUses = () => { | |||
} | |||
}, [location.state]) | |||
|
|||
// If otherUses data is available, set the rowData | |||
useEffect(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a duplicate of the code below. Why do we need this since its being set in onGridReady?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just for updates. Once the record is saved for first time, there is a race condition that otherUses is not loaded, so I have to wait until the data is available.
@@ -29,21 +43,25 @@ def create_mock_entity(overrides: dict): | |||
|
|||
|
|||
def create_mock_schema(overrides: dict): | |||
mock_schema = OtherUsesCreateSchema( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you moving away from a typed object?
mock_compliance_report_uuid = "mock_group_uuid" | ||
|
||
# Mock the first db.execute call for fetching compliance report group UUID | ||
mock_first_execute = MagicMock() | ||
mock_first_execute.scalar.return_value = mock_compliance_report_uuid | ||
|
||
# Create a realistic mock other_use object | ||
mock_other_use = MagicMock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you not using create_mock_entity?
valueFormatter: (params) => parseFloat(params.value).toFixed(2), | ||
cellStyle: (params) => StandardCellErrors(params, errors), | ||
editable: false, | ||
valueGetter: (params) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is being properly set on the backend, why do we need such a complex getter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because there are dependencies based on the selection of the user. This is related to the comment above:
Considering the following object:
{
"fuelTypeId": 1,
"fuelType": "Biodiesel",
"fossilDerived": null,
"provision1Id": null,
"provision2Id": null,
"defaultCarbonIntensity": 100.21,
"fuelCodes": [
{
"fuelCodeId": 2,
"fuelCode": "BCLCF124.4",
"carbonIntensity": 3.62
},
{
"fuelCodeId": 3,
"fuelCode": "BCLCF125.4",
"carbonIntensity": -2.14
},
{
"fuelCodeId": 4,
"fuelCode": "BCLCF138.5",
"carbonIntensity": 4.26
},
{
"fuelCodeId": 6,
"fuelCode": "BCLCF251.2",
"carbonIntensity": 0.35
},
{
"fuelCodeId": 8,
"fuelCode": "BCLCF274.2",
"carbonIntensity": -15.03
},
{
"fuelCodeId": 15,
"fuelCode": "BCLCF362.1",
"carbonIntensity": -1
}
],
"provisionOfTheAct": [
{
"provisionOfTheActId": 2,
"name": "Fuel code - section 19 (b) (i)"
},
{
"provisionOfTheActId": 3,
"name": "Default carbon intensity - section 19 (b) (ii)"
}
],
"units": "L"
}
We are just checking if provision_of_the_act is 'Fuel code - section 19 (b) (i)', If it is the case, then we find the fuel_code associated to the fuel_type selected and provide the value to ciOfFuel. Otherwise, just take the value from defaultCarbonIntensity in fuel_type. which in this case is 100.21.
a07288a
to
d7abb36
Compare
d7abb36
to
0fb1b0a
Compare
0fb1b0a
to
49d186c
Compare
Add new columns to the Fuels for Other Use AG grid table in the compliance report and Report Details: