Added targetStateOfCharge to transaction
MODIFY
src/assets/server/rest/v1/docs/e-mobility-oas.json
src/assets/server/rest/v1/docs/e-mobility-oas.json
"type": "string",
"format": "date-time"
},
+ "targetStateOfCharge": {
+ "type": "integer",
+ "example": ""
+ },
"args": {
"type": "object",
"properties": {

MODIFY
src/assets/server/rest/v1/schemas/chargingstation/chargingstation-action-transaction-start.json
src/assets/server/rest/v1/schemas/chargingstation/chargingstation-action-transaction-start.json
"customType": "date",
"sanitize": "mongo"
},
+ "targetStateOfCharge": {
+ "type": "integer",
+ "sanitize": "mongo",
+ "minimum": 1,
+ "maximum": 100
+ },
"args": {
"type": "object",
"properties": {

MODIFY
src/server/ocpp/services/OCPPService.ts
src/server/ocpp/services/OCPPService.ts
@@ -1381,6 +1381,7 @@ export default class OCPPService {
transaction.carStateOfCharge = user.startTransactionData.lastCarStateOfCharge;
transaction.carOdometer = user.startTransactionData.lastCarOdometer;
transaction.departureTime = user.startTransactionData.lastDepartureTime;
+ transaction.targetStateOfCharge = user.startTransactionData.lastTargetStateOfCharge;
} else {
// Get default car if any
const defaultCar = await CarStorage.getDefaultUserCar(tenant, user.id, {},
@@ -1405,7 +1406,8 @@ export default class OCPPService {
lastSelectedCar: false,
lastCarStateOfCharge: null,
lastCarOdometer: null,
- lastDepartureTime: null
+ lastDepartureTime: null,
+ lastTargetStateOfCharge: null
});
// Handle SoC
soc = await this.getCurrentSoc(tenant, transaction, chargingStation);

MODIFY
src/server/rest/v1/service/ChargingStationService.ts
src/server/rest/v1/service/ChargingStationService.ts
@@ -1266,7 +1266,8 @@ export default class ChargingStationService {
lastSelectedCar: true,
lastCarStateOfCharge: filteredRequest.carStateOfCharge,
lastCarOdometer: filteredRequest.carOdometer,
- lastDepartureTime: filteredRequest.departureTime
+ lastDepartureTime: filteredRequest.departureTime,
+ lastTargetStateOfCharge: filteredRequest.targetStateOfCharge,
});
}
// Execute it

MODIFY
src/server/rest/v1/service/TransactionService.ts
src/server/rest/v1/service/TransactionService.ts
@@ -383,6 +383,8 @@ export default class TransactionService {
}
public static async handleTransactionStart(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
+ // Cache request to avoid modifications from validator
+ const cachedReq = Utils.cloneObject(req);
// Filter
const remoteStartRequest = ChargingStationValidatorRest.getInstance().validateChargingStationActionTransactionStartReq(req.body);
// Get data
@@ -392,11 +394,11 @@ export default class TransactionService {
if (chargingStation.issuer) {
// OCPP Remote Start
await ChargingStationService.handleOcppAction(
- ServerAction.CHARGING_STATION_REMOTE_START_TRANSACTION, req, res, next);
+ ServerAction.CHARGING_STATION_REMOTE_START_TRANSACTION, cachedReq, res, next);
} else {
// OCPI Remote Start
await ChargingStationService.handleOcpiAction(
- ServerAction.OCPI_EMSP_START_SESSION, req, res, next);
+ ServerAction.OCPI_EMSP_START_SESSION, cachedReq, res, next);
}
}
@@ -1127,7 +1129,7 @@ export default class TransactionService {
// Get the transactions
const transactions = await TransactionStorage.getTransactions(req.tenant,
{
- status: filteredRequest.Status as TransactionStatus,
+ status: filteredRequest.Status ,
chargingStationIDs: filteredRequest.ChargingStationID ? filteredRequest.ChargingStationID.split('|') : null,
issuer: Utils.objectHasProperty(filteredRequest, 'Issuer') ? filteredRequest.Issuer : null,
userIDs: filteredRequest.UserID ? filteredRequest.UserID.split('|') : null,

MODIFY
src/storage/mongodb/TransactionStorage.ts
src/storage/mongodb/TransactionStorage.ts
@@ -60,6 +60,7 @@ export default class TransactionStorage {
carStateOfCharge: Utils.convertToInt(transactionToSave.carStateOfCharge),
carOdometer: Utils.convertToInt(transactionToSave.carOdometer),
departureTime: Utils.convertToDate(transactionToSave.departureTime),
+ targetStateOfCharge: Utils.convertToInt(transactionToSave.targetStateOfCharge),
userID: DatabaseUtils.convertToObjectID(transactionToSave.userID),
chargeBoxID: transactionToSave.chargeBoxID,
meterStart: Utils.convertToInt(transactionToSave.meterStart),

MODIFY
src/types/Transaction.ts
src/types/Transaction.ts
@@ -85,6 +85,7 @@ export default interface Transaction extends AbstractCurrentConsumption {
carStateOfCharge?: number;
carOdometer?: number;
departureTime?: Date;
+ targetStateOfCharge?: number;
phasesUsed?: CSPhasesUsed;
companyID?: string;
company?: Company;

MODIFY
src/types/User.ts
src/types/User.ts
@@ -52,6 +52,7 @@ export interface StartTransactionUserData {
lastCarStateOfCharge: number;
lastCarOdometer: number;
lastDepartureTime: Date;
+ lastTargetStateOfCharge: number;
}
export interface UserSite {

MODIFY
src/types/requests/HttpChargingStationRequest.ts
src/types/requests/HttpChargingStationRequest.ts
@@ -160,6 +160,7 @@ export interface HttpChargingStationTransactionStartRequest extends HttpCharging
carStateOfCharge?: number,
carOdometer?: number,
departureTime?: Date,
+ targetStateOfCharge?: number,
args: {
connectorId: number,
tagID?: string,

Added targetStateOfCharge to transaction