pricing - remove useless code
MODIFY
src/assets/server/rest/v1/schemas/user/user-default-tag-car-get.json
src/assets/server/rest/v1/schemas/user/user-default-tag-car-get.json
"ChargingStationID": {
"$ref": "chargingstation#/definitions/id"
},
- "ConnectorID": {
- "$ref": "chargingstation#/definitions/connector/properties/connectorId"
- },
"ProjectFields": {
"$ref": "common#/definitions/projectFields"
}

MODIFY
src/server/rest/v1/service/UserService.ts
src/server/rest/v1/service/UserService.ts
@@ -6,7 +6,6 @@ import { Car, CarType } from '../../../../types/Car';
import { DataResult, UserDataResult } from '../../../../types/DataResult';
import { HTTPAuthError, HTTPError } from '../../../../types/HTTPError';
import { NextFunction, Request, Response } from 'express';
-import { ResolvedPricingDefinition, ResolvedPricingModel } from '../../../../types/Pricing';
import Tenant, { TenantComponents } from '../../../../types/Tenant';
import User, { ImportedUser, UserRequiredImportProperties, UserRole } from '../../../../types/User';
@@ -18,7 +17,6 @@ import Authorizations from '../../../../authorization/Authorizations';
import BillingFactory from '../../../../integration/billing/BillingFactory';
import CSVError from 'csvtojson/v2/CSVError';
import CarStorage from '../../../../storage/mongodb/CarStorage';
-import ChargingStation from '../../../../types/ChargingStation';
import ChargingStationStorage from '../../../../storage/mongodb/ChargingStationStorage';
import Constants from '../../../../utils/Constants';
import EmspOCPIClient from '../../../../client/ocpi/EmspOCPIClient';
@@ -32,8 +30,6 @@ import OCPIClientFactory from '../../../../client/ocpi/OCPIClientFactory';
import { OCPIRole } from '../../../../types/ocpi/OCPIRole';
import { OCPITokenWhitelist } from '../../../../types/ocpi/OCPIToken';
import OCPIUtils from '../../../ocpi/OCPIUtils';
-import PricingFactory from '../../../../integration/pricing/PricingFactory';
-import PricingHelper from '../../../../integration/pricing/PricingHelper';
import { Readable } from 'stream';
import { ServerAction } from '../../../../types/Server';
import { StartTransactionErrorCode } from '../../../../types/Transaction';
@@ -86,7 +82,6 @@ export default class UserService {
}
}
let withBillingChecks = true ;
- let pricingDefinitions = null;
if (filteredRequest.ChargingStationID) {
// TODO - The ChargingStationID is optional but only for backward compatibility reasons - make it mandatory as soon as possible
const chargingStation = await ChargingStationStorage.getChargingStation(req.tenant, filteredRequest.ChargingStationID,
@@ -96,10 +91,6 @@ export default class UserService {
// The access control is switched off - so billing checks are useless
withBillingChecks = false;
}
- if (filteredRequest.ConnectorId) {
- // Fetch all pricing definitions matching the current context + connectorId
- pricingDefinitions = await UserService.fetchPricingDefinitions(action, req.tenant, req.user, user, chargingStation, filteredRequest.ConnectorId);
- }
}
// Check for billing errors
const errorCodes: Array<StartTransactionErrorCode> = [];
@@ -108,7 +99,7 @@ export default class UserService {
await UserService.checkBillingErrorCodes(action, req.tenant, req.user, user, errorCodes);
}
res.json({
- tag, car, errorCodes, pricingDefinitions
+ tag, car, errorCodes
});
next();
}
@@ -828,19 +819,6 @@ export default class UserService {
}
}
- private static async fetchPricingDefinitions(action: ServerAction, tenant: Tenant,
- loggedUser: UserToken, user: User, chargingStation: ChargingStation, connectorId: number) : Promise<ResolvedPricingDefinition[]> {
- if (Utils.isComponentActiveFromToken(loggedUser, TenantComponents.PRICING)) {
- const pricingImpl = await PricingFactory.getPricingImpl(tenant);
- if (pricingImpl) {
- const pricingContext = PricingHelper.buildUserPricingContext(tenant, user.id, chargingStation, connectorId, new Date());
- const pricingModel: ResolvedPricingModel = await pricingImpl.resolvePricingContext(pricingContext);
- return pricingModel.pricingDefinitions;
- }
- }
- return null;
- }
-
private static async checkBillingErrorCodes(action: ServerAction, tenant: Tenant,
loggedUser: UserToken, user: User, errorCodes: StartTransactionErrorCode[]) {
if (Utils.isComponentActiveFromToken(loggedUser, TenantComponents.BILLING)) {

MODIFY
src/types/requests/HttpUserRequest.ts
src/types/requests/HttpUserRequest.ts
@@ -103,5 +103,4 @@ export interface HttpEulaRequest {
export interface HttpUserDefaultTagCar {
UserID: string;
ChargingStationID?: string; // TODO: Backward-compatibility issue - This should be mandatory! - change it as soon as possible
- ConnectorId?: number
}

pricing - remove useless code