Return if the OCPI CDRs has been sent successfully
MODIFY
src/client/ocpi/CpoOCPIClient.ts
src/client/ocpi/CpoOCPIClient.ts
@@ -385,7 +385,7 @@ export default class CpoOCPIClient extends OCPIClient {
});
}
- public async pushCdr(transaction: Transaction): Promise<void> {
+ public async pushCdr(transaction: Transaction): Promise<boolean> {
if (!transaction.stop) {
throw new BackendError({
...LoggingHelper.getTransactionProperties(transaction),
@@ -449,7 +449,8 @@ export default class CpoOCPIClient extends OCPIClient {
module: MODULE_NAME, method: 'postCdr',
detailedMessages: { response: response.data, transaction }
});
- } else {
+ return true;
+ }
await Logging.logWarning({
...LoggingHelper.getTransactionProperties(transaction),
tenantID: this.tenant.id,
@@ -458,7 +459,7 @@ export default class CpoOCPIClient extends OCPIClient {
module: MODULE_NAME, method: 'postCdr',
detailedMessages: { transaction }
});
- }
+ return false;
}
public async patchChargingStationStatus(chargingStation: ChargingStation, status?: OCPIEvseStatus): Promise<void> {

MODIFY
src/server/ocpi/OCPIFacade.ts
src/server/ocpi/OCPIFacade.ts
@@ -86,12 +86,11 @@ export default class OCPIFacade {
const ocpiClient = await OCPIFacade.checkAndGetOcpiCpoClient(
tenant, transaction, user, action);
// Send OCPI CDR
- await ocpiClient.pushCdr(transaction);
+ return ocpiClient.pushCdr(transaction);
}
public static async checkAndSendTransactionCdr(tenant: Tenant, transaction: Transaction,
chargingStation: ChargingStation, siteArea: SiteArea, action: ServerAction): Promise<boolean> {
- let ocpiCdrSent = false;
// CDR not already pushed
if (Utils.isTenantComponentActive(tenant, TenantComponents.OCPI) &&
transaction.ocpiData?.session && !transaction.ocpiData.cdr?.id) {
@@ -100,7 +99,7 @@ export default class OCPIFacade {
if (ocpiLock) {
try {
// Roaming
- ocpiCdrSent = await OCPIFacade.processEndTransaction(
+ return OCPIFacade.processEndTransaction(
tenant, transaction, chargingStation, siteArea, transaction.user, action);
} finally {
// Release the lock
@@ -108,7 +107,6 @@ export default class OCPIFacade {
}
}
}
- return ocpiCdrSent;
}
public static async updateConnectorStatus(tenant: Tenant, chargingStation: ChargingStation, connector: Connector): Promise<void> {

Return if the OCPI CDRs has been sent successfully