Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ <h4>Analysis Setup</h4>
</select>
</div>
</div>
<div class="alert alert-warning text-center p-1" *ngIf="showReportYearWarning">
This facility does not have 12 months of data for the selected report year
({{analysisItem.reportYear}}). An analysis is intended to be run with complete years only. To see
mid-year progress, please run a <a class="click-link" (click)="goToSavingsReport()">"Savings
Report"</a> for an analysis conducted with a different report year.
</div>
<div class="form-group row">
<label class="col-5 col-form-label">
Reporting Year
Expand Down Expand Up @@ -180,7 +186,8 @@ <h4>Analysis Setup</h4>
</div>
</form>
<app-select-banked-analysis *ngIf="analysisItem.hasBanking" [facilityAnalysisItems]="facilityAnalysisItems"
[analysisItem]="analysisItem" [facility]="facility" (emitSave)="saveItem()" [disabled]="disableForm"></app-select-banked-analysis>
[analysisItem]="analysisItem" [facility]="facility" (emitSave)="saveItem()"
[disabled]="disableForm"></app-select-banked-analysis>


<div class="row">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { FacilitydbService } from 'src/app/indexedDB/facility-db.service';
import { EnergyUnitOptions, UnitOption } from 'src/app/shared/unitOptions';
import * as _ from 'lodash';
import { AnalysisService } from '../../analysis.service';
import { Router } from '@angular/router';
import { ActivatedRoute, Router } from '@angular/router';
import { DbChangesService } from 'src/app/indexedDB/db-changes.service';
import { AccountdbService } from 'src/app/indexedDB/account-db.service';
import { firstValueFrom, Subscription } from 'rxjs';
Expand All @@ -19,10 +19,10 @@ import { IdbAccount } from 'src/app/models/idbModels/account';
import { IdbFacility } from 'src/app/models/idbModels/facility';
import { IdbAnalysisItem } from 'src/app/models/idbModels/analysisItem';
@Component({
selector: 'app-analysis-setup',
templateUrl: './analysis-setup.component.html',
styleUrls: ['./analysis-setup.component.css'],
standalone: false
selector: 'app-analysis-setup',
templateUrl: './analysis-setup.component.html',
styleUrls: ['./analysis-setup.component.css'],
standalone: false
})
export class AnalysisSetupComponent implements OnInit {

Expand All @@ -46,31 +46,34 @@ export class AnalysisSetupComponent implements OnInit {

analysisItemSub: Subscription;
isFormChange: boolean = false;
showReportYearWarning: boolean = false;
constructor(private facilityDbService: FacilitydbService, private analysisDbService: AnalysisDbService,
private analysisService: AnalysisService, private router: Router,
private analysisValidationService: AnalysisValidationService,
private dbChangesService: DbChangesService,
private accountDbService: AccountdbService,
private calanderizationService: CalanderizationService,
private accountAnalysisDbService: AccountAnalysisDbService,
private regressionModelsService: RegressionModelsService) { }
private regressionModelsService: RegressionModelsService,
private activatedRoute: ActivatedRoute) { }

ngOnInit(): void {
this.analysisItemSub = this.analysisDbService.selectedAnalysisItem.subscribe(item => {
if(!this.isFormChange){
if (!this.isFormChange) {
this.analysisItem = item;
this.facility = this.facilityDbService.selectedFacility.getValue();
this.yearOptions = this.calanderizationService.getYearOptionsFacility(this.facility.guid, this.analysisItem.analysisCategory);
this.setReportYears();
this.setBaselineYearWarning();
this.setReportYearWarning();
this.setComponentBools();
}else{
} else {
this.isFormChange = false;
}
})
}

ngOnDestroy(){
ngOnDestroy() {
this.analysisItemSub.unsubscribe();
}

Expand All @@ -87,6 +90,7 @@ export class AnalysisSetupComponent implements OnInit {
async changeReportYear() {
this.analysisItem = this.analysisService.setDataAdjustments(this.analysisItem);
this.setBaselineYearWarning();
this.setReportYearWarning();
if (!this.baselineYearWarning) {
let allFacilityAnalysisItems: Array<IdbAnalysisItem> = this.analysisDbService.facilityAnalysisItems.getValue();
let selectYearAnalysis: boolean = true;
Expand Down Expand Up @@ -239,4 +243,17 @@ export class AnalysisSetupComponent implements OnInit {
}
await this.saveItem();
}


setReportYearWarning() {
if (this.analysisItem.reportYear != undefined) {
this.showReportYearWarning = this.calanderizationService.checkReportYearSelection('all', this.analysisItem.reportYear, this.facility);
} else {
this.showReportYearWarning = false;
}
}

goToSavingsReport(){
this.router.navigate(['../../../reports'], { relativeTo: this.activatedRoute });
}
}