fix: ensure the second stage at handling incoming request is executed
[e-mobility-charging-stations-simulator.git] / src / charging-station / ocpp / 1.6 / OCPP16ServiceUtils.ts
index b8048927ccb824f4ff8e20320cfd356c33af6f0f..a959844ac497f46b1876acd068ac56f61c87045d 100644 (file)
@@ -1,4 +1,4 @@
-// Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
+// Partial Copyright Jerome Benoit. 2021-2024. All Rights Reserved.
 
 import type { JSONSchemaType } from 'ajv'
 import {
@@ -164,12 +164,9 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils {
       // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
       chargingStation.getConnectorStatus(connectorId)!.chargingProfiles = []
     }
-    // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
-    cp.chargingSchedule.startSchedule = convertToDate(cp.chargingSchedule.startSchedule)!
-    // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
-    cp.validFrom = convertToDate(cp.validFrom)!
-    // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
-    cp.validTo = convertToDate(cp.validTo)!
+    cp.chargingSchedule.startSchedule = convertToDate(cp.chargingSchedule.startSchedule)
+    cp.validFrom = convertToDate(cp.validFrom)
+    cp.validTo = convertToDate(cp.validTo)
     let cpReplaced = false
     if (isNotEmptyArray(chargingStation.getConnectorStatus(connectorId)?.chargingProfiles)) {
       // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -510,8 +507,7 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils {
             .filter((schedulePeriod, index) => {
               if (
                 isWithinInterval(
-                  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
-                  addSeconds(chargingScheduleInterval.start, schedulePeriod.startPeriod)!,
+                  addSeconds(chargingScheduleInterval.start, schedulePeriod.startPeriod),
                   compositeInterval
                 )
               ) {
@@ -552,8 +548,7 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils {
           ),
           chargingSchedulePeriod: chargingSchedule.chargingSchedulePeriod.filter(schedulePeriod =>
             isWithinInterval(
-              // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
-              addSeconds(chargingScheduleInterval.start, schedulePeriod.startPeriod)!,
+              addSeconds(chargingScheduleInterval.start, schedulePeriod.startPeriod),
               compositeInterval
             )
           )