sap-labs-france / ev-server

The Open e-Mobility Charging Station management backend server (check also ev-dashboard and ev-mobile)
https://open-e-mobility.fr/
Apache License 2.0
154 stars 144 forks source link

[ConvergentCharging] sessionId computation changes between start and update of transaction #810

Closed mehdijouan closed 5 years ago

mehdijouan commented 5 years ago

When a transaction is opened in emobility, a session is opened in convergent charging. The sessionId is computed by ConvergentChargingPricing.ts as the hash of:

consumptionData.userID + consumptionData.chargeBoxID + consumptionData.connectorId + this.transaction.timestamp;

When the transaction is updated in emobility, the session should be updated. The problem is that the computed sessionId for the update is different of the one computed during the start.

mehdijouan commented 5 years ago

During the start of the transaction, it has not been saved yet and its timestamp is of type string. When fetching it from the DB it is a Date type. It leads to the following difference when concatenating values :

The solution proposed is to check the type of timestamp prior to compute the sessionId to always have the same behavior.