transaction - soft stop - log warning
MODIFY
src/server/ocpp/services/OCPPService.ts
src/server/ocpp/services/OCPPService.ts
@@ -798,8 +798,9 @@ export default class OCPPService {
// Get the last transaction
const lastTransaction = await TransactionStorage.getLastTransactionFromChargingStation(
tenant, chargingStation.id, connector.connectorId, { withUser: true });
+ if (lastTransaction) {
// Transaction completed
- if (lastTransaction?.stop) {
+ if (lastTransaction.stop) {
// Check Inactivity
const transactionUpdated = await this.checkAndComputeTransactionExtraInactivityFromStatusNotification(
tenant, chargingStation, lastTransaction, connector, statusNotification);
@@ -815,9 +816,7 @@ export default class OCPPService {
if (transactionUpdated || billingDataUpdated || ocpiUpdated || oicpUpdated) {
await TransactionStorage.saveTransaction(tenant, lastTransaction);
}
- }
- // Clear Connector Runtime Data
- if (!Utils.isNullOrUndefined(lastTransaction)) {
+ } else {
await Logging.logWarning({
tenantID: tenant.id,
...LoggingHelper.getChargingStationProperties(chargingStation),
@@ -826,6 +825,8 @@ export default class OCPPService {
message: `${Utils.buildConnectorInfo(lastTransaction.connectorId, lastTransaction.id)} Received Status Notification '${statusNotification.status}' while a transaction is ongoing`,
detailedMessages: { statusNotification }
});
+ }
+ // Clear Connector Runtime Data
OCPPUtils.clearChargingStationConnectorRuntimeData(chargingStation, lastTransaction.connectorId);
}
}

transaction - soft stop - log warning