Added missing properties
MODIFY
src/server/rest/v1/service/AssetService.ts
src/server/rest/v1/service/AssetService.ts
@@ -387,6 +387,8 @@ export default class AssetService {
name: filteredRequest.name,
siteAreaID: filteredRequest.siteAreaID,
assetType: filteredRequest.assetType,
+ fluctuation: filteredRequest.fluctuation,
+ fallbackValue: filteredRequest.fallbackValue,
coordinates: filteredRequest.coordinates,
image: filteredRequest.image,
dynamicAsset: filteredRequest.dynamicAsset,
@@ -444,6 +446,8 @@ export default class AssetService {
asset.name = filteredRequest.name;
asset.siteAreaID = filteredRequest.siteAreaID;
asset.assetType = filteredRequest.assetType;
+ asset.fluctuation = filteredRequest.fluctuation;
+ asset.fallbackValue = filteredRequest.fallbackValue;
asset.coordinates = filteredRequest.coordinates;
asset.image = filteredRequest.image;
asset.dynamicAsset = filteredRequest.dynamicAsset;

MODIFY
src/server/rest/v1/service/UtilsService.ts
src/server/rest/v1/service/UtilsService.ts
@@ -526,6 +526,15 @@ export default class UtilsService {
user: req.user.id
});
}
+ if (!(typeof asset.fallbackValue === 'number')) {
+ throw new AppError({
+ source: Constants.CENTRAL_SERVER,
+ errorCode: HTTPError.GENERAL_ERROR,
+ message: 'Fallback value must be of type number',
+ module: MODULE_NAME, method: 'checkIfAssetValid',
+ user: req.user.id
+ });
+ }
if (asset.dynamicAsset) {
if (!asset.connectionID) {
throw new AppError({

MODIFY
src/server/rest/v1/service/security/AssetSecurity.ts
src/server/rest/v1/service/security/AssetSecurity.ts
@@ -63,6 +63,8 @@ export default class AssetSecurity {
filteredRequest.name = sanitize(request.name),
filteredRequest.siteAreaID = sanitize(request.siteAreaID),
filteredRequest.assetType = sanitize(request.assetType),
+ filteredRequest.fluctuation = sanitize(request.fluctuation),
+ filteredRequest.fallbackValue = sanitize(request.fallbackValue),
filteredRequest.image = request.image;
filteredRequest.dynamicAsset = UtilsSecurity.filterBoolean(request.dynamicAsset);
if (request.coordinates && request.coordinates.length === 2) {

MODIFY
src/storage/mongodb/AssetStorage.ts
src/storage/mongodb/AssetStorage.ts
@@ -51,6 +51,8 @@ export default class AssetStorage {
coordinates: Utils.containsGPSCoordinates(assetToSave.coordinates) ? assetToSave.coordinates.map(
(coordinate) => Utils.convertToFloat(coordinate)) : [],
assetType: assetToSave.assetType,
+ fluctuation: Utils.convertToFloat(assetToSave.fluctuation),
+ fallbackValue: Utils.convertToFloat(assetToSave.fallbackValue),
dynamicAsset: assetToSave.dynamicAsset,
issuer: Utils.convertToBoolean(assetToSave.issuer),
connectionID: assetToSave.connectionID,

MODIFY
src/types/Asset.ts
src/types/Asset.ts
@@ -8,7 +8,9 @@ export default interface Asset extends CreatedUpdatedProps, AbstractCurrentConsu
name: string;
siteAreaID: string;
siteArea?: SiteArea;
- assetType: string;
+ assetType: AssetType;
+ fluctuation: number;
+ fallbackValue: number;
coordinates: number[];
issuer: boolean;
image?: string;
@@ -18,6 +20,12 @@ export default interface Asset extends CreatedUpdatedProps, AbstractCurrentConsu
values: Consumption[],
}
+export enum AssetType {
+ CO = 'CO',
+ PR = 'PR',
+ CO_PR = 'CO-PR',
+}
+
export enum SchneiderProperty {
ENERGY_ACTIVE = 'Energie_Active',
AMPERAGE_L1 = 'I1',

MODIFY
test/factories/AssetFactory.ts
test/factories/AssetFactory.ts
@@ -4,4 +4,5 @@ import faker from 'faker';
export default Factory.define('asset')
.attr('name', () => faker.company.companyName())
.attr('siteAreaID', null)
- .attr('assetType', null);
+ .attr('assetType', null)
+ .attr('fallbackValue', 0);

Added missing properties