Removed getSettings in build of tariff
MODIFY
src/client/ocpi/CpoOCPIClient.ts
src/client/ocpi/CpoOCPIClient.ts
@@ -230,7 +230,7 @@ export default class CpoOCPIClient extends OCPIClient {
// Get tokens endpoint url
const sessionsUrl = `${this.getEndpointUrl('sessions', ServerAction.OCPI_PUSH_SESSIONS)}/${this.getLocalCountryCode(ServerAction.OCPI_PUSH_SESSIONS)}/${this.getLocalPartyID(ServerAction.OCPI_PUSH_SESSIONS)}/${transaction.id.toString()}`;
const site = await SiteStorage.getSite(this.tenant, chargingStation.siteID);
- const ocpiLocation: OCPILocation = await this.convertChargingStationToOCPILocation(this.tenant, site, chargingStation,
+ const ocpiLocation: OCPILocation = this.convertChargingStationToOCPILocation(this.tenant, site, chargingStation,
transaction.connectorId, this.getLocalCountryCode(ServerAction.OCPI_PUSH_SESSIONS), this.getLocalPartyID(ServerAction.OCPI_PUSH_SESSIONS));
// Build payload
const ocpiSession: OCPISession = {
@@ -576,7 +576,7 @@ export default class CpoOCPIClient extends OCPIClient {
partyID: this.getLocalPartyID(ServerAction.OCPI_CHECK_LOCATIONS)
};
// Get all EVSEs from all locations
- const locations = await OCPIUtilsService.getAllLocations(this.tenant, 0, 0, options, true);
+ const locations = await OCPIUtilsService.getAllLocations(this.tenant, 0, 0, options, true, this.settings);
if (!Utils.isEmptyArray(locations.result)) {
await Promise.map(locations.result, async (location) => {
if (location) {
@@ -688,7 +688,7 @@ export default class CpoOCPIClient extends OCPIClient {
chargeBoxIDsToProcess = _.uniq(chargeBoxIDsToProcess);
}
// Get all locations
- const locations = await OCPIUtilsService.getAllLocations(this.tenant, 0, 0, options, false);
+ const locations = await OCPIUtilsService.getAllLocations(this.tenant, 0, 0, options, false, this.settings);
if (!Utils.isEmptyArray(locations.result)) {
await Promise.map(locations.result, async (location) => {
// Get the Charging Station should be processed
@@ -702,7 +702,7 @@ export default class CpoOCPIClient extends OCPIClient {
}
evses = await OCPIUtilsService.getEvsesFromSite(this.tenant, location.id, options,
{ skip: currentSkip, limit: Constants.DB_RECORD_COUNT_DEFAULT },
- { chargingStationIDs });
+ { chargingStationIDs }, this.settings);
// Loop through EVSE
if (!Utils.isEmptyArray(evses)) {
await Promise.map(evses, async (evse) => {
@@ -1071,8 +1071,8 @@ export default class CpoOCPIClient extends OCPIClient {
return chargingPeriods;
}
- private async convertChargingStationToOCPILocation(tenant: Tenant, site: Site, chargingStation: ChargingStation,
- connectorID: number, countryID: string, partyID: string): Promise<OCPILocation> {
+ private convertChargingStationToOCPILocation(tenant: Tenant, site: Site, chargingStation: ChargingStation,
+ connectorID: number, countryID: string, partyID: string): OCPILocation {
const hasValidSiteGpsCoordinates = Utils.hasValidGpsCoordinates(site.address?.coordinates);
const hasValidChargingStationGpsCoordinates = Utils.hasValidGpsCoordinates(chargingStation?.coordinates);
const connectors: OCPIConnector[] = [];
@@ -1080,7 +1080,7 @@ export default class CpoOCPIClient extends OCPIClient {
const connector = Utils.getConnectorFromID(chargingStation, connectorID);
let chargePoint;
if (connector) {
- connectors.push(await OCPIUtilsService.convertConnector2OCPIConnector(tenant, chargingStation, connector, countryID, partyID));
+ connectors.push(OCPIUtilsService.convertConnector2OCPIConnector(tenant, chargingStation, connector, countryID, partyID, this.settings));
status = connector.status;
chargePoint = Utils.getChargePointFromID(chargingStation, connector.chargePointID);
}

MODIFY
src/client/ocpi/OCPIClient.ts
src/client/ocpi/OCPIClient.ts
@@ -134,6 +134,10 @@ export default abstract class OCPIClient {
return response.data?.data;
}
+ public getSettings(): OcpiSetting {
+ return this.settings;
+ }
+
public async getEndpointVersions(): Promise<OCPIEndpointVersions> {
await Logging.logInfo({
tenantID: this.tenant.id,

MODIFY
src/client/ocpi/OCPIClientFactory.ts
src/client/ocpi/OCPIClientFactory.ts
@@ -17,7 +17,7 @@ import Utils from '../../utils/Utils';
const MODULE_NAME = 'OCPIClientFactory';
export default class OCPIClientFactory {
- static async getOcpiClient(tenant: Tenant, ocpiEndpoint: OCPIEndpoint): Promise<CpoOCPIClient|EmspOCPIClient> {
+ public static async getOcpiClient(tenant: Tenant, ocpiEndpoint: OCPIEndpoint): Promise<CpoOCPIClient|EmspOCPIClient> {
// Check if OCPI component is active
if (Utils.isTenantComponentActive(tenant, TenantComponents.OCPI)) {
const ocpiSettings = await SettingStorage.getOCPISettings(tenant);
@@ -47,7 +47,7 @@ export default class OCPIClientFactory {
}
}
- static async getCpoOcpiClient(tenant: Tenant, ocpiEndpoint: OCPIEndpoint): Promise<CpoOCPIClient> {
+ public static async getCpoOcpiClient(tenant: Tenant, ocpiEndpoint: OCPIEndpoint): Promise<CpoOCPIClient> {
if (ocpiEndpoint.role === OCPIRole.CPO) {
const client = await OCPIClientFactory.getOcpiClient(tenant, ocpiEndpoint);
return client as CpoOCPIClient;
@@ -60,7 +60,7 @@ export default class OCPIClientFactory {
});
}
- static async getEmspOcpiClient(tenant: Tenant, ocpiEndpoint: OCPIEndpoint): Promise<EmspOCPIClient> {
+ public static async getEmspOcpiClient(tenant: Tenant, ocpiEndpoint: OCPIEndpoint): Promise<EmspOCPIClient> {
if (ocpiEndpoint.role === OCPIRole.EMSP) {
const client = await OCPIClientFactory.getOcpiClient(tenant, ocpiEndpoint);
return client as EmspOCPIClient;
@@ -73,7 +73,7 @@ export default class OCPIClientFactory {
});
}
- static async getAvailableOcpiClient(tenant: Tenant, ocpiRole: OCPIRole): Promise<CpoOCPIClient|EmspOCPIClient> {
+ public static async getAvailableOcpiClient(tenant: Tenant, ocpiRole: OCPIRole): Promise<CpoOCPIClient|EmspOCPIClient> {
const ocpiEndpoints = await OCPIEndpointStorage.getOcpiEndpoints(tenant, { role: ocpiRole }, Constants.DB_PARAMS_MAX_LIMIT);
for (const ocpiEndpoint of ocpiEndpoints.result) {
if (ocpiEndpoint.status === OCPIRegistrationStatus.REGISTERED) {
@@ -83,7 +83,7 @@ export default class OCPIClientFactory {
}
}
- static async getChargingStationClient(tenant: Tenant, chargingStation: ChargingStation): Promise<OCPIChargingStationClient> {
+ public static async getChargingStationClient(tenant: Tenant, chargingStation: ChargingStation): Promise<OCPIChargingStationClient> {
const ocpiEndpoints = await OCPIEndpointStorage.getOcpiEndpoints(tenant, { role: OCPIRole.EMSP }, Constants.DB_PARAMS_MAX_LIMIT);
for (const ocpiEndpoint of ocpiEndpoints.result) {
if (ocpiEndpoint.status === OCPIRegistrationStatus.REGISTERED) {

MODIFY
src/server/ocpi/ocpi-services-impl/AbstractEndpoint.ts
src/server/ocpi/ocpi-services-impl/AbstractEndpoint.ts
@@ -5,13 +5,9 @@ import OCPIEndpoint from '../../../types/ocpi/OCPIEndpoint';
import { OCPIResponse } from '../../../types/ocpi/OCPIResponse';
import Tenant from '../../../types/Tenant';
-/**
- * Abstract Endpoint
- */
export default abstract class AbstractEndpoint {
-
// Create OCPI Service
- constructor(readonly ocpiService: AbstractOCPIService, readonly identifier: string = 'default') {
+ public constructor(protected readonly ocpiService: AbstractOCPIService, protected readonly identifier: string = 'default') {
}
// Get Endpoint Identifier

MODIFY
src/server/ocpi/ocpi-services-impl/ocpi-2.1.1/cpo/CPOLocationsEndpoint.ts
src/server/ocpi/ocpi-services-impl/ocpi-2.1.1/cpo/CPOLocationsEndpoint.ts
@@ -13,6 +13,7 @@ import { OCPIResponse } from '../../../../../types/ocpi/OCPIResponse';
import { OCPIStatusCode } from '../../../../../types/ocpi/OCPIStatusCode';
import OCPIUtils from '../../../OCPIUtils';
import OCPIUtilsService from '../OCPIUtilsService';
+import { OcpiSetting } from '../../../../../types/Setting';
import { ServerAction } from '../../../../../types/Server';
import SiteStorage from '../../../../../storage/mongodb/SiteStorage';
import Tenant from '../../../../../types/Tenant';
@@ -54,7 +55,7 @@ export default class CPOLocationsEndpoint extends AbstractEndpoint {
};
// Process request
if (locationId && evseUid && evseConnectorId) {
- evseConnector = await this.getConnector(tenant, locationId, evseUid, evseConnectorId, options);
+ evseConnector = await this.getConnector(tenant, locationId, evseUid, evseConnectorId, options, ocpiClient.getSettings());
// Check if at least of site found
if (!evseConnector) {
throw new AppError({
@@ -67,7 +68,7 @@ export default class CPOLocationsEndpoint extends AbstractEndpoint {
});
}
} else if (locationId && evseUid) {
- evseConnector = await OCPIUtilsService.getEvse(tenant, locationId, evseUid, options);
+ evseConnector = await OCPIUtilsService.getEvse(tenant, locationId, evseUid, options, ocpiClient.getSettings());
// Check if at least of site found
if (!evseConnector) {
throw new AppError({
@@ -81,7 +82,7 @@ export default class CPOLocationsEndpoint extends AbstractEndpoint {
}
} else if (locationId) {
// Get single location
- evseConnector = await this.getLocation(tenant, locationId, options);
+ evseConnector = await this.getLocation(tenant, locationId, options, ocpiClient.getSettings());
// Check if at least of site found
if (!evseConnector) {
throw new AppError({
@@ -98,7 +99,7 @@ export default class CPOLocationsEndpoint extends AbstractEndpoint {
const offset = (req.query.offset) ? Utils.convertToInt(req.query.offset) : 0;
const limit = (req.query.limit && Utils.convertToInt(req.query.limit) < Constants.OCPI_RECORDS_LIMIT) ? Utils.convertToInt(req.query.limit) : Constants.OCPI_RECORDS_LIMIT;
// Get all locations
- const locations = await OCPIUtilsService.getAllLocations(tenant, limit, offset, options, true);
+ const locations = await OCPIUtilsService.getAllLocations(tenant, limit, offset, options, true, ocpiClient.getSettings());
evseConnector = locations.result;
// Set header
res.set({
@@ -117,17 +118,17 @@ export default class CPOLocationsEndpoint extends AbstractEndpoint {
return OCPIUtils.success(evseConnector);
}
- private async getLocation(tenant: Tenant, locationId: string, options: OCPILocationOptions): Promise<OCPILocation> {
+ private async getLocation(tenant: Tenant, locationId: string, options: OCPILocationOptions, settings: OcpiSetting): Promise<OCPILocation> {
// Get site
const site = await SiteStorage.getSite(tenant, locationId);
if (site) {
- return await OCPIUtilsService.convertCPOSite2Location(tenant, site, options, true);
+ return await OCPIUtilsService.convertCPOSite2Location(tenant, site, options, true, settings);
}
}
- private async getConnector(tenant: Tenant, locationId: string, evseUid: string, connectorId: string, options: OCPILocationOptions): Promise<OCPIConnector> {
+ private async getConnector(tenant: Tenant, locationId: string, evseUid: string, connectorId: string, options: OCPILocationOptions, settings: OcpiSetting): Promise<OCPIConnector> {
// Get site
- const evse = await OCPIUtilsService.getEvse(tenant, locationId, evseUid, options);
+ const evse = await OCPIUtilsService.getEvse(tenant, locationId, evseUid, options, settings);
// Find the Connector
return evse?.connectors.find((connector) => connector.id === connectorId);
}

MODIFY
src/server/ocpi/ocpi-services-impl/ocpi-2.1.1/emsp/EMSPLocationsEndpoint.ts
src/server/ocpi/ocpi-services-impl/ocpi-2.1.1/emsp/EMSPLocationsEndpoint.ts
@@ -11,6 +11,7 @@ import Constants from '../../../../../utils/Constants';
import { HTTPError } from '../../../../../types/HTTPError';
import Logging from '../../../../../utils/Logging';
import LoggingHelper from '../../../../../utils/LoggingHelper';
+import OCPIClientFactory from '../../../../../client/ocpi/OCPIClientFactory';
import { OCPIConnector } from '../../../../../types/ocpi/OCPIConnector';
import OCPIEndpoint from '../../../../../types/ocpi/OCPIEndpoint';
import { OCPILocation } from '../../../../../types/ocpi/OCPILocation';
@@ -59,6 +60,8 @@ export default class EMSPLocationsEndpoint extends AbstractEndpoint {
ocpiError: OCPIStatusCode.CODE_2001_INVALID_PARAMETER_ERROR
});
}
+ // Get the OCPI client
+ const ocpiClient = await OCPIClientFactory.getOcpiClient(tenant, ocpiEndpoint);
// Handle Charging Station / Connector
if (evseUID) {
const chargingStation = await ChargingStationStorage.getChargingStationByOcpiLocationUid(
@@ -85,7 +88,7 @@ export default class EMSPLocationsEndpoint extends AbstractEndpoint {
});
}
// Rebuild Location
- const location = await OCPIUtilsService.convertEMSPSiteArea2Location(tenant, chargingStation.siteArea);
+ const location = OCPIUtilsService.convertEMSPSiteArea2Location(chargingStation.siteArea, ocpiClient.getSettings());
// Get the EVSE
const chargingStationEvse = chargingStation.ocpiData.evses.find((evse) => evse.uid === evseUID);
if (!chargingStationEvse) {

Removed getSettings in build of tariff