Fix return compensation not being negative (#9654)

This commit is contained in:
Bram Kragten 2021-07-30 21:57:27 +02:00 committed by GitHub
parent 5147dff670
commit 2982adbfa7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -202,7 +202,7 @@ export class HuiEnergySourcesTableCard
flow.stat_cost ||
this._energyInfo!.cost_sensors[flow.stat_energy_from];
const cost = cost_stat
? calculateStatisticSumGrowth(this._stats![cost_stat])
? calculateStatisticSumGrowth(this._stats![cost_stat]) || 0
: null;
if (cost !== null) {
totalCost += cost;
@ -260,7 +260,8 @@ export class HuiEnergySourcesTableCard
flow.stat_compensation ||
this._energyInfo!.cost_sensors[flow.stat_energy_to];
const cost = cost_stat
? calculateStatisticSumGrowth(this._stats![cost_stat])
? (calculateStatisticSumGrowth(this._stats![cost_stat]) ||
0) * -1
: null;
if (cost !== null) {
totalCost += cost;