refactor: cleanup getLimitFromChargingProfiles() helper return type
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 24 Jul 2023 11:18:41 +0000 (13:18 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 24 Jul 2023 11:18:41 +0000 (13:18 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ChargingStationUtils.ts

index 7865eb1f3d14433226aad8ddd16a8db496360645..749b876b2d647d5021073093f70a39d0f4b9becc 100644 (file)
@@ -657,10 +657,12 @@ const convertDeprecatedTemplateKey = (
 const getLimitFromChargingProfiles = (
   chargingProfiles: ChargingProfile[],
   logPrefix: string,
-): {
-  limit: number;
-  matchingChargingProfile: ChargingProfile;
-} | null => {
+):
+  | {
+      limit: number;
+      matchingChargingProfile: ChargingProfile;
+    }
+  | undefined => {
   const debugLogMsg = `${logPrefix} ${moduleName}.getLimitFromChargingProfiles: Matching charging profile found for power limitation: %j`;
   const currentDate = new Date();
   for (const chargingProfile of chargingProfiles) {
@@ -677,7 +679,6 @@ const getLimitFromChargingProfiles = (
       );
       chargingSchedule.startSchedule = convertToDate(chargingSchedule.startSchedule)!;
     }
-    // Check type (recurring) and if it is already active
     // Adjust the daily recurring schedule to today
     if (
       chargingProfile.chargingProfileKind === ChargingProfileKindType.RECURRING &&
@@ -746,7 +747,6 @@ const getLimitFromChargingProfiles = (
       }
     }
   }
-  return null;
 };
 
 const getRandomSerialNumberSuffix = (params?: {