addSeconds,
addWeeks,
differenceInDays,
+ differenceInSeconds,
differenceInWeeks,
isAfter,
isBefore,
start: chargingSchedule.startSchedule!,
end: addDays(chargingSchedule.startSchedule!, 1),
};
+ checkRecurringChargingProfileDuration(chargingProfile, recurringInterval, logPrefix);
if (
!isWithinInterval(currentDate, recurringInterval) &&
isBefore(chargingSchedule.startSchedule!, currentDate)
start: chargingSchedule.startSchedule!,
end: addWeeks(chargingSchedule.startSchedule!, 1),
};
+ checkRecurringChargingProfileDuration(chargingProfile, recurringInterval, logPrefix);
if (
!isWithinInterval(currentDate, recurringInterval) &&
isBefore(chargingSchedule.startSchedule!, currentDate)
}
};
+const checkRecurringChargingProfileDuration = (
+ chargingProfile: ChargingProfile,
+ interval: Interval,
+ logPrefix: string,
+) => {
+ if (
+ chargingProfile.chargingSchedule.duration! > differenceInSeconds(interval.end, interval.start)
+ ) {
+ logger.warn(
+ `${logPrefix} ${moduleName}.getLimitFromChargingProfiles: Recurring ${
+ chargingProfile.chargingProfileKind
+ } charging profile id ${chargingProfile.chargingProfileId} duration ${
+ chargingProfile.chargingSchedule.duration
+ } is greater than the recurrency time interval ${differenceInSeconds(
+ interval.end,
+ interval.start,
+ )} duration`,
+ );
+ }
+};
+
const getRandomSerialNumberSuffix = (params?: {
randomBytesLength?: number;
upperCase?: boolean;