Skip to content

Commit

Permalink
Merge pull request #341 from NREL/issue-328
Browse files Browse the repository at this point in the history
Issue 328 - assessment annual energy saving unit and round to energy oppo cost saving
  • Loading branch information
RLiNREL authored Dec 2, 2024
2 parents ee02464 + bddd8f9 commit 5b4dda0
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class PreAssessmentSetupService {
let selectedUnitOption = selectedUtilityOption.energyUnitOptions.find(
_unitOption => _unitOption.value == utilityEnergyUse.energyUnit);
if (selectedUtilityOption.isStandardEnergyUnit
&& selectedUnitOption.isStandard !== false) {
&& selectedUnitOption?.isStandard !== false) {
convertedCost = this.convertValue.convertValue(
utilityEnergyUse.energyUse / (facilityUnitSettings[`${camelCaseType}HHV`]),
utilityEnergyUse.energyUnit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,19 @@ <h6>Utility Types</h6>
</div>
</div>
</ng-container>
<ng-container *ngIf="use.include && !isUtilityTracked(use.utilityType)">
<div class="col-12">
<div class="alert alert-warning small m-0 ms-5 p-1">
This utility is not tracked under current facility.
To track this utility, please go to
<button class="btn btn-sm btn-outline-primary border-0 p-0 mb-1" (click)="goToFacilitySetup()">
<fa-icon [icon]="faIndustry"></fa-icon>
Facility Setup
</button>
Page.
</div>
</div>
</ng-container>
</div>
</ng-container>
<hr>
Expand Down Expand Up @@ -141,7 +154,7 @@ <h6>Utility Types</h6>
<div class="input-group">
<input name="energySavings" type="number" class="form-control" [(ngModel)]="assessment.energySavings"
(input)="saveChanges()" id="energySavings" [disabled]="isDisabled">
<span *ngIf="numberOfTrackedUtilities !== 1" class="input-group-text" [innerHTML]="numberOfTrackedUtilities === 1?
<span class="input-group-text" [innerHTML]="numberOfTrackedUtilities === 1?
(trackedEnergyUnit | unitsDisplay) + '/yr': (companyEnergyUnit | unitsDisplay) + '/yr'"></span>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { getDefaultUnitSettings } from 'src/app/models/unitSettings';
import { CompanyIdbService } from 'src/app/indexed-db/company-idb.service';
import { IdbCompany } from 'src/app/models/company';
import { EnergyOpportunityIdbService } from 'src/app/indexed-db/energy-opportunity-idb.service';
import { stubServiceProviders } from 'src/app/spec-helpers/spec-test-service-stub';

describe('AssessmentDetailsFormComponent', () => {
let component: AssessmentDetailsFormComponent;
Expand Down Expand Up @@ -50,15 +51,7 @@ describe('AssessmentDetailsFormComponent', () => {
await TestBed.configureTestingModule({
imports: [FontAwesomeModule, FormsModule, RouterTestingModule, HelperPipesModule],
declarations: [AssessmentDetailsFormComponent],
providers: [
{ provide: FacilityIdbService, useValue: facilityIdbService },
{ provide: AssessmentIdbService, useValue: assessmentIdbService },
{ provide: SetupWizardService, useValue: setupWizardService },
{ provide: ContactIdbService, useValue: contactIdbService },
{ provide: EnergyEquipmentIdbService, useValue: energyEquipmentIdbService },
{ provide: CompanyIdbService, useValue: companyIdbService },
{ provide: EnergyOpportunityIdbService, useValue: energyOpportunityIdbService }
]
providers: stubServiceProviders
})
.compileComponents();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { IdbAssessment } from 'src/app/models/assessment';
import { Subscription } from 'rxjs';
import { AssessmentIdbService } from 'src/app/indexed-db/assessment-idb.service';
import { IdbContact } from 'src/app/models/contact';
import { IconDefinition, faContactBook, faPeopleGroup, faUser } from '@fortawesome/free-solid-svg-icons';
import { IconDefinition, faContactBook, faPeopleGroup, faUser, faIndustry } from '@fortawesome/free-solid-svg-icons';
import { ContactIdbService } from 'src/app/indexed-db/contact-idb.service';
import { SetupWizardService } from 'src/app/setup-wizard/setup-wizard.service';
import { IdbEnergyEquipment } from 'src/app/models/energyEquipment';
Expand All @@ -20,6 +20,9 @@ import { IdbEnergyOpportunity } from 'src/app/models/energyOpportunity';
import { EnergyOpportunityIdbService } from 'src/app/indexed-db/energy-opportunity-idb.service';
import { AssessmentEnergyOpportunitiesFormService } from '../../../setup-wizard/data-collection/on-site-assessment/assessment-energy-opportunities-form/assessment-energy-opportunities-form.service';
import { SharedDataService } from '../../shared-services/shared-data.service';
import { Router } from '@angular/router';
import { OnSiteVisitIdbService } from 'src/app/indexed-db/on-site-visit-idb.service';
import { IdbOnSiteVisit } from 'src/app/models/onSiteVisit';

@Component({
selector: 'app-assessment-details-form',
Expand All @@ -33,6 +36,7 @@ export class AssessmentDetailsFormComponent {
faPeopleGroup: IconDefinition = faPeopleGroup;
faUser: IconDefinition = faUser;
faContactBook: IconDefinition = faContactBook;
faIndustry: IconDefinition = faIndustry;

assessment: IdbAssessment;
assessmentSub: Subscription;
Expand Down Expand Up @@ -67,6 +71,8 @@ export class AssessmentDetailsFormComponent {
private facilityIdbService: FacilityIdbService,
private energyOpportunityIdbService: EnergyOpportunityIdbService,
private assessmentEnergyOpportunitiesFormService: AssessmentEnergyOpportunitiesFormService,
private onSiteVisitIdbService: OnSiteVisitIdbService,
private router: Router,

) { }

Expand Down Expand Up @@ -136,7 +142,7 @@ export class AssessmentDetailsFormComponent {
_unitOption => _unitOption.value == utilityEnergyUse.energyUnit);
// calculate use
if (selectedUtilityOption.isStandardEnergyUnit
&& selectedUnitOption.isStandard !== false) {
&& selectedUnitOption?.isStandard !== false) {
convertedUse = this.convertValue.convertValue(
utilityEnergyUse.energyUse,
utilityEnergyUse.energyUnit,
Expand Down Expand Up @@ -175,4 +181,14 @@ export class AssessmentDetailsFormComponent {
});

}

isUtilityTracked(utilityType: string): boolean {
let trimmed = utilityType.replace(/\s+/g, '');
return this.facilityUnitSettings[`include${trimmed}`];
}

goToFacilitySetup() {
let onsiteVisit: IdbOnSiteVisit = this.onSiteVisitIdbService.selectedVisit.getValue();
this.router.navigateByUrl('/setup-wizard/pre-visit/' + onsiteVisit.guid + '/facility-setup');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,11 @@ export class EnergyOpportunitySetupFormComponent {
let trimmedType = this.energyOpportunity.utilityType.replace(/\s+/g, '');
let camelCaseType = trimmedType.charAt(0).toLowerCase() + trimmedType.slice(1);
if (this.facilityUnitSettings[`include${trimmedType}`]) {
this.energyOpportunity.costSavings = this.convertValue.convertValue(
let costSavings = this.convertValue.convertValue(
this.energyOpportunity.energySavings * this.facilityUnitSettings[`${camelCaseType}Price`],
this.energyOpportunity.energyUnit,
this.facilityUnitSettings[`${camelCaseType}Unit`]).convertedValue;
this.energyOpportunity.costSavings = parseFloat(costSavings.toFixed(0));
}
await this.saveEnergyOpportunity();
}
Expand Down

0 comments on commit 5b4dda0

Please sign in to comment.