Ensure Site Area is provided
MODIFY
src/utils/Utils.ts
src/utils/Utils.ts
-import { AxiosError } from 'axios';
-import bcrypt from 'bcryptjs';
-import crypto from 'crypto';
-import { Request } from 'express';
-import fs from 'fs';
-import http from 'http';
-import _ from 'lodash';
-import moment from 'moment';
-import { ObjectID } from 'mongodb';
-import passwordGenerator from 'password-generator';
-import path from 'path';
-import tzlookup from 'tz-lookup';
-import url from 'url';
-import { v4 as uuid } from 'uuid';
-import validator from 'validator';
-import Authorizations from '../authorization/Authorizations';
-import AppError from '../exception/AppError';
-import BackendError from '../exception/BackendError';
-import ChargingStationStorage from '../storage/mongodb/ChargingStationStorage';
-import SiteAreaStorage from '../storage/mongodb/SiteAreaStorage';
-import TenantStorage from '../storage/mongodb/TenantStorage';
-import UserStorage from '../storage/mongodb/UserStorage';
+import { AnalyticsSettingsType, AssetSettingsType, BillingSettingsType, PricingSettingsType, RefundSettingsType, RoamingSettingsType, SettingDBContent, SmartChargingContentType } from '../types/Setting';
+import { Car, CarCatalog, CarType } from '../types/Car';
+import { ChargePointStatus, OCPPProtocol, OCPPVersion } from '../types/ocpp/OCPPServer';
+import ChargingStation, { ChargePoint, Connector, ConnectorCurrentLimitSource, CurrentType, SiteAreaLimitSource } from '../types/ChargingStation';
+import Transaction, { InactivityStatus } from '../types/Transaction';
+import User, { UserRole, UserStatus } from '../types/User';
+
+import { ActionsResponse } from '../types/GlobalType';
import Address from '../types/Address';
+import AppError from '../exception/AppError';
import Asset from '../types/Asset';
-import { Car, CarCatalog, CarType } from '../types/Car';
+import Authorizations from '../authorization/Authorizations';
+import { AxiosError } from 'axios';
+import BackendError from '../exception/BackendError';
import { ChargingProfile } from '../types/ChargingProfile';
-import ChargingStation, { ChargePoint, Connector, ConnectorCurrentLimitSource, CurrentType, SiteAreaLimitSource } from '../types/ChargingStation';
+import ChargingStationStorage from '../storage/mongodb/ChargingStationStorage';
import Company from '../types/Company';
+import Configuration from './Configuration';
import ConnectorStats from '../types/ConnectorStats';
+import Constants from './Constants';
import Consumption from '../types/Consumption';
-import { ActionsResponse } from '../types/GlobalType';
+import Cypher from './Cypher';
import { HTTPError } from '../types/HTTPError';
-import OCPIEndpoint from '../types/ocpi/OCPIEndpoint';
-import { ChargePointStatus, OCPPProtocol, OCPPVersion } from '../types/ocpp/OCPPServer';
import { HttpEndUserErrorNotificationRequest } from '../types/requests/HttpNotificationRequest';
+import Logging from './Logging';
+import OCPIEndpoint from '../types/ocpi/OCPIEndpoint';
+import { ObjectID } from 'mongodb';
+import { Request } from 'express';
import { ServerAction } from '../types/Server';
-import { AnalyticsSettingsType, AssetSettingsType, BillingSettingsType, PricingSettingsType, RefundSettingsType, RoamingSettingsType, SettingDBContent, SmartChargingContentType } from '../types/Setting';
import Site from '../types/Site';
import SiteArea from '../types/SiteArea';
+import SiteAreaStorage from '../storage/mongodb/SiteAreaStorage';
import Tag from '../types/Tag';
import Tenant from '../types/Tenant';
import TenantComponents from '../types/TenantComponents';
-import Transaction, { InactivityStatus } from '../types/Transaction';
-import User, { UserRole, UserStatus } from '../types/User';
+import TenantStorage from '../storage/mongodb/TenantStorage';
+import UserStorage from '../storage/mongodb/UserStorage';
import UserToken from '../types/UserToken';
-import Configuration from './Configuration';
-import Constants from './Constants';
-import Cypher from './Cypher';
-import Logging from './Logging';
+import _ from 'lodash';
+import bcrypt from 'bcryptjs';
+import crypto from 'crypto';
+import fs from 'fs';
+import http from 'http';
+import moment from 'moment';
+import passwordGenerator from 'password-generator';
+import path from 'path';
+import tzlookup from 'tz-lookup';
+import url from 'url';
+import { v4 as uuid } from 'uuid';
+import validator from 'validator';
const MODULE_NAME = 'Utils';
@@ -1786,7 +1787,7 @@ export default class Utils {
public static async addSiteLimitationToConsumption(tenantID: string, siteArea: SiteArea, consumption: Consumption): Promise<void> {
const tenant: Tenant = await TenantStorage.getTenant(tenantID);
- if (Utils.isTenantComponentActive(tenant, TenantComponents.ORGANIZATION)) {
+ if (Utils.isTenantComponentActive(tenant, TenantComponents.ORGANIZATION) && siteArea) {
// Get limit of the site area
consumption.limitSiteAreaWatts = 0;
// Maximum power of the Site Area provided?

Ensure Site Area is provided