Send OCPI Cdr only when there is charging periods and consumption
MODIFY
src/client/ocpi/CpoOCPIClient.ts
src/client/ocpi/CpoOCPIClient.ts
@@ -410,6 +410,9 @@ export default class CpoOCPIClient extends OCPIClient {
charging_periods: await this.buildChargingPeriods(this.tenant, transaction),
last_updated: transaction.stop.timestamp
};
+ // Send CDR only if there is charging periods and consummed energy
+ if (!Utils.isEmptyArray(transaction.ocpiData.cdr.charging_periods) &&
+ transaction.ocpiData.cdr.total_energy > 0) {
// Call IOP
const response = await this.axiosInstance.post(
cdrsUrl,
@@ -430,9 +433,23 @@ export default class CpoOCPIClient extends OCPIClient {
action: ServerAction.OCPI_PUSH_CDRS,
message: `${Utils.buildConnectorInfo(transaction.connectorId, transaction.id)} OCPI CDR has been sent successfully`,
module: MODULE_NAME, method: 'postCdr',
- detailedMessages: { cdr: transaction.ocpiData.cdr, response: response.data }
+ detailedMessages: { response: response.data, transaction }
+ });
+ } else {
+ await Logging.logWarning({
+ tenantID: this.tenant.id,
+ siteID: transaction.siteID,
+ siteAreaID: transaction.siteAreaID,
+ companyID: transaction.companyID,
+ chargingStationID: transaction.chargeBoxID,
+ source: transaction.chargeBoxID,
+ action: ServerAction.OCPI_PUSH_CDRS,
+ message: `${Utils.buildConnectorInfo(transaction.connectorId, transaction.id)} OCPI CDR has no consumption and will be be ignored`,
+ module: MODULE_NAME, method: 'postCdr',
+ detailedMessages: { transaction }
});
}
+ }
public async updateChargingStationStatus(chargingStation: ChargingStation, status?: OCPIEvseStatus): Promise<void> {
if (!chargingStation.siteAreaID) {

Send OCPI Cdr only when there is charging periods and consumption