Fixed OCPI CDR is sent multiple times on OCPP status notification
MODIFY
src/scheduler/tasks/ocpi/OCPICheckCdrsTask.ts
src/scheduler/tasks/ocpi/OCPICheckCdrsTask.ts
@@ -62,7 +62,7 @@ export default class OCPICheckCdrsTask extends SchedulerTask {
tenantID: tenant.id,
module: MODULE_NAME, method: 'processOCPIEndpoint',
action: ServerAction.OCPI_CHECK_CDRS,
- message: `The check CDRs process for endpoint '${ocpiEndpoint.name}' is being processed`
+ message: `The check of CDRs for endpoint '${ocpiEndpoint.name}' is being processed...`
});
// Build OCPI Client
const ocpiClient = await OCPIClientFactory.getCpoOcpiClient(tenant, ocpiEndpoint);
@@ -71,7 +71,7 @@ export default class OCPICheckCdrsTask extends SchedulerTask {
tenantID: tenant.id,
module: MODULE_NAME, method: 'processOCPIEndpoint',
action: ServerAction.OCPI_CHECK_CDRS,
- message: `The check CDRs process for endpoint '${ocpiEndpoint.name}' is completed`,
+ message: `The check of CDRs for endpoint '${ocpiEndpoint.name}' is completed`,
detailedMessages: { result }
});
} catch (error) {

MODIFY
src/scheduler/tasks/ocpi/OCPIPushCdrsTask.ts
src/scheduler/tasks/ocpi/OCPIPushCdrsTask.ts
@@ -61,7 +61,7 @@ export default class OCPIPushCdrsTask extends SchedulerTask {
});
continue;
}
- if (transaction.ocpiData && transaction.ocpiData.cdr) {
+ if (transaction.ocpiData?.cdr) {
await Logging.logInfo({
tenantID: tenant.id,
action: ServerAction.OCPI_PUSH_CDRS,

MODIFY
src/server/ocpp/services/OCPPService.ts
src/server/ocpp/services/OCPPService.ts
@@ -1198,6 +1198,8 @@ export default class OCPPService {
}
private async checkAndSendOCPITransactionCdr(tenantID: string, transaction: Transaction, chargingStation: ChargingStation) {
+ // CDR not already pushed
+ if (transaction.ocpiData && !transaction.ocpiData.cdr?.id) {
// Get the lock
const ocpiLock = await LockingHelper.createOCPIPushCdrLock(tenantID, transaction.id);
if (ocpiLock) {
@@ -1210,8 +1212,11 @@ export default class OCPPService {
}
}
}
+ }
private async checkAndSendOICPTransactionCdr(tenantID: string, transaction: Transaction, chargingStation: ChargingStation) {
+ // CDR not already pushed
+ if (transaction.oicpData && !transaction.oicpData.cdr?.SessionID) {
// Get the lock
const oicpLock = await LockingHelper.createOICPPushCdrLock(tenantID, transaction.id);
if (oicpLock) {
@@ -1224,6 +1229,7 @@ export default class OCPPService {
}
}
}
+ }
private async checkStatusNotificationOngoingTransaction(tenantID: string, chargingStation: ChargingStation,
statusNotification: OCPPStatusNotificationRequestExtended, connector: Connector) {

Fixed OCPI CDR is sent multiple times on OCPP status notification