diff --git a/src/app/fsat/fsat.service.ts b/src/app/fsat/fsat.service.ts index bed919ca26..10a598b32c 100644 --- a/src/app/fsat/fsat.service.ts +++ b/src/app/fsat/fsat.service.ts @@ -473,6 +473,7 @@ export class FsatService { tmpModification.fsat.whatIfScenario = true; tmpModification.fsat.fsatOperations = fsatCopy.fsatOperations; tmpModification.fsat.fsatOperations.cO2SavingsData = fsatCopy.fsatOperations.cO2SavingsData; + tmpModification.fsat.fsatOperations.cO2SavingsData.userEnteredModificationEmissions = fsatCopy.fsatOperations.cO2SavingsData.userEnteredBaselineEmissions; return tmpModification; } } diff --git a/src/app/phast/add-modification/add-modification.component.ts b/src/app/phast/add-modification/add-modification.component.ts index e908a49fa9..6314815dc2 100644 --- a/src/app/phast/add-modification/add-modification.component.ts +++ b/src/app/phast/add-modification/add-modification.component.ts @@ -20,8 +20,6 @@ export class AddModificationComponent implements OnInit { @Input() modificationExists: boolean; - - newModificationName: string; currentTab: string; tabSubscription: Subscription; @@ -44,7 +42,7 @@ export class AddModificationComponent implements OnInit { addModification() { let exploreOppsDefault: SavingsOpportunity = { hasOpportunity: false, display: '' }; - let tmpModification: Modification = { + let modification: Modification = { phast: { losses: {}, name: this.newModificationName, @@ -85,15 +83,16 @@ export class AddModificationComponent implements OnInit { exploreOppsShowFixtures: exploreOppsDefault, }; if (this.currentTab === 'explore-opportunities') { - tmpModification.exploreOpportunities = true; + modification.exploreOpportunities = true; } if (this.phast.co2SavingsData) { - tmpModification.phast.co2SavingsData = (JSON.parse(JSON.stringify(this.phast.co2SavingsData))); + modification.phast.co2SavingsData = (JSON.parse(JSON.stringify(this.phast.co2SavingsData))); + modification.phast.co2SavingsData.userEnteredModificationEmissions = modification.phast.co2SavingsData.userEnteredBaselineEmissions; } - tmpModification.phast.losses = (JSON.parse(JSON.stringify(this.phast.losses))); - tmpModification.phast.operatingCosts = (JSON.parse(JSON.stringify(this.phast.operatingCosts))); - tmpModification.phast.operatingHours = (JSON.parse(JSON.stringify(this.phast.operatingHours))); - tmpModification.phast.systemEfficiency = (JSON.parse(JSON.stringify(this.phast.systemEfficiency))); - this.save.emit(tmpModification); + modification.phast.losses = (JSON.parse(JSON.stringify(this.phast.losses))); + modification.phast.operatingCosts = (JSON.parse(JSON.stringify(this.phast.operatingCosts))); + modification.phast.operatingHours = (JSON.parse(JSON.stringify(this.phast.operatingHours))); + modification.phast.systemEfficiency = (JSON.parse(JSON.stringify(this.phast.systemEfficiency))); + this.save.emit(modification); } } diff --git a/src/app/phast/modification-list/modification-list.component.ts b/src/app/phast/modification-list/modification-list.component.ts index a3afb6ef92..bbd476fc0a 100644 --- a/src/app/phast/modification-list/modification-list.component.ts +++ b/src/app/phast/modification-list/modification-list.component.ts @@ -184,6 +184,7 @@ export class ModificationListComponent implements OnInit { tmpModification.exploreOpportunities = true; } tmpModification.phast.co2SavingsData = (JSON.parse(JSON.stringify(phast.co2SavingsData))); + tmpModification.phast.co2SavingsData.userEnteredModificationEmissions = tmpModification.phast.co2SavingsData.userEnteredBaselineEmissions; tmpModification.phast.losses = (JSON.parse(JSON.stringify(phast.losses))); tmpModification.phast.operatingCosts = (JSON.parse(JSON.stringify(phast.operatingCosts))); tmpModification.phast.operatingHours = (JSON.parse(JSON.stringify(phast.operatingHours))); diff --git a/src/app/psat/add-modification/add-modification.component.ts b/src/app/psat/add-modification/add-modification.component.ts index 5eb5aab3a8..fb877e5371 100644 --- a/src/app/psat/add-modification/add-modification.component.ts +++ b/src/app/psat/add-modification/add-modification.component.ts @@ -48,7 +48,7 @@ export class AddModificationComponent implements OnInit { } addModification() { - let tmpModification: Modification = { + let modification: Modification = { psat: { name: this.newModificationName, }, @@ -60,13 +60,14 @@ export class AddModificationComponent implements OnInit { systemBasicsNotes: '' }, } - tmpModification.psat.inputs = (JSON.parse(JSON.stringify(this.psat.inputs))); - tmpModification.psat.inputs.pump_style = 11; - tmpModification.psat.inputs.whatIfScenario = this.isWhatIfScenario; - tmpModification.exploreOpportunities = (this.currentTab == 'explore-opportunities'); + modification.psat.inputs = (JSON.parse(JSON.stringify(this.psat.inputs))); + modification.psat.inputs.co2SavingsData.userEnteredModificationEmissions = modification.psat.inputs.co2SavingsData.userEnteredBaselineEmissions; + modification.psat.inputs.pump_style = 11; + modification.psat.inputs.whatIfScenario = this.isWhatIfScenario; + modification.exploreOpportunities = (this.currentTab == 'explore-opportunities'); let baselineResults: PsatOutputs = this.psatService.resultsExisting(this.psat.inputs, this.settings); - tmpModification.psat.inputs.pump_specified = baselineResults.pump_efficiency; - this.save.emit(tmpModification) + modification.psat.inputs.pump_specified = baselineResults.pump_efficiency; + this.save.emit(modification) } saveScenarioChange(isNewModWhatIfScenario: boolean){ diff --git a/src/app/psat/modification-list/modification-list.component.ts b/src/app/psat/modification-list/modification-list.component.ts index cbcea41aa8..1db4ce9476 100644 --- a/src/app/psat/modification-list/modification-list.component.ts +++ b/src/app/psat/modification-list/modification-list.component.ts @@ -160,6 +160,7 @@ export class ModificationListComponent implements OnInit { tmpModification.exploreOpportunities = true; } tmpModification.psat.inputs = (JSON.parse(JSON.stringify(psat.inputs))); + tmpModification.psat.inputs.co2SavingsData.userEnteredModificationEmissions = tmpModification.psat.inputs.co2SavingsData.userEnteredModificationEmissions; let baselineResults: PsatOutputs = this.psatService.resultsExisting(this.psat.inputs, this.settings); tmpModification.psat.inputs.pump_specified = baselineResults.pump_efficiency; tmpModification.psat.inputs.whatIfScenario = true; diff --git a/src/app/psat/psat.component.ts b/src/app/psat/psat.component.ts index a735b6c5c3..dd2e58dffa 100644 --- a/src/app/psat/psat.component.ts +++ b/src/app/psat/psat.component.ts @@ -435,7 +435,7 @@ export class PsatComponent implements OnInit { addNewMod() { let modName: string = 'Scenario ' + (this._psat.modifications.length + 1); - let tmpModification: Modification = { + let modification: Modification = { psat: { name: modName, }, @@ -448,12 +448,13 @@ export class PsatComponent implements OnInit { }, exploreOpportunities: this.currentTab == 'explore-opportunities' } - tmpModification.psat.inputs = (JSON.parse(JSON.stringify(this._psat.inputs))); - tmpModification.psat.inputs.pump_style = 11; - tmpModification.psat.inputs.whatIfScenario = true; + modification.psat.inputs = (JSON.parse(JSON.stringify(this._psat.inputs))); + modification.psat.inputs.co2SavingsData.userEnteredModificationEmissions = modification.psat.inputs.co2SavingsData.userEnteredBaselineEmissions; + modification.psat.inputs.pump_style = 11; + modification.psat.inputs.whatIfScenario = true; let baselineResults: PsatOutputs = this.psatService.resultsExisting(this._psat.inputs, this.settings); - tmpModification.psat.inputs.pump_specified = baselineResults.pump_efficiency; - this.saveNewMod(tmpModification) + modification.psat.inputs.pump_specified = baselineResults.pump_efficiency; + this.saveNewMod(modification) } async addSettings(settings: Settings) { diff --git a/src/app/shared/assessment-co2-savings/assessment-co2-savings.component.ts b/src/app/shared/assessment-co2-savings/assessment-co2-savings.component.ts index 65fb9798d9..a23be087a3 100644 --- a/src/app/shared/assessment-co2-savings/assessment-co2-savings.component.ts +++ b/src/app/shared/assessment-co2-savings/assessment-co2-savings.component.ts @@ -194,7 +194,6 @@ export class AssessmentCo2SavingsComponent implements OnInit { } setModificationSubregionForm() { - // set selected baseline subregion value this.form.controls.eGridSubregion.patchValue(this.co2SavingsData.eGridSubregion); this.hasValidSubRegion = true; this.setSubregionControlStatus(); diff --git a/src/app/ssmt/add-modification/add-modification.component.ts b/src/app/ssmt/add-modification/add-modification.component.ts index 1775b89fa1..40a6f92f54 100644 --- a/src/app/ssmt/add-modification/add-modification.component.ts +++ b/src/app/ssmt/add-modification/add-modification.component.ts @@ -41,17 +41,18 @@ export class AddModificationComponent implements OnInit { addModification() { let ssmtCopy: SSMT = (JSON.parse(JSON.stringify(this.ssmt))); delete ssmtCopy.modifications; - let tmpModification: Modification = { + let modification: Modification = { ssmt: ssmtCopy, exploreOpportunities: (this.assessmentTab === 'explore-opportunities') }; - tmpModification.ssmt.name = this.newModificationName; - if (tmpModification.ssmt.headerInput.lowPressureHeader) { - tmpModification.ssmt.headerInput.lowPressureHeader.useBaselineProcessSteamUsage = true; + modification.ssmt.co2SavingsData.userEnteredModificationEmissions = modification.ssmt.co2SavingsData.userEnteredBaselineEmissions; + modification.ssmt.name = this.newModificationName; + if (modification.ssmt.headerInput.lowPressureHeader) { + modification.ssmt.headerInput.lowPressureHeader.useBaselineProcessSteamUsage = true; } - if (tmpModification.ssmt.headerInput.mediumPressureHeader) { - tmpModification.ssmt.headerInput.mediumPressureHeader.useBaselineProcessSteamUsage = true; + if (modification.ssmt.headerInput.mediumPressureHeader) { + modification.ssmt.headerInput.mediumPressureHeader.useBaselineProcessSteamUsage = true; } - this.save.emit(tmpModification); + this.save.emit(modification); } } diff --git a/src/app/ssmt/modification-list/modification-list.component.ts b/src/app/ssmt/modification-list/modification-list.component.ts index 644c7cb573..378b8d604d 100644 --- a/src/app/ssmt/modification-list/modification-list.component.ts +++ b/src/app/ssmt/modification-list/modification-list.component.ts @@ -136,6 +136,7 @@ export class ModificationListComponent implements OnInit { let ssmtCopy: SSMT = (JSON.parse(JSON.stringify(ssmt))); delete ssmtCopy.modifications; ssmtCopy.name = this.newModificationName; + if (ssmtCopy.headerInput.lowPressureHeader) { ssmtCopy.headerInput.lowPressureHeader.useBaselineProcessSteamUsage = true; } @@ -146,6 +147,8 @@ export class ModificationListComponent implements OnInit { ssmt: ssmtCopy, exploreOpportunities: (this.assessmentTab === 'explore-opportunities') }; + + tmpModification.ssmt.co2SavingsData.userEnteredModificationEmissions = tmpModification.ssmt.co2SavingsData.userEnteredBaselineEmissions; this.dropdown.push(false); this.rename.push(false); this.deleteArr.push(false); diff --git a/src/app/ssmt/operations/operations.component.ts b/src/app/ssmt/operations/operations.component.ts index 53c91c16a7..4ab0c7a0d0 100644 --- a/src/app/ssmt/operations/operations.component.ts +++ b/src/app/ssmt/operations/operations.component.ts @@ -118,9 +118,11 @@ export class OperationsComponent implements OnInit { this.co2SavingsData.zipcode = co2SavingsData.zipcode, this.save(); } - + setCo2SavingsData() { - let co2SavingsData: Co2SavingsData = this.ssmt.co2SavingsData; + // todo 6993 - simplify duplicated co2SavingsData objects + let co2SavingsData: Co2SavingsData = copyObject(this.ssmt.co2SavingsData); + // todo weird if (this.ssmt.co2SavingsData) { this.co2SavingsData = co2SavingsData; } else { @@ -139,7 +141,6 @@ export class OperationsComponent implements OnInit { } this.setEnergySource(shouldSetOutputRate); } - canCompare() { if (this.compareService.baselineSSMT && this.compareService.modifiedSSMT && !this.inSetup) { return true; diff --git a/src/app/ssmt/ssmt.component.ts b/src/app/ssmt/ssmt.component.ts index 44b540a7bc..77ff3f50e2 100644 --- a/src/app/ssmt/ssmt.component.ts +++ b/src/app/ssmt/ssmt.component.ts @@ -298,10 +298,10 @@ export class SsmtComponent implements OnInit { } else { mod.ssmt.co2SavingsData.zipcode = ssmt.co2SavingsData.zipcode; mod.ssmt.co2SavingsData.eGridSubregion = ssmt.co2SavingsData.eGridSubregion; - if (!mod.ssmt.co2SavingsData.totalEmissionOutputRate) { + if (mod.ssmt.co2SavingsData.totalEmissionOutputRate === undefined) { mod.ssmt.co2SavingsData.totalEmissionOutputRate = ssmt.co2SavingsData.totalEmissionOutputRate; } - if (!mod.ssmt.co2SavingsData.totalFuelEmissionOutputRate) { + if (mod.ssmt.co2SavingsData.totalFuelEmissionOutputRate === undefined) { mod.ssmt.co2SavingsData.totalFuelEmissionOutputRate = ssmt.co2SavingsData.totalFuelEmissionOutputRate; } } diff --git a/src/app/waste-water/add-modification-modal/add-modification-modal.component.ts b/src/app/waste-water/add-modification-modal/add-modification-modal.component.ts index 9f7e211858..75bd22fc56 100644 --- a/src/app/waste-water/add-modification-modal/add-modification-modal.component.ts +++ b/src/app/waste-water/add-modification-modal/add-modification-modal.component.ts @@ -37,6 +37,7 @@ export class AddModificationModalComponent implements OnInit { addModification() { let wasteWater: WasteWater = this.wasteWaterService.wasteWater.getValue(); let modification: WasteWaterData = JSON.parse(JSON.stringify(wasteWater.baselineData)); + modification.co2SavingsData.userEnteredModificationEmissions = modification.co2SavingsData.userEnteredBaselineEmissions; modification.exploreOpportunities = (this.assessmentTab == 'explore-opportunities'); modification.name = this.newModificationName; modification.id = Math.random().toString(36).substr(2, 9); diff --git a/src/app/waste-water/explore-opportunities/explore-opportunities-form/explore-opportunities-form.component.ts b/src/app/waste-water/explore-opportunities/explore-opportunities-form/explore-opportunities-form.component.ts index 4cfb8127c0..08df9da913 100644 --- a/src/app/waste-water/explore-opportunities/explore-opportunities-form/explore-opportunities-form.component.ts +++ b/src/app/waste-water/explore-opportunities/explore-opportunities-form/explore-opportunities-form.component.ts @@ -54,6 +54,7 @@ export class ExploreOpportunitiesFormComponent implements OnInit { addNewMod() { let wasteWater: WasteWater = this.wasteWaterService.wasteWater.getValue(); let modification: WasteWaterData = JSON.parse(JSON.stringify(wasteWater.baselineData)); + modification.co2SavingsData.userEnteredModificationEmissions = modification.co2SavingsData.userEnteredBaselineEmissions; modification.exploreOpportunities = true; modification.name = 'Scenario ' + (wasteWater.modifications.length + 1); modification.id = Math.random().toString(36).substr(2, 9); diff --git a/src/app/waste-water/explore-opportunities/explore-opportunities.component.ts b/src/app/waste-water/explore-opportunities/explore-opportunities.component.ts index f6c4110296..80aa2a9556 100644 --- a/src/app/waste-water/explore-opportunities/explore-opportunities.component.ts +++ b/src/app/waste-water/explore-opportunities/explore-opportunities.component.ts @@ -41,6 +41,7 @@ export class ExploreOpportunitiesComponent implements OnInit { addExploreOpp() { let wasteWater: WasteWater = this.wasteWaterService.wasteWater.getValue(); let modification: WasteWaterData = JSON.parse(JSON.stringify(wasteWater.baselineData)); + modification.co2SavingsData.userEnteredModificationEmissions = modification.co2SavingsData.userEnteredBaselineEmissions; modification.exploreOpportunities = true; modification.name = 'Scenario ' + (wasteWater.modifications.length + 1); modification.id = Math.random().toString(36).substr(2, 9); diff --git a/src/app/waste-water/modification-list-modal/modification-list-modal.component.ts b/src/app/waste-water/modification-list-modal/modification-list-modal.component.ts index c5f337d13d..4af0f66ff1 100644 --- a/src/app/waste-water/modification-list-modal/modification-list-modal.component.ts +++ b/src/app/waste-water/modification-list-modal/modification-list-modal.component.ts @@ -114,6 +114,7 @@ export class ModificationListModalComponent implements OnInit { addNewModification() { let modification: WasteWaterData = JSON.parse(JSON.stringify(this.wasteWater.baselineData)); + modification.co2SavingsData.userEnteredModificationEmissions = modification.co2SavingsData.userEnteredBaselineEmissions; modification.name = this.newModificationName; modification.id = Math.random().toString(36).substr(2, 9); this.wasteWater.modifications.push(modification);