Reorder condition check
authorJérôme Benoit <jerome.benoit@sap.com>
Fri, 4 Feb 2022 23:23:25 +0000 (00:23 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Fri, 4 Feb 2022 23:23:25 +0000 (00:23 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ocpp/OCPPRequestService.ts

index 363db74420a81f623ad7760cf0233c0f9daf1a30..e459bc07a6bdba06c0466f099196851dfd38076f 100644 (file)
@@ -29,7 +29,7 @@ export default abstract class OCPPRequestService {
         skipBufferingOnError: false,
         triggerMessage: false
       }): Promise<unknown> {
-    if ((this.chargingStation.isInPendingState() && !params.triggerMessage) || this.chargingStation.isInRejectedState()) {
+    if (this.chargingStation.isInRejectedState() || (this.chargingStation.isInPendingState() && !params.triggerMessage)) {
       throw new OCPPError(ErrorType.SECURITY_ERROR, 'Cannot send command payload if the charging station is not in accepted state', commandName);
     } else if (this.chargingStation.isInAcceptedState() || (this.chargingStation.isInPendingState() && params.triggerMessage)) {
       // eslint-disable-next-line @typescript-eslint/no-this-alias