Fixed log OCPI error + Fix manual push of CDR
MODIFY
src/scheduler/tasks/ocpi/OCPIPushCdrsTask.ts
src/scheduler/tasks/ocpi/OCPIPushCdrsTask.ts
@@ -95,11 +95,12 @@ export default class OCPIPushCdrsTask extends SchedulerTask {
detailedMessages: { cdr: transaction.ocpiData.cdr }
});
} catch (error) {
- await Logging.logInfo({
+ await Logging.logError({
tenantID: tenant.id,
action: ServerAction.OCPI_PUSH_CDRS,
module: MODULE_NAME, method: 'processTenant',
message: `Failed to pushed the CDR of the Transaction ID '${transactionMDB._id}' to OCPI`,
+ detailedMessages: { error: error.message, stack: error.stack, transaction: transactionMDB }
});
} finally {
// Release the lock

MODIFY
src/server/rest/v1/service/TransactionService.ts
src/server/rest/v1/service/TransactionService.ts
@@ -207,7 +207,16 @@ export default class TransactionService {
user: req.user, action: action
});
}
- // Check if transaction was handled with Gireve or Hubject
+ // No Roaming Cdr to push
+ if (!transaction.oicpData.session && !transaction.ocpiData.session) {
+ throw new AppError({
+ source: Constants.CENTRAL_SERVER,
+ errorCode: HTTPError.TRANSACTION_WITH_NO_OCPI_DATA,
+ message: `The transaction ID '${transaction.id}' has no OCPI or OICP session data`,
+ module: MODULE_NAME, method: 'handlePushTransactionCdr',
+ user: req.user, action: action
+ });
+ }
// Check OCPI
if (transaction.ocpiData.session) {
// CDR already pushed
@@ -226,6 +235,8 @@ export default class TransactionService {
try {
// Post CDR
await OCPPUtils.processOCPITransaction(req.user.tenantID, transaction, chargingStation, TransactionAction.END);
+ // Save
+ await TransactionStorage.saveTransaction(req.user.tenantID, transaction);
// Ok
await Logging.logInfo({
tenantID: req.user.tenantID,
@@ -260,37 +271,6 @@ export default class TransactionService {
try {
// Post CDR
await OCPPUtils.processOICPTransaction(req.user.tenantID, transaction, chargingStation, TransactionAction.END);
- // Ok
- await Logging.logInfo({
- tenantID: req.user.tenantID,
- action: action,
- user: req.user, actionOnUser: (transaction.user ? transaction.user : null),
- module: MODULE_NAME, method: 'handlePushTransactionCdr',
- message: `CDR of Transaction ID '${transaction.id}' has been pushed successfully`,
- detailedMessages: { cdr: transaction.ocpiData.cdr }
- });
- } finally {
- // Release the lock
- await LockingManager.release(oicpLock);
- }
- }
- }
- // No Roaming Cdr to push
- if (!transaction.oicpData.session && !transaction.ocpiData.session) {
- throw new AppError({
- source: Constants.CENTRAL_SERVER,
- errorCode: HTTPError.TRANSACTION_WITH_NO_OCPI_DATA,
- message: `The transaction ID '${transaction.id}' has no OCPI or OICP session data`,
- module: MODULE_NAME, method: 'handlePushTransactionCdr',
- user: req.user, action: action
- });
- }
- // Get the lock
- const ocpiLock = await LockingHelper.createOCPIPushCdrLock(req.user.tenantID, transaction.id);
- if (ocpiLock) {
- try {
- // Post CDR
- await OCPPUtils.processOCPITransaction(req.user.tenantID, transaction, chargingStation, TransactionAction.END);
// Save
await TransactionStorage.saveTransaction(req.user.tenantID, transaction);
// Ok
@@ -304,7 +284,8 @@ export default class TransactionService {
});
} finally {
// Release the lock
- await LockingManager.release(ocpiLock);
+ await LockingManager.release(oicpLock);
+ }
}
}
res.json(Constants.REST_RESPONSE_SUCCESS);

Fixed log OCPI error + Fix manual push of CDR