Sessions: fix session energy nulled when charger already disconnected

This commit is contained in:
andig 2022-11-03 16:00:27 +01:00
parent 24f49585b9
commit 7d3619f8f7

View file

@ -30,7 +30,9 @@ type Session struct {
// Stop stops charging session with end meter reading and due total amount
func (t *Session) Stop(chargedWh, total float64) {
t.ChargedEnergy = chargedWh / 1e3
if chargedEnergy := chargedWh / 1e3; chargedEnergy > t.ChargedEnergy {
t.ChargedEnergy = chargedEnergy
}
t.MeterStop = total
t.Finished = time.Now()
}