diff --git a/src/app/setup-wizard/pre-visit/pre-assessment-setup/pre-assessment-setup.service.ts b/src/app/setup-wizard/pre-visit/pre-assessment-setup/pre-assessment-setup.service.ts index c0db1c6e..97d3a8cb 100644 --- a/src/app/setup-wizard/pre-visit/pre-assessment-setup/pre-assessment-setup.service.ts +++ b/src/app/setup-wizard/pre-visit/pre-assessment-setup/pre-assessment-setup.service.ts @@ -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, diff --git a/src/app/shared/shared-assessment-forms/assessment-details-form/assessment-details-form.component.html b/src/app/shared/shared-assessment-forms/assessment-details-form/assessment-details-form.component.html index ad8e0b2a..b5fed9a6 100644 --- a/src/app/shared/shared-assessment-forms/assessment-details-form/assessment-details-form.component.html +++ b/src/app/shared/shared-assessment-forms/assessment-details-form/assessment-details-form.component.html @@ -89,6 +89,19 @@
Utility Types
+ +
+
+ This utility is not tracked under current facility. + To track this utility, please go to + + Page. +
+
+

@@ -141,7 +154,7 @@
Utility Types
-
diff --git a/src/app/shared/shared-assessment-forms/assessment-details-form/assessment-details-form.component.spec.ts b/src/app/shared/shared-assessment-forms/assessment-details-form/assessment-details-form.component.spec.ts index 32c6491f..88137be6 100644 --- a/src/app/shared/shared-assessment-forms/assessment-details-form/assessment-details-form.component.spec.ts +++ b/src/app/shared/shared-assessment-forms/assessment-details-form/assessment-details-form.component.spec.ts @@ -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; @@ -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(); diff --git a/src/app/shared/shared-assessment-forms/assessment-details-form/assessment-details-form.component.ts b/src/app/shared/shared-assessment-forms/assessment-details-form/assessment-details-form.component.ts index e0ed1aec..11a721cb 100644 --- a/src/app/shared/shared-assessment-forms/assessment-details-form/assessment-details-form.component.ts +++ b/src/app/shared/shared-assessment-forms/assessment-details-form/assessment-details-form.component.ts @@ -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'; @@ -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', @@ -33,6 +36,7 @@ export class AssessmentDetailsFormComponent { faPeopleGroup: IconDefinition = faPeopleGroup; faUser: IconDefinition = faUser; faContactBook: IconDefinition = faContactBook; + faIndustry: IconDefinition = faIndustry; assessment: IdbAssessment; assessmentSub: Subscription; @@ -67,6 +71,8 @@ export class AssessmentDetailsFormComponent { private facilityIdbService: FacilityIdbService, private energyOpportunityIdbService: EnergyOpportunityIdbService, private assessmentEnergyOpportunitiesFormService: AssessmentEnergyOpportunitiesFormService, + private onSiteVisitIdbService: OnSiteVisitIdbService, + private router: Router, ) { } @@ -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, @@ -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'); + } } diff --git a/src/app/shared/shared-assessment-forms/energy-opportunity-setup-form/energy-opportunity-setup-form.component.ts b/src/app/shared/shared-assessment-forms/energy-opportunity-setup-form/energy-opportunity-setup-form.component.ts index 35e6c4a6..f5aee49b 100644 --- a/src/app/shared/shared-assessment-forms/energy-opportunity-setup-form/energy-opportunity-setup-form.component.ts +++ b/src/app/shared/shared-assessment-forms/energy-opportunity-setup-form/energy-opportunity-setup-form.component.ts @@ -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(); }