Check OCPI Session/Cdr not null
MODIFY
src/client/ocpi/CpoOCPIClient.ts
src/client/ocpi/CpoOCPIClient.ts
@@ -621,7 +621,7 @@ export default class CpoOCPIClient extends OCPIClient {
result.failure++;
result.objectIDsInFailure.push(String(transaction.id));
result.logs.push(
- `Failed to check CDR of OCPI Transaction ID '${transaction.ocpiData.session.id}' (ID '${transaction.id}'): ${error.message}`
+ `Failed to check CDR of OCPI Transaction ID '${transaction.id}': ${error.message}`
);
}
result.total++;
@@ -700,7 +700,7 @@ export default class CpoOCPIClient extends OCPIClient {
result.failure++;
result.objectIDsInFailure.push(evse.chargeBoxId);
result.logs.push(
- `Update status failed on Location ID '${location.id}', Charging Station ID '${evse.evse_id}': ${error.message}`
+ `Update status failed on Location '${location.name}' with ID '${location.id}', Charging Station ID '${evse.evse_id}': ${error.message}`
);
}
if (result.failure > 0) {
@@ -835,8 +835,11 @@ export default class CpoOCPIClient extends OCPIClient {
module: MODULE_NAME, method: 'checkCdr',
});
}
- const cdrsUrl = this.getEndpointUrl('cdrs', ServerAction.OCPI_CHECK_CDRS);
+ // Mark it as done (checked at least once)
+ transaction.ocpiData.cdrCheckedOn = new Date();
+ await TransactionStorage.saveTransactionOcpiData(this.tenant.id, transaction.id, transaction.ocpiData);
// Check CDR
+ const cdrsUrl = this.getEndpointUrl('cdrs', ServerAction.OCPI_CHECK_CDRS);
const response = await this.axiosInstance.get(
`${cdrsUrl}/${transaction.ocpiData.cdr.id}`,
{
@@ -844,9 +847,6 @@ export default class CpoOCPIClient extends OCPIClient {
'Authorization': `Token ${this.ocpiEndpoint.token}`
},
});
- // Mark it as done (checked at least once)
- transaction.ocpiData.cdrCheckedOn = new Date();
- await TransactionStorage.saveTransactionOcpiData(this.tenant.id, transaction.id, transaction.ocpiData);
// Create if it does not exit
if (response.data.status_code === 3001) {
await Logging.logError({
@@ -910,8 +910,11 @@ export default class CpoOCPIClient extends OCPIClient {
module: MODULE_NAME, method: 'checkSession',
});
}
+ // Mark it as done (checked at least once)
+ transaction.ocpiData.sessionCheckedOn = new Date();
+ await TransactionStorage.saveTransactionOcpiData(this.tenant.id, transaction.id, transaction.ocpiData);
+ // Check Session
const sessionsUrl = `${this.getEndpointUrl('sessions', ServerAction.OCPI_CHECK_SESSIONS)}/${this.getLocalCountryCode(ServerAction.OCPI_CHECK_SESSIONS)}/${this.getLocalPartyID(ServerAction.OCPI_CHECK_SESSIONS)}/${transaction.ocpiData.session.id}`;
- // Check
const response = await this.axiosInstance.get(
sessionsUrl,
{
@@ -919,9 +922,6 @@ export default class CpoOCPIClient extends OCPIClient {
'Authorization': `Token ${this.ocpiEndpoint.token}`
},
});
- // Mark it as done (checked at least once)
- transaction.ocpiData.sessionCheckedOn = new Date();
- await TransactionStorage.saveTransactionOcpiData(this.tenant.id, transaction.id, transaction.ocpiData);
if (OCPIUtilsService.isSuccessResponse(response.data)) {
const session = response.data.data as OCPISession;
if (session) {
@@ -976,7 +976,7 @@ export default class CpoOCPIClient extends OCPIClient {
if (!result) {
throw new BackendError({
action: ServerAction.OCPI_CHECK_LOCATIONS,
- message: `Failed to check Location ID '${location.id}'`,
+ message: `Failed to check Location '${location.name}' with ID '${location.id}'`,
module: MODULE_NAME, method: 'checkLocation',
detailedMessages: { location, ocpiLocation }
});
@@ -984,7 +984,7 @@ export default class CpoOCPIClient extends OCPIClient {
await Logging.logInfo({
tenantID: this.tenant.id,
action: ServerAction.OCPI_CHECK_LOCATIONS,
- message: `Location ID '${location.id}' checked successfully`,
+ message: `Location '${location.name}' with ID '${location.id}' checked successfully`,
module: MODULE_NAME, method: 'checkLocation',
detailedMessages: { location, ocpiLocation }
});

MODIFY
src/client/ocpi/EmspOCPIClient.ts
src/client/ocpi/EmspOCPIClient.ts
@@ -378,7 +378,7 @@ export default class EmspOCPIClient extends OCPIClient {
if (!evse.uid) {
throw new BackendError({
action: ServerAction.OCPI_PULL_LOCATIONS,
- message: `Missing Charging Station EVSE UID in Location ID '${location.id}'`,
+ message: `Missing Charging Station EVSE UID in Location '${location.name}' with ID '${location.id}'`,
module: MODULE_NAME, method: 'processLocation',
detailedMessages: { evse, location }
});
@@ -393,7 +393,7 @@ export default class EmspOCPIClient extends OCPIClient {
await Logging.logDebug({
tenantID: this.tenant.id,
action: ServerAction.OCPI_PULL_LOCATIONS,
- message: `Removed Charging Station EVSE UID '${evse.uid}' in Location ID '${location.id}'`,
+ message: `Removed Charging Station EVSE UID '${evse.uid}' in Location '${location.name}' with ID '${location.id}'`,
module: MODULE_NAME, method: 'processLocation',
detailedMessages: { evse, location }
});

MODIFY
src/server/ocpi/ocpi-services-impl/ocpi-2.1.1/emsp/EMSPLocationsEndpoint.ts
src/server/ocpi/ocpi-services-impl/ocpi-2.1.1/emsp/EMSPLocationsEndpoint.ts
@@ -302,7 +302,7 @@ export default class EMSPLocationsEndpoint extends AbstractEndpoint {
await Logging.logInfo({
tenantID: tenant.id,
action: ServerAction.OCPI_PATCH_LOCATION,
- message: `Charging Station '${evse.uid}' of Location ID '${location.id}' has been deleted`,
+ message: `Charging Station '${evse.uid}' of Location '${location.name}' with ID '${location.id}' has been deleted`,
source: Constants.CENTRAL_SERVER,
module: MODULE_NAME, method: 'updateEvse',
detailedMessages: location
@@ -315,7 +315,7 @@ export default class EMSPLocationsEndpoint extends AbstractEndpoint {
await Logging.logDebug({
tenantID: tenant.id,
action: ServerAction.OCPI_PATCH_LOCATION,
- message: `Charging Station '${evse.uid}' of Location ID '${location.id}' has been updated`,
+ message: `Charging Station '${evse.uid}' of Location '${location.name}' with ID '${location.id}' has been updated`,
source: Constants.CENTRAL_SERVER,
module: MODULE_NAME, method: 'updateEvse',
detailedMessages: location
@@ -332,7 +332,7 @@ export default class EMSPLocationsEndpoint extends AbstractEndpoint {
action: ServerAction.OCPI_PUT_LOCATION,
module: MODULE_NAME, method: 'updateConnector',
errorCode: StatusCodes.NOT_FOUND,
- message: `Unknown Charging Station with EVSE UID '${evse.uid}' and Location ID '${location.id}'`,
+ message: `Unknown Charging Station with EVSE UID '${evse.uid}' and Location '${location.name}' with ID '${location.id}'`,
ocpiError: OCPIStatusCode.CODE_2003_UNKNOWN_LOCATION_ERROR,
detailedMessages: { location, evse }
});

MODIFY
src/storage/mongodb/TransactionStorage.ts
src/storage/mongodb/TransactionStorage.ts
@@ -471,7 +471,7 @@ export default class TransactionStorage {
}
if (Utils.objectHasProperty(params, 'ocpiSessionChecked')) {
filters.stop = { $exists: true };
- filters['ocpiData.session'] = { $exists: true };
+ filters['ocpiData.session'] = { $exists: true, $ne: null };
filters['ocpiData.sessionCheckedOn'] = { $exists: params.ocpiSessionChecked };
}
// OCPI Cdr Date provided?
@@ -487,7 +487,7 @@ export default class TransactionStorage {
}
if (Utils.objectHasProperty(params, 'ocpiCdrChecked')) {
filters.stop = { $exists: true };
- filters['ocpiData.cdr'] = { $exists: true };
+ filters['ocpiData.cdr'] = { $exists: true, $ne: null };
filters['ocpiData.cdrCheckedOn'] = { $exists: params.ocpiCdrChecked };
}
// Check stop transaction

Check OCPI Session/Cdr not null