ATG: fix start transaction counting with no authentication
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 5 Sep 2022 08:21:48 +0000 (10:21 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 5 Sep 2022 08:21:48 +0000 (10:21 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/AutomaticTransactionGenerator.ts

index d552d8a50b3aed420a68f2d8bdd837b65be9c11c..cdef826badef71331f21e68003a47c42841fd536 100644 (file)
@@ -309,13 +309,7 @@ export default class AutomaticTransactionGenerator {
             connectorId,
             idTag,
           });
-          this.connectorsStatus.get(connectorId).startTransactionRequests++;
-          if (startResponse?.idTagInfo?.status === AuthorizationStatus.ACCEPTED) {
-            this.connectorsStatus.get(connectorId).acceptedStartTransactionRequests++;
-          } else {
-            logger.warn(this.logPrefix(connectorId) + ' start transaction rejected');
-            this.connectorsStatus.get(connectorId).rejectedStartTransactionRequests++;
-          }
+          this.handleStartTransactionResponse(connectorId, startResponse);
           PerformanceStatistics.endMeasure(measureId, beginId);
           return startResponse;
         }
@@ -332,6 +326,7 @@ export default class AutomaticTransactionGenerator {
         connectorId,
         idTag,
       });
+      this.handleStartTransactionResponse(connectorId, startResponse);
       PerformanceStatistics.endMeasure(measureId, beginId);
       return startResponse;
     }
@@ -382,4 +377,17 @@ export default class AutomaticTransactionGenerator {
       }:`
     );
   }
+
+  private handleStartTransactionResponse(
+    connectorId: number,
+    startResponse: StartTransactionResponse
+  ): void {
+    this.connectorsStatus.get(connectorId).startTransactionRequests++;
+    if (startResponse?.idTagInfo?.status === AuthorizationStatus.ACCEPTED) {
+      this.connectorsStatus.get(connectorId).acceptedStartTransactionRequests++;
+    } else {
+      logger.warn(this.logPrefix(connectorId) + ' start transaction rejected');
+      this.connectorsStatus.get(connectorId).rejectedStartTransactionRequests++;
+    }
+  }
 }