Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes to mobile emissions conversions in calanderization #1469

Merged
merged 1 commit into from
Feb 15, 2024
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 @@ -62,7 +62,7 @@ export function getConsumptionUnit(meter: IdbUtilityMeter, accountOrFacility: Id
}

export function getUnitFromMeter(accountMeter: IdbUtilityMeter, accountOrFacility: IdbAccount | IdbFacility): string {
if (accountMeter.source == 'Electricity' || getIsEnergyUnit(accountMeter.startingUnit)) {
if (accountMeter.source == 'Electricity' || (getIsEnergyUnit(accountMeter.startingUnit) && accountMeter.scope != 2)) {
return accountOrFacility.energyUnit;
} else if (accountMeter.source == 'Natural Gas') {
return accountOrFacility.volumeGasUnit;
Expand Down
18 changes: 6 additions & 12 deletions src/app/calculations/calanderization/calanderizeMeters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,6 @@ function getBillPeriodTotal(previousReading: IdbUtilityMeterData, currentReading
meter.vehicleDistanceUnit,
hhvOrFuelEfficiencyCurrent);

if (isNaN(emissionsForCurrent.mobileCarbonEmissions)) {
console.log(currentReading);
console.log(meter);
console.log('===')
}

let costForCurrent: number = (currentReading.totalCost / daysFromPrevious) * daysFromCurrent;

//days from next bill to current bill reading
Expand Down Expand Up @@ -410,7 +404,7 @@ function calanderizeMeterDataFullMonth(meter: IdbUtilityMeter, meterData: Array<
let readingSummaries: Array<CalanderizedReadingSummary> = new Array();
currentMonthsReadings.forEach(reading => {
let totalMonthEnergyUse: number = 0;
let totalMonthEnergyConsumption: number = 0;
let totalConsumption: number = 0;
let totalMonthCost: number = Number(reading.totalCost);
//energy use
let isEnergyMeter: boolean = getIsEnergyMeter(meter.source);
Expand All @@ -419,10 +413,10 @@ function calanderizeMeterDataFullMonth(meter: IdbUtilityMeter, meterData: Array<
}
//energy consumption (data input not as energy)
let isEnergyUnit: boolean = getIsEnergyUnit(meter.startingUnit);
if (!isEnergyUnit) {
totalMonthEnergyConsumption = Number(reading.totalVolume);
if (!isEnergyUnit || meter.scope == 2) {
totalConsumption = Number(reading.totalVolume);
} else {
totalMonthEnergyConsumption = totalMonthEnergyUse;
totalConsumption = totalMonthEnergyUse;
}
let hhvOrFuelEfficiency: number = reading.heatCapacity;
if (meter.scope == 2) {
Expand All @@ -433,12 +427,12 @@ function calanderizeMeterDataFullMonth(meter: IdbUtilityMeter, meterData: Array<
facilities,
co2Emissions,
customFuels,
totalMonthEnergyConsumption,
totalConsumption,
meter.vehicleCollectionUnit,
meter.vehicleDistanceUnit,
hhvOrFuelEfficiency);
readingSummaries.push({
consumption: totalMonthEnergyConsumption,
consumption: totalConsumption,
energyUse: totalMonthEnergyUse,
cost: totalMonthCost,
emissionsResults: emissions,
Expand Down
10 changes: 8 additions & 2 deletions src/app/calculations/conversions/convertMeterData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,14 @@ export function convertMeterData(meter: IdbUtilityMeter, meterData: Array<IdbUti
if (meter.source == 'Other Fuels' && meter.scope == 2) {
startingUnit = meter.vehicleCollectionUnit;
}
for (let index: number = 0; index < copyMeterData.length; index++) {
copyMeterData[index].totalVolume = new ConvertValue(copyMeterData[index].totalVolume, startingUnit, facilityUnit).convertedValue;
if (meter.scope != 2) {
for (let index: number = 0; index < copyMeterData.length; index++) {
copyMeterData[index].totalVolume = new ConvertValue(copyMeterData[index].totalVolume, startingUnit, facilityUnit).convertedValue;
}
} else if (meter.vehicleCollectionType == 1) {
for (let index: number = 0; index < copyMeterData.length; index++) {
copyMeterData[index].totalVolume = new ConvertValue(copyMeterData[index].totalVolume, startingUnit, facilityUnit).convertedValue;
}
}
}
return copyMeterData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ <h4>{{selectedMeter.name}} Calanderized Data

<div>
<app-calanderized-meter-data-table *ngIf="dataDisplay == 'table'" [itemsPerPage]="itemsPerPage"
[calanderizedMeter]="calanderizedMeter">
[calanderizedMeter]="calanderizedMeter" [consumptionLabel]="consumptionLabel">
</app-calanderized-meter-data-table>
<app-calanderization-chart *ngIf="dataDisplay == 'graph'" [meterData]="calanderizedMeter"
[displayGraphEnergy]="displayGraphEnergy" [displayGraphCost]="displayGraphCost">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export class CalanderizationComponent implements OnInit {
selectedFacility: IdbFacility;
displayDataApplicationModal: boolean = false;
hasMeterData: boolean;
consumptionLabel: 'Consumption' | 'Distance';
constructor(private calanderizationService: CalanderizationService, private utilityMeterDbService: UtilityMeterdbService,
private facilityDbService: FacilitydbService,
private dbChangesService: DbChangesService, private accountDbService: AccountdbService,
Expand Down Expand Up @@ -107,6 +108,11 @@ export class CalanderizationComponent implements OnInit {
let calanderizedMeterData: Array<CalanderizedMeter> = getCalanderizedMeterData([this.selectedMeter], facilityMeterData, this.selectedFacility, false, undefined, this.eGridService.co2Emissions, customFuels, [this.selectedFacility]);
calanderizedMeterData = this.filterMeterDataDateRanges(calanderizedMeterData);
this.calanderizedMeter = calanderizedMeterData[0];
if(this.selectedMeter.scope != 2){
this.consumptionLabel = 'Consumption';
}else{
this.consumptionLabel = 'Distance';
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Month</th>
<th (click)="setOrderDataField('energyConsumption')"
[ngClass]="{'active': orderDataField == 'energyConsumption'}" *ngIf="calanderizedMeter.showConsumption">
Total Consumption<br> (<span [innerHTML]="calanderizedMeter.consumptionUnit | settingsLabel"></span>)
Total {{consumptionLabel}}<br> (<span [innerHTML]="calanderizedMeter.consumptionUnit | settingsLabel"></span>)
</th>
<th (click)="setOrderDataField('energyUse')" [ngClass]="{'active': orderDataField == 'energyUse'}"
*ngIf="calanderizedMeter.showEnergyUse">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export class CalanderizedMeterDataTableComponent implements OnInit {
calanderizedMeter: CalanderizedMeter;
@Input()
itemsPerPage: number;
@Input()
consumptionLabel: 'Consumption' | 'Distance';

@ViewChild('meterDataTable', { static: false }) meterDataTable: ElementRef;
orderDataField: string = 'date';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<th (click)="setOrderDataField('readDate')" [ngClass]="{'active': orderDataField == 'readDate'}"
class="row-year">Meter Read Date</th>
<th (click)="setOrderDataField('totalVolume')" [ngClass]="{'active': orderDataField == 'totalVolume'}">
Total Consumption<br> (<span [innerHTML]="volumeUnit | settingsLabel"></span>)
Total {{consumptionLabel}}<br> (<span [innerHTML]="volumeUnit | settingsLabel"></span>)
</th>
<th (click)="setOrderDataField('totalEnergyUse')" [ngClass]="{'active': orderDataField == 'totalEnergyUse'}"
*ngIf="vehicleDataFilters.totalEnergy">Total Energy<br> (<span [innerHTML]="energyUnit | settingsLabel"></span>)</th>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class VehicleDataTableComponent {
showDetailedCharges: boolean;
volumeUnit: string;
energyUnit: string
consumptionLabel: 'Consumption' | 'Distance';
constructor(private utilityMeterDataService: UtilityMeterDataService,
private copyTableService: CopyTableService,
private customFuelDbService: CustomFuelDbService,
Expand All @@ -72,6 +73,11 @@ export class VehicleDataTableComponent {

ngOnChanges() {
this.setData();
if(this.selectedMeter.scope != 2){
this.consumptionLabel = 'Consumption';
}else{
this.consumptionLabel = 'Distance';
}
}

setData() {
Expand Down
Loading