diff --git a/backend/export/property_scenarios/db_functions.py b/backend/export/property_scenarios/db_functions.py index 8b29ab0e..a27806c2 100644 --- a/backend/export/property_scenarios/db_functions.py +++ b/backend/export/property_scenarios/db_functions.py @@ -150,6 +150,7 @@ class DbMethods: self.session.query( Recommendation, PlanModel.scenario_id, + PlanModel.name ) .join( PlanRecommendations, @@ -171,6 +172,7 @@ class DbMethods: for col in Recommendation.__table__.columns }, "scenario_id": r.scenario_id, + "plan_name": r.name, } for r in recs_query ] diff --git a/backend/export/property_scenarios/main.py b/backend/export/property_scenarios/main.py index d2d89916..56886a8b 100644 --- a/backend/export/property_scenarios/main.py +++ b/backend/export/property_scenarios/main.py @@ -59,17 +59,17 @@ def process_export(payload: ExportRequest, session: Session) -> Dict[Union[str, continue measures_df: pd.DataFrame = scenario_recs[ - ["property_id", "measure_type", "estimated_cost"] + ["property_id", "measure_type", "plan_name", "estimated_cost"] ].drop_duplicates() pivot = measures_df.pivot( - index="property_id", + index=["property_id", "plan_name"], columns="measure_type", values="estimated_cost", ).reset_index() pivot["total_retrofit_cost"] = ( - pivot.drop(columns=["property_id"]).sum(axis=1) + pivot.drop(columns=["property_id", "plan_name"]).sum(axis=1) ) post_sap = (