fix: check reservation status at the end at start transaction
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 30 Jul 2023 22:05:03 +0000 (00:05 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sun, 30 Jul 2023 22:05:03 +0000 (00:05 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts

index f5b568dc41eb39ade5eeb28cbfb7fff9459c81c7..ad7e8e17ed94d2396700cc66056dc7206f69620a 100644 (file)
@@ -825,15 +825,6 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
     commandPayload: RemoteStartTransactionRequest,
   ): Promise<GenericResponse> {
     const { connectorId: transactionConnectorId, idTag, chargingProfile } = commandPayload;
-    if (
-      (chargingStation.getConnectorStatus(transactionConnectorId)?.status ===
-        OCPP16ChargePointStatus.Reserved &&
-        chargingStation.getReservationBy('connectorId', transactionConnectorId)?.idTag !== idTag) ||
-      (chargingStation.getConnectorStatus(0)?.status === OCPP16ChargePointStatus.Reserved &&
-        chargingStation.getReservationBy('connectorId', 0)?.idTag !== idTag)
-    ) {
-      return OCPP16Constants.OCPP_RESPONSE_REJECTED;
-    }
     if (chargingStation.hasConnector(transactionConnectorId) === false) {
       return this.notifyRemoteStartTransactionRejected(
         chargingStation,
@@ -851,6 +842,15 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
         idTag,
       );
     }
+    if (
+      (chargingStation.getConnectorStatus(transactionConnectorId)?.status ===
+        OCPP16ChargePointStatus.Reserved &&
+        chargingStation.getReservationBy('connectorId', transactionConnectorId)?.idTag !== idTag) ||
+      (chargingStation.getConnectorStatus(0)?.status === OCPP16ChargePointStatus.Reserved &&
+        chargingStation.getReservationBy('connectorId', 0)?.idTag !== idTag)
+    ) {
+      return OCPP16Constants.OCPP_RESPONSE_REJECTED;
+    }
     const remoteStartTransactionLogMsg = `
       ${chargingStation.logPrefix()} Transaction remotely STARTED on ${
         chargingStation.stationInfo.chargingStationId