Send only one end of charge notification
MODIFY
src/client/ocpi/CpoOCPIClient.ts
src/client/ocpi/CpoOCPIClient.ts
@@ -574,7 +574,7 @@ export default class CpoOCPIClient extends OCPIClient {
result.failure++;
result.objectIDsInFailure.push(String(location.id));
result.logs.push(
- `Failed to check Location ID '${location.id}': ${error.message}`
+ `Failed to check the Location '${location.name}' with ID '${location.id}': ${error.message}`
);
}
}

MODIFY
src/notification/NotificationHandler.ts
src/notification/NotificationHandler.ts
@@ -90,7 +90,7 @@ export default class NotificationHandler {
}
}
- public static async sendEndOfCharge(tenant: Tenant, user: User, chargingStation: ChargingStation,
+ public static async sendEndOfCharge(tenant: Tenant, notificationID: string, user: User, chargingStation: ChargingStation,
sourceData: EndOfChargeNotification): Promise<void> {
if (tenant.id !== Constants.DEFAULT_TENANT) {
// Get the Tenant logo
@@ -103,19 +103,15 @@ export default class NotificationHandler {
for (const notificationSource of NotificationHandler.notificationSources) {
if (notificationSource.enabled) {
try {
- // Get the interval
- const intervalMins = Utils.getEndOfChargeNotificationIntervalMins(
- chargingStation, Utils.getConnectorIDFromConnectorLetter(sourceData.connectorId));
// Check notification
- const hasBeenNotified = await NotificationHandler.hasNotifiedSource(
- tenant, notificationSource.channel, ServerAction.END_OF_CHARGE,
- chargingStation.id, user.id, { intervalMins, additionalFilters: { transactionId: sourceData.transactionId } });
+ const hasBeenNotified = await NotificationHandler.hasNotifiedSourceByID(
+ tenant, notificationSource.channel, notificationID);
if (!hasBeenNotified) {
// Enabled?
if (user.notificationsActive && user.notifications.sendEndOfCharge) {
// Save
await NotificationHandler.saveNotification(
- tenant, notificationSource.channel, null, ServerAction.END_OF_CHARGE, {
+ tenant, notificationSource.channel, notificationID, ServerAction.END_OF_CHARGE, {
user,
chargingStation,
notificationData: {

MODIFY
src/server/ocpp/services/OCPPService.ts
src/server/ocpp/services/OCPPService.ts
@@ -1213,6 +1213,7 @@ export default class OCPPService {
// Notify (Async)
NotificationHandler.sendEndOfCharge(
tenant,
+ transaction.id.toString() + '-EOC',
transaction.user,
chargingStation,
{

MODIFY
src/storage/mongodb/TransactionStorage.ts
src/storage/mongodb/TransactionStorage.ts
@@ -469,7 +469,7 @@ export default class TransactionStorage {
filters['ocpiData.session.last_updated'] = { $lte: Utils.convertToDate(params.ocpiSessionDateTo) };
}
}
- if (params.ocpiSessionChecked === true || params.ocpiSessionChecked === false) {
+ if (Utils.objectHasProperty(params, 'ocpiSessionChecked')) {
filters.stop = { $exists: true };
filters['ocpiData.session'] = { $exists: true };
filters['ocpiData.sessionCheckedOn'] = { $exists: params.ocpiSessionChecked };
@@ -485,13 +485,14 @@ export default class TransactionStorage {
filters['ocpiData.cdr.last_updated'] = { $lte: Utils.convertToDate(params.ocpiCdrDateTo) };
}
}
- if (params.ocpiCdrChecked === true || params.ocpiCdrChecked === false) {
+ if (Utils.objectHasProperty(params, 'ocpiCdrChecked')) {
+ filters.stop = { $exists: true };
filters['ocpiData.cdr'] = { $exists: true };
filters['ocpiData.cdrCheckedOn'] = { $exists: params.ocpiCdrChecked };
}
// Check stop transaction
if (params.stop) {
- filters.stop = params.stop;
+ filters.stop = filters.stop ? { ...filters.stop, ...params.stop } : params.stop;
}
// Inactivity Status
if (params.inactivityStatus) {

Send only one end of charge notification