Skip to content

Commit

Permalink
refactor: enhance emission summary response and undo form changes
Browse files Browse the repository at this point in the history
  • Loading branch information
acatchpole committed Jan 20, 2025
1 parent 0f73794 commit b0c8d9c
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 56 deletions.
8 changes: 2 additions & 6 deletions bc_obps/reporting/api/emission_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ def get_emission_category(request: HttpRequest) -> Tuple[int, List[EmissionCateg
auth=authorize("approved_authorized_roles"),
)
@handle_http_errors()
def get_emission_summary_totals(
request: HttpRequest, version_id: int, facility_id: UUID
) -> Tuple[int, EmissionSummarySchemaOut]:
def get_emission_summary_totals(request: HttpRequest, version_id: int, facility_id: UUID) -> Tuple[int, dict]:
facility_report_id = FacilityReport.objects.get(report_version_id=version_id, facility_id=facility_id).pk
return 200, EmissionCategoryService.get_facility_emission_summary_form_data(facility_report_id)

Expand All @@ -46,7 +44,5 @@ def get_emission_summary_totals(
auth=authorize("approved_authorized_roles"),
)
@handle_http_errors()
def get_operation_emission_summary_totals(
request: HttpRequest, version_id: int
) -> Tuple[int, EmissionSummarySchemaOut]:
def get_operation_emission_summary_totals(request: HttpRequest, version_id: int) -> Tuple[int, dict]:
return 200, EmissionCategoryService.get_operation_emission_summary_form_data(version_id)
24 changes: 24 additions & 0 deletions bc_obps/reporting/schema/emission_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,27 @@ class EmissionSummarySchemaOut(Schema):
emission_categories: BasicEmissionCategoriesSchema
fuel_excluded: FuelExcludedEmissionCategoriesSchema
other_excluded: OtherExcludedEmissionCategoriesSchema


{
'attributable_for_reporting': Decimal('33330.0000'),
'attributable_for_reporting_threshold': Decimal('31108.0000'),
'reporting_only_emission': Decimal('2222.0000'),
'emission_categories': {
'flaring': Decimal('0'),
'fugitive': Decimal('0'),
'industrial_process': Decimal('0'),
'onsite_transportation': Decimal('0'),
'stationary_combustion': Decimal('31108.0000'),
'venting_useful': Decimal('0'),
'venting_non_useful': Decimal('0'),
'waste': Decimal('2222.0000'),
'wastewater': Decimal('0'),
},
'fuel_excluded': {
'woody_biomass': Decimal('2222.0000'),
'excluded_biomass': Decimal('0'),
'excluded_non_biomass': Decimal('0'),
},
'other_excluded': {'lfo_excluded': Decimal('0'), 'fog_excluded': 0},
}
4 changes: 1 addition & 3 deletions bc_obps/reporting/service/emission_category_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,7 @@ def get_all_category_totals_by_version(version_id: int) -> Dict[str, Decimal | i
}

@classmethod
def transform_category_totals_to_summary_form_data(
cls, emission_totals: Dict[str, Decimal | int]
) -> dict:
def transform_category_totals_to_summary_form_data(cls, emission_totals: Dict[str, Decimal | int]) -> dict:
return {
'attributable_for_reporting': emission_totals['attributable_for_reporting'],
'attributable_for_reporting_threshold': emission_totals['attributable_for_threshold'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
import ReportingStepButtons from "@bciers/components/form/components/ReportingStepButtons";
import { multiStepHeaderSteps } from "../../taskList/multiStepHeaderConfig";
import { EmissionSummaryFormData } from "@reporting/src/app/utils/emissionSummaryTypes";
import MultiStepFormWithTaskList from "@bciers/components/form/MultiStepFormWithTaskList";

interface Props {
versionId: number;
Expand All @@ -33,53 +32,35 @@ const OperationEmissionSummary: React.FC<Props> = ({
const continueRef = `/reports/${versionId}/compliance-summary`;
const additionalReportingStepIndex = 2;

const handleSubmit = async (): Promise<boolean> => {
// This function does nothing and resolves to true
return true;
};

return (
<MultiStepFormWithTaskList
initialStep={additionalReportingStepIndex}
steps={multiStepHeaderSteps}
taskListElements={taskListElements}
backUrl={backRef}
continueUrl={continueRef}
formData={summaryFormData}
schema={operationEmissionSummarySchema}
uiSchema={emissionSummaryUiSchema}
submitButtonDisabled={false}
saveButtonDisabled={true}
onSubmit={handleSubmit}
/>
// <Box sx={{ p: 3 }}>
// <div
// className="container mx-auto p-4"
// data-testid="operation-emission-summary"
// >
// <MultiStepHeader
// stepIndex={additionalReportingStepIndex}
// steps={multiStepHeaderSteps}
// />
// </div>
// <div className="w-full flex">
// <ReportingTaskList elements={taskListElements} />
// <div className="w-full md:max-w-[60%]">
// <FormBase
// schema={operationEmissionSummarySchema}
// uiSchema={emissionSummaryUiSchema}
// formData={summaryFormData}
// >
// <ReportingStepButtons
// backUrl={backRef}
// continueUrl={continueRef}
// saveButtonDisabled={true}
// submitButtonDisabled={false}
// />
// </FormBase>
// </div>
// </div>
// </Box>
<Box sx={{ p: 3 }}>
<div
className="container mx-auto p-4"
data-testid="operation-emission-summary"
>
<MultiStepHeader
stepIndex={additionalReportingStepIndex}
steps={multiStepHeaderSteps}
/>
</div>
<div className="w-full flex">
<ReportingTaskList elements={taskListElements} />
<div className="w-full md:max-w-[60%]">
<FormBase
schema={operationEmissionSummarySchema}
uiSchema={emissionSummaryUiSchema}
formData={summaryFormData}
>
<ReportingStepButtons
backUrl={backRef}
continueUrl={continueRef}
saveButtonDisabled={true}
submitButtonDisabled={false}
/>
</FormBase>
</div>
</div>
</Box>
);
};

Expand Down

0 comments on commit b0c8d9c

Please sign in to comment.