Renamed transaction's timestamp
MODIFY
src/client/ocpi/CpoOCPIClient.ts
src/client/ocpi/CpoOCPIClient.ts
@@ -298,7 +298,7 @@ export default class CpoOCPIClient extends OCPIClient {
const sessionsUrl = `${this.getEndpointUrl('sessions', ServerAction.OCPI_PUSH_SESSIONS)}/${this.getLocalCountryCode(ServerAction.OCPI_PUSH_SESSIONS)}/${this.getLocalPartyID(ServerAction.OCPI_PUSH_SESSIONS)}/${transaction.ocpiData.session.id}`;
transaction.ocpiData.session.kwh = transaction.currentTotalConsumptionWh / 1000;
// eslint-disable-next-line @typescript-eslint/camelcase
- transaction.ocpiData.session.last_updated = transaction.lastUpdate;
+ transaction.ocpiData.session.last_updated = transaction.currentTimestamp;
// eslint-disable-next-line @typescript-eslint/camelcase
transaction.ocpiData.session.total_cost = transaction.currentCumulatedPrice;
transaction.ocpiData.session.currency = transaction.priceUnit;

MODIFY
src/server/ocpi/ocpi-services-impl/ocpi-2.1.1/OCPIMapping.ts
src/server/ocpi/ocpi-services-impl/ocpi-2.1.1/OCPIMapping.ts
@@ -580,7 +580,7 @@ export default class OCPIMapping {
});
const inactivity: number = transaction.stop ? transaction.stop.totalInactivitySecs : transaction.currentTotalInactivitySecs;
if (inactivity > 0) {
- const inactivityStart = transaction.stop ? transaction.stop.timestamp : transaction.lastUpdate;
+ const inactivityStart = transaction.stop ? transaction.stop.timestamp : transaction.currentTimestamp;
chargingPeriods.push({
// eslint-disable-next-line @typescript-eslint/camelcase
start_date_time: moment(inactivityStart).subtract(inactivity, 'seconds').toDate(),

MODIFY
src/server/ocpi/ocpi-services-impl/ocpi-2.1.1/OCPISessionsService.ts
src/server/ocpi/ocpi-services-impl/ocpi-2.1.1/OCPISessionsService.ts
@@ -119,7 +119,7 @@ export default class OCPISessionsService {
tenantID: tenantId,
source: Constants.CENTRAL_SERVER,
module: MODULE_NAME, method: 'updateSession',
- message: `Ignore session update session.last_updated < transaction.lastUpdate for transaction ${transaction.id}`,
+ message: `Ignore session update session.last_updated < transaction.currentTimestamp for transaction ${transaction.id}`,
detailedMessages: { session }
});
return;
@@ -131,7 +131,7 @@ export default class OCPISessionsService {
transaction.ocpiData = {};
}
transaction.ocpiData.session = session;
- transaction.lastUpdate = session.last_updated;
+ transaction.currentTimestamp = session.last_updated;
transaction.price = session.total_cost;
transaction.priceUnit = session.currency;
transaction.roundedPrice = Utils.convertToFloat(session.total_cost.toFixed(2));
@@ -206,7 +206,7 @@ export default class OCPISessionsService {
transaction.priceUnit = cdr.currency;
transaction.price = cdr.total_cost;
transaction.roundedPrice = Utils.convertToFloat(cdr.total_cost.toFixed(2));
- transaction.lastUpdate = cdr.last_updated;
+ transaction.currentTimestamp = cdr.last_updated;
transaction.stop = {
extraInactivityComputed: false,
extraInactivitySecs: 0,

MODIFY
src/server/ocpp/services/OCPPService.ts
src/server/ocpp/services/OCPPService.ts
@@ -1102,7 +1102,7 @@ export default class OCPPService {
chargingStation: ChargingStation, meterValue: OCPPNormalizedMeterValue): Promise<Consumption> {
// Get the last one
const lastMeterValue = transaction.lastMeterValue;
- // State of Charge
+ // State of Charge ----------------------------------------------
if (OCPPUtils.isSocMeterValue(meterValue)) {
// Set current
transaction.currentStateOfCharge = Utils.convertToFloat(meterValue.value);
@@ -1110,7 +1110,7 @@ export default class OCPPService {
if (transaction.stateOfCharge === 0) {
transaction.stateOfCharge = transaction.currentStateOfCharge;
}
- // Energy Active Import (Wh)?
+ // Energy Active Import (Wh) ------------------------------------
} else if (OCPPUtils.isEnergyActiveImportMeterValue(meterValue)) {
// Update Transaction
transaction.numberOfMeterValues++;
@@ -1132,7 +1132,7 @@ export default class OCPPService {
// Update current consumption
transaction.currentConsumptionWh = currentConsumptionWh;
transaction.currentInstantWatts = currentConsumptionWatts;
- transaction.lastUpdate = meterValue.timestamp;
+ transaction.currentTimestamp = meterValue.timestamp;
transaction.currentTotalConsumptionWh += currentConsumptionWh;
// Inactivity?
if (currentConsumptionWh === 0) {
@@ -1263,7 +1263,7 @@ export default class OCPPService {
const consumption: Consumption = await this.buildConsumptionWithMeterValue(
tenantID, transaction, chargingStation, meterValue);
if (consumption) {
- // Existing Consumption (SoC or Consumption MeterValue)?
+ // Existing Consumption created?
const existingConsumption = consumptions.find(
(c) => c.endedAt.getTime() === consumption.endedAt.getTime());
if (existingConsumption) {
@@ -1272,7 +1272,7 @@ export default class OCPPService {
existingConsumption[property] = consumption[property];
}
} else {
- // Add
+ // Add new
consumptions.push(consumption);
}
}

MODIFY
src/types/Transaction.ts
src/types/Transaction.ts
@@ -71,7 +71,7 @@ export default interface Transaction {
pricingSource?: string;
stateOfCharge: number;
timezone: string;
- lastUpdate?: Date;
+ currentTimestamp?: Date;
currentTotalInactivitySecs: number;
currentInactivityStatus?: InactivityStatus;
currentStateOfCharge: number;

Renamed transaction's timestamp