Skip to content

issue-483 add utilityCategory to assessment, form, report #492

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

Merged
merged 1 commit into from
May 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/app/indexed-db/update-db-entries.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ export class UpdateDbEntriesService {
// need recalculate uses and costs
let facility: IdbFacility = facilities.find(_facility => { return _facility.guid == assessment.facilityId });
let company: IdbCompany = companies.find(_company => { return _company.guid == facility.companyId });
// previously assessment is limited to one utility type
// legacy assessment is limited to one utility type
// 1. update utility types
assessment.utilityTypes = AssessmentOptions.find(_option =>
{ return _option.assessmentType == assessment.assessmentType })?.utilityTypes || [];
Expand All @@ -284,7 +284,27 @@ export class UpdateDbEntriesService {
let utilityEnergyUse: UtilityEnergyUse = assessment.utilityEnergyUses.find(_energyUse =>
{ return _energyUse.utilityType == assessment.utilityType });
utilityEnergyUse.utilitySaving = assessment.energySavings;
if (assessment.utilityType == 'Water' || assessment.utilityType == 'Waste Water') {
assessment.utilityCategory = 'water';
} else {
assessment.utilityCategory = 'energy';
}
assessment.utilityType = undefined;
} else {
// update the utility category if none is set
if (assessment.utilityCategory == undefined) {
assessment.utilityCategory = 'energy';
for (const utilityType of assessment.utilityTypes) {
if (utilityType == 'Water' || utilityType == 'Waste Water') {
let use = assessment.utilityEnergyUses.find(_energyUse =>
{ return _energyUse.utilityType == utilityType });
if (use && use.include) {
assessment.utilityCategory = 'water';
break;
}
}
}
}
}
// update the use, cost, and savings
assessment = updateAssessmentUtilityUseCostSavings(assessment, facility.unitSettings, company.companyEnergyUnit);
Expand Down
2 changes: 2 additions & 0 deletions src/app/models/assessment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface IdbAssessment extends IdbEntry {
implementationCost: number,
sidebarOpen: boolean,
isUtilityCostUpdated: boolean,
utilityCategory?: 'energy' | 'water',
}

const defaultAssessmentType: AssessmentType = "Pump";
Expand Down Expand Up @@ -63,5 +64,6 @@ export function getNewIdbAssessment(userId: string, companyId: string, facilityI
implementationCost: 0,
sidebarOpen: false,
isUtilityCostUpdated: true,
utilityCategory: 'energy',
}
}
15 changes: 14 additions & 1 deletion src/app/shared/reports/calculations/assessmentReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,17 @@ export function getAssessmentReport(
implementationCost += assessment.implementationCost;
}

// update utilityCategory based on assessment and EEMs
let utilityCategory: string = assessment.utilityCategory;
if (utilityCategory == 'energy') {
for (const report of energyOpportunityReports) {
if (report.energyOpportunity.utilityCategory == 'water') {
utilityCategory = 'water';
break;
}
};
}

let totalPaybackWithNebs: number = (implementationCost / totalFinancialImpact);
if (totalPaybackWithNebs == Infinity) {
totalPaybackWithNebs = 0;
Expand Down Expand Up @@ -169,7 +180,8 @@ export function getAssessmentReport(
nonOpportunityPaybackWithoutNebs: nonOpportunityPaybackWithoutNebs,
nonOpportunityPaybackWithNebs: nonOpportunityPaybackWithNebs,
allNebReports: allNebReports,
keyPerformanceIndicatorReport: getKeyPerformanceIndicatorReport(allNebReports)
keyPerformanceIndicatorReport: getKeyPerformanceIndicatorReport(allNebReports),
utilityCategory: utilityCategory,
}
}

Expand All @@ -194,6 +206,7 @@ export interface AssessmentReport {
nonOpportunityPaybackWithoutNebs: number,
nonOpportunityPaybackWithNebs: number,
keyPerformanceIndicatorReport: KeyPerformanceIndicatorReport,
utilityCategory?: string,
}


Expand Down
13 changes: 10 additions & 3 deletions src/app/shared/reports/calculations/executiveSummaryReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import { getKeyPerformanceIndicatorReport, KeyPerformanceIndicatorReport } from
import { NebReport } from "./nebReport";
import { IdbKeyPerformanceIndicator } from "src/app/models/keyPerformanceIndicator";

//IF no report is passed as a parameter
//All data (assessments/opps/nebs) included
// If no report is passed as a parameter, all data (assessments/EEMs/NEBs) included
export function getExecutiveSummaryReport(visitDate: Date, assessmentIds: Array<string>, assessments: Array<IdbAssessment>,
energyOpportunities: Array<IdbEnergyOpportunity>,
nonEnergyBenefits: Array<IdbNonEnergyBenefit>,
Expand Down Expand Up @@ -86,6 +85,11 @@ export function getExecutiveSummaryReport(visitDate: Date, assessmentIds: Array<
});
return totalNebFinancialImpact;
});
// update utility category
let utilityCategory: string = "energy"; // Default to "energy"
if (assessmentReports.some(report => report.assessment.utilityCategory === "water")) {
utilityCategory = "water";
}
let totalPaybackWithoutNebs: number = (totalImplementationCost / totalNonNebCostSavings);
if (totalPaybackWithoutNebs == Infinity || isNaN(totalPaybackWithoutNebs)) {
totalPaybackWithoutNebs = 0;
Expand All @@ -109,7 +113,9 @@ export function getExecutiveSummaryReport(visitDate: Date, assessmentIds: Array<
totalPaybackWithoutNebs: totalPaybackWithoutNebs,
totalPaybackWithNebs: totalPaybackWithNebs,
totalUtilityCosts: totalUtilityCosts,
totalUtilityCostSavings: totalUtilityCostSavings,};
totalUtilityCostSavings: totalUtilityCostSavings,
utilityCategory: utilityCategory
};
}
export interface ExecutiveSummaryReport {
visitDate: Date;
Expand All @@ -126,4 +132,5 @@ export interface ExecutiveSummaryReport {
totalPaybackWithNebs: number;
totalUtilityCosts: number;
totalUtilityCostSavings: number;
utilityCategory?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ <h5 class="mt-2">Annual Key Performance Indicator Impacts</h5>
</tr>
<tr>
<td class="ps-2">
Utilities
{{ executiveSummaryReport.utilityCategory == 'energy' ? 'Energy' : 'Utilities' }}
</td>
<td class="text-right">
<app-single-cell-item [isCurrency]="true" [numValue]="executiveSummaryReport.totalUtilityCostSavings">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ <h5 class="mt-2">Project Summary</h5>
<tr>
<th rowspan="2"></th>
<th></th>
<th colspan="2">Utility Savings</th>
<th colspan="2">
{{ executiveSummaryReport.utilityCategory == 'energy'? 'Energy' : 'Utility' }} Savings
</th>
<th></th>
<th colspan="2">Including NEBs</th>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,24 @@ export class AssessmentDetailsFormComponent {
let utilityTypes = AssessmentOptions.find(
_assessmentOption => _assessmentOption.assessmentType == this.assessment.assessmentType)?.utilityTypes || [];
this.assessment.utilityTypes = utilityTypes; // track all utility types
this.updateAssessmentUtilityCategory();
await this.calculateUtilityUseCostSavings();
}

updateAssessmentUtilityCategory() {
this.assessment.utilityCategory = 'energy';
for (let utilityType of this.assessment.utilityTypes) {
if (utilityType == 'Water' || utilityType == 'Waste Water') {
let use = this.assessment.utilityEnergyUses.find(
_energyUse => _energyUse.utilityType == utilityType);
if (use && use.include) {
this.assessment.utilityCategory = 'water';
break;
}
}
}
}

updateEnergyOpportunities() {
this.assessmentEnergyOpportunities = this.energyOpportunityIdbService.getByOtherGuid(
this.assessment.guid, 'assessment');
Expand Down
Loading