Skip to content

Commit

Permalink
Merge pull request #1761 from ORNL-AMO/issue-1720-fixes
Browse files Browse the repository at this point in the history
Banking updates for BP report
  • Loading branch information
rmroot authored Nov 22, 2024
2 parents 455e198 + 2f3f83b commit a34a18d
Show file tree
Hide file tree
Showing 33 changed files with 419 additions and 126 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@
</p>
<p>
<span
*ngIf="selectedReport.betterPlantsReportSetup.modificationNotes">{{selectedReport.betterPlantsReportSetup.modificationNotes}}</span>
<span *ngIf="!selectedReport.betterPlantsReportSetup.modificationNotes">N/A</span>
*ngIf="selectedReport.betterPlantsReportSetup.modificationNotes">{{selectedReport.betterPlantsReportSetup.modificationNotes}}<br></span>
<span
*ngIf="!selectedReport.betterPlantsReportSetup.modificationNotes">N/A</span>
</p>
</div>
</div>
</ng-container>
<div class="row justify-content-center print-break-before" *ngIf="selectedReport.betterPlantsReportSetup.includePerformanceTable">
<div class="row justify-content-center print-break-before"
*ngIf="selectedReport.betterPlantsReportSetup.includePerformanceTable">
<div class="col-10">
<hr class="hide-print">
<p class="bold pt-4">
Expand Down Expand Up @@ -123,13 +125,14 @@
</p>
<p>
<span
*ngIf="selectedReport.betterPlantsReportSetup.modificationNotes">{{selectedReport.betterPlantsReportSetup.modificationNotes}}</span>
*ngIf="selectedReport.betterPlantsReportSetup.modificationNotes">{{selectedReport.betterPlantsReportSetup.modificationNotes}}<br></span>
<span *ngIf="!selectedReport.betterPlantsReportSetup.modificationNotes">N/A</span>
</p>
</div>
</div>
</ng-container>
<div class="row justify-content-center print-break-avoid" *ngIf="selectedReport.betterPlantsReportSetup.includePerformanceTable">
<div class="row justify-content-center print-break-avoid"
*ngIf="selectedReport.betterPlantsReportSetup.includePerformanceTable">
<div class="col-10">
<hr class="hide-print">
<p class="bold pt-4">
Expand All @@ -139,7 +142,8 @@
</div>
</ng-container>
<!--end water-->
<div class="row justify-content-center print-break-avoid" *ngIf="selectedReport.betterPlantsReportSetup.includePerformanceTable">
<div class="row justify-content-center print-break-avoid"
*ngIf="selectedReport.betterPlantsReportSetup.includePerformanceTable">
<div class="col-6">
<app-facility-performance-table [betterPlantsSummary]="betterPlantsSummary"
[betterPlantsReportSetup]="selectedReport.betterPlantsReportSetup">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,22 @@
{{betterPlantsSummary.reportYearAnalysisSummary.newSavings | customNumber}}
</td>
</tr>
<tr *ngIf="betterPlantsSummary.totalEnergySavingsUnbanked">
<td colspan="2">
Unbanked Energy Savings (MMBtu)
</td>
<td>
{{betterPlantsSummary.totalEnergySavingsUnbanked | customNumber}}
</td>
</tr>
<tr *ngIf="betterPlantsSummary.totalEnergySavingsBanked">
<td colspan="2">
Banked Energy Savings (MMBtu)
</td>
<td>
{{betterPlantsSummary.totalEnergySavingsBanked | customNumber}}
</td>
</tr>
<tr>
<td colspan="2">
Total Energy Savings since Baseline Year (MMBtu)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,22 @@
{{betterPlantsSummary.reportYearAnalysisSummary.newSavings | customNumber}}
</td>
</tr>
<tr *ngIf="betterPlantsSummary.totalWaterSavingsUnbanked">
<td colspan="2">
Unbanked Water Savings (kGal)
</td>
<td>
{{betterPlantsSummary.totalWaterSavingsUnbanked | customNumber}}
</td>
</tr>
<tr *ngIf="betterPlantsSummary.totalWaterSavingsBanked">
<td colspan="2">
Banked Water Savings (kGal)
</td>
<td>
{{betterPlantsSummary.totalWaterSavingsBanked | customNumber}}
</td>
</tr>
<tr>
<td>
Total Water Savings since Baseline Year (kGal)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,12 @@ export class BetterPlantsExcelWriterService {
worksheet.getCell('E34').value = betterPlantsSummary.percentTotalEnergyImprovement / 100;

//baseline adjustment notes
if (report.betterPlantsReportSetup.baselineAdjustmentNotes) {
if (report.betterPlantsReportSetup.baselineAdjustmentNotes && !betterPlantsSummary.totalEnergySavingsBanked) {
worksheet.getCell('C39').value = report.betterPlantsReportSetup.baselineAdjustmentNotes;
} else if (!report.betterPlantsReportSetup.baselineAdjustmentNotes && betterPlantsSummary.totalEnergySavingsBanked) {
worksheet.getCell('C39').value = betterPlantsSummary.totalEnergySavingsBanked + ' MMBtu of banked savings included.';
} else if (report.betterPlantsReportSetup.baselineAdjustmentNotes && betterPlantsSummary.totalEnergySavingsBanked) {
worksheet.getCell('C39').value = report.betterPlantsReportSetup.baselineAdjustmentNotes + '; ' + betterPlantsSummary.totalEnergySavingsBanked + ' MMBtu of banked savings included.';
}
//modification notes
if (report.betterPlantsReportSetup.modificationNotes) {
Expand Down Expand Up @@ -368,9 +372,14 @@ export class BetterPlantsExcelWriterService {
worksheet.getCell('E51').value = betterPlantsSummary.percentTotalWaterImprovement

//baseline adjustment notes
if (report.betterPlantsReportSetup.baselineAdjustmentNotes) {
if (report.betterPlantsReportSetup.baselineAdjustmentNotes && !betterPlantsSummary.totalWaterSavingsBanked) {
worksheet.getCell('D55').value = report.betterPlantsReportSetup.baselineAdjustmentNotes;
} else if (!report.betterPlantsReportSetup.baselineAdjustmentNotes && betterPlantsSummary.totalWaterSavingsBanked) {
worksheet.getCell('D55').value = betterPlantsSummary.totalWaterSavingsBanked + ' kGal of banked savings included.';
} else if (report.betterPlantsReportSetup.baselineAdjustmentNotes && betterPlantsSummary.totalWaterSavingsBanked) {
worksheet.getCell('D55').value = report.betterPlantsReportSetup.baselineAdjustmentNotes + '; ' + betterPlantsSummary.totalWaterSavingsBanked + ' kGal of banked savings included.';
}

//modification notes
if (report.betterPlantsReportSetup.modificationNotes) {
worksheet.getCell('D61').value = report.betterPlantsReportSetup.modificationNotes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ export class AnnualAccountAnalysisSummaryClass {
newSavings: checkAnalysisValue(summaryDataClass.newSavings),
predictorUsage: summaryDataClass.predictorUsage,
isBanked: false,
isIntermediateBanked: false
isIntermediateBanked: false,
savingsBanked: checkAnalysisValue(summaryDataClass.savingsBanked),
savingsUnbanked: checkAnalysisValue(summaryDataClass.savingsUnbanked)
}
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export class AnnualAnalysisSummaryDataClass {
baselineAdjustment: number;
SEnPI: number;
savings: number;
savingsBanked: number;
savingsUnbanked: number;
totalSavingsPercentImprovement: number;
annualSavingsPercentImprovement: number;
cummulativeSavings: number;
Expand Down Expand Up @@ -141,6 +143,12 @@ export class AnnualAnalysisSummaryDataClass {
this.savings = _.sumBy(this.yearAnalysisSummaryData, (data: MonthlyAnalysisSummaryData) => {
return data.savings;
});
this.savingsUnbanked = _.sumBy(this.yearAnalysisSummaryData, (data: MonthlyAnalysisSummaryData) => {
return data.savingsUnbanked;
});
this.savingsBanked = _.sumBy(this.yearAnalysisSummaryData, (data: MonthlyAnalysisSummaryData) => {
return data.savingsBanked;
});
}

setTotalSavingsPercentImprovement() {
Expand All @@ -160,24 +168,24 @@ export class AnnualAnalysisSummaryDataClass {

setAnnualSavingsPercentImprovement() {
this.annualSavingsPercentImprovement = this.totalSavingsPercentImprovement - this.previousYearPercentSavings;
if(this.isIntermediateBanked){
if (this.isIntermediateBanked) {
this.annualSavingsPercentImprovement = 0;
}
}

setCummulativeSavings(previousYearsSummaryData: Array<AnnualAnalysisSummaryDataClass>) {
if (previousYearsSummaryData.length != 0 && !this.isIntermediateBanked) {
let previousYearData: Array<AnnualAnalysisSummaryDataClass> = previousYearsSummaryData.filter(data => { return data.year < this.year })
let sumSavings: number = _.sumBy(previousYearData, (data: AnnualAnalysisSummaryDataClass) => {return data.cummulativeSavings});
this.cummulativeSavings = sumSavings + this.savings;
let sumSavings: number = _.sumBy(previousYearData, (data: AnnualAnalysisSummaryDataClass) => { return data.cummulativeSavings });
this.cummulativeSavings = sumSavings + this.savings;
} else {
this.cummulativeSavings = 0;
}
}

setNewSavings() {
this.newSavings = this.savings - this.previousYearSavings;
if(this.isIntermediateBanked){
if (this.isIntermediateBanked) {
this.newSavings = 0;
}
}
Expand Down Expand Up @@ -221,7 +229,9 @@ export class AnnualAnalysisSummaryDataClass {
newSavings: checkAnalysisValue(this.newSavings),
predictorUsage: this.predictorUsage,
isBanked: this.isBanked,
isIntermediateBanked: this.isIntermediateBanked
isIntermediateBanked: this.isIntermediateBanked,
savingsBanked: checkAnalysisValue(this.savingsBanked),
savingsUnbanked: checkAnalysisValue(this.savingsUnbanked)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ export class AnnualFacilityAnalysisSummaryClass {
newSavings: checkAnalysisValue(summaryDataClass.newSavings),
predictorUsage: summaryDataClass.predictorUsage,
isBanked: false,
isIntermediateBanked: false
isIntermediateBanked: false,
savingsBanked: checkAnalysisValue(summaryDataClass.savingsBanked),
savingsUnbanked: checkAnalysisValue(summaryDataClass.savingsUnbanked)
}
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ export class AnnualGroupAnalysisSummaryClass {
newSavings: checkAnalysisValue(summaryDataClass.newSavings),
predictorUsage: summaryDataClass.predictorUsage,
isBanked: summaryDataClass.isBanked,
isIntermediateBanked: summaryDataClass.isIntermediateBanked
isIntermediateBanked: summaryDataClass.isIntermediateBanked,
savingsUnbanked: checkAnalysisValue(summaryDataClass.savingsUnbanked),
savingsBanked: checkAnalysisValue(summaryDataClass.savingsBanked)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export class GroupMonthlyAnalysisCalculatedValues {

savings: number;
savingsUnbanked: number;
savingsBanked: number

percentSavingsComparedToBaseline: number;

Expand Down Expand Up @@ -46,7 +47,8 @@ export class GroupMonthlyAnalysisCalculatedValues {
baselineActualEnergyUse: number,
modelYearDataAdjusted: number,
dataAdjustment: number,
lastBankedMonthSummaryData: MonthlyAnalysisSummaryDataClass
lastBankedMonthSummaryData: MonthlyAnalysisSummaryDataClass,
originalBaselineYearBaselineActualEnergyUse: number
) {
this.energyUse = energyUse;
this.modeledEnergy = modeledEnergy;
Expand All @@ -60,7 +62,7 @@ export class GroupMonthlyAnalysisCalculatedValues {
this.setAdjustedStarStar(dataAdjustment);
this.setAdjusted();
this.setBaselineAdjustmentForNormalization(baselineActualEnergyUse, modelYearDataAdjusted, dataAdjustment);
this.setBaselineAdjustmentForOtherV2(baselineAdjustementInput, modelYearDataAdjusted, dataAdjustment, baselineActualEnergyUse);
this.setBaselineAdjustmentForOtherV2(baselineAdjustementInput, modelYearDataAdjusted, dataAdjustment, baselineActualEnergyUse, originalBaselineYearBaselineActualEnergyUse);
this.setBaselineAdjustment();
this.setSEnPI();
this.setSavings(baselineActualEnergyUse, baselineAdjustementInput, modelYearDataAdjusted, dataAdjustment, lastBankedMonthSummaryData);
Expand Down Expand Up @@ -145,7 +147,7 @@ export class GroupMonthlyAnalysisCalculatedValues {
this.yearToDateAdjustedEnergyUse = this.yearToDateAdjustedEnergyUse + this.adjusted;
}

setBaselineAdjustmentForOtherV2(baselineAdjustementInput: number, modelYearDataAdjusted: number, dataAdjustment: number, baselineActualEnergyUse: number) {
setBaselineAdjustmentForOtherV2(baselineAdjustementInput: number, modelYearDataAdjusted: number, dataAdjustment: number, baselineActualEnergyUse: number, originalBaselineYearBaselineActualEnergyUse: number) {
if ((this.energyUse - dataAdjustment) == 0 && this.energyUse != 0) {
this.baselineAdjustmentForOtherV2 = baselineAdjustementInput;
} else {
Expand All @@ -164,6 +166,11 @@ export class GroupMonthlyAnalysisCalculatedValues {
this.baselineAdjustmentForOtherV2 = baselineAdjustementInput * ((this.modeledEnergy - modelYearDataAdjusted) / (this.baselineModeledEnergyUse - modelYearDataAdjusted)) * adjustedStarStarRatio;
}
}

//add (new baseline actual - original baseline actual)
if (isNaN(originalBaselineYearBaselineActualEnergyUse) == false && originalBaselineYearBaselineActualEnergyUse != baselineActualEnergyUse) {
this.baselineAdjustmentForOtherV2 = (this.baselineAdjustmentForOtherV2 + (baselineActualEnergyUse - originalBaselineYearBaselineActualEnergyUse));
}
}

setSEnPI() {
Expand All @@ -183,6 +190,7 @@ export class GroupMonthlyAnalysisCalculatedValues {
//TODO: handle banking here..
this.savings = this.savingsUnbanked;
}
this.savingsBanked = (this.savings - this.savingsUnbanked);
}

setPercentSavingsComparedToBaseline() {
Expand Down Expand Up @@ -256,6 +264,7 @@ export class GroupMonthlyAnalysisCalculatedValues {
this.adjusted = new ConvertValue(this.adjusted, startingUnit, endingUnit).convertedValue;
this.baselineAdjustment = new ConvertValue(this.baselineAdjustment, startingUnit, endingUnit).convertedValue;
this.savings = new ConvertValue(this.savings, startingUnit, endingUnit).convertedValue;
this.savingsBanked = new ConvertValue(this.savingsBanked, startingUnit, endingUnit).convertedValue;
this.yearToDateSavings = new ConvertValue(this.yearToDateSavings, startingUnit, endingUnit).convertedValue;
this.rollingSavings = new ConvertValue(this.rollingSavings, startingUnit, endingUnit).convertedValue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ export class MonthlyAccountAnalysisClass {
// adjustedStarStar: summaryDataItem.monthlyAnalysisCalculatedValues.adjustedStarStar,
baselineAdjustmentInput: summaryDataItem.baselineAdjustmentInput,
isBanked: false,
isIntermediateBanked: false
isIntermediateBanked: false,
savingsBanked: checkAnalysisValue(summaryDataItem.monthlyAnalysisCalculatedValues.savingsBanked),
savingsUnbanked: checkAnalysisValue(summaryDataItem.monthlyAnalysisCalculatedValues.savingsUnbanked)

}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export class MonthlyAnalysisCalculatedValuesSummation {
fiscalYear: number;
SEnPI: number;
savings: number;
savingsBanked: number;
savingsUnbanked: number;
percentSavingsComparedToBaseline: number;
yearToDateSavings: number;
yearToDatePercentSavings: number;
Expand Down Expand Up @@ -115,6 +117,14 @@ export class MonthlyAnalysisCalculatedValuesSummation {
this.savings = _.sumBy(currentMonthData, (data: MonthlyAnalysisSummaryDataClass) => {
return data.monthlyAnalysisCalculatedValues.savings;
});

this.savingsUnbanked = _.sumBy(currentMonthData, (data: MonthlyAnalysisSummaryDataClass) => {
return data.monthlyAnalysisCalculatedValues.savingsUnbanked;
});

this.savingsBanked = _.sumBy(currentMonthData, (data: MonthlyAnalysisSummaryDataClass) => {
return data.monthlyAnalysisCalculatedValues.savingsBanked;
});
}

setPercentSavingsComparedToBaseline() {
Expand Down Expand Up @@ -145,9 +155,10 @@ export class MonthlyAnalysisCalculatedValuesSummation {
setRollingSavingsValues(previousMonthsValues: Array<MonthlyAnalysisCalculatedValuesSummation>) {
if (this.summaryDataIndex > 11) {
let last11MonthsData: Array<MonthlyAnalysisCalculatedValuesSummation> = previousMonthsValues.splice(this.summaryDataIndex - 11, this.summaryDataIndex);
let total12MonthsEnergyUse: number = _.sumBy(last11MonthsData, (data: MonthlyAnalysisCalculatedValuesSummation) => { return data.energyUse }) + this.energyUse;
// let total12MonthsEnergyUse: number = _.sumBy(last11MonthsData, (data: MonthlyAnalysisCalculatedValuesSummation) => { return data.energyUse }) + this.energyUse;
let total12MonthsAdjusedBaseline: number = _.sumBy(last11MonthsData, (data: MonthlyAnalysisCalculatedValuesSummation) => { return data.adjusted }) + this.adjusted;
this.rollingSavings = total12MonthsAdjusedBaseline - total12MonthsEnergyUse;
this.rollingSavings = _.sumBy(last11MonthsData, (data: MonthlyAnalysisCalculatedValuesSummation) => { return data.savings }) + this.savings;
// this.rollingSavings = total12MonthsAdjusedBaseline - total12MonthsEnergyUse;
this.rolling12MonthImprovement = this.rollingSavings / total12MonthsAdjusedBaseline;
} else {
this.rolling12MonthImprovement = 0;
Expand Down
Loading

0 comments on commit a34a18d

Please sign in to comment.