added authorizations for sites for basic
added site to db
MODIFY
src/assets/server/rest/v1/schemas/pricing/pricing-definition-create.json
src/assets/server/rest/v1/schemas/pricing/pricing-definition-create.json
"$ref": "pricing-definition#/definitions/pricingDimension"
}
}
+ },
+ "siteID": {
+ "$ref": "common#/definitions/id"
}
},
"required": [

MODIFY
src/authorization/AuthorizationsDefinition.ts
src/authorization/AuthorizationsDefinition.ts
@@ -380,6 +380,22 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
},
basic: {
grants: [
+ { resource: Entity.PRICING_DEFINITION, action: [Action.LIST],
+ condition: {
+ Fn: 'custom:dynamicAuthorizations',
+ args: {
+ asserts: [],
+ filters: ['AssignedSites']
+ }
+ },
+ attributes: ['id', 'entityID', 'entityType', 'name', 'description', 'entityName',
+ 'staticRestrictions.validFrom', 'staticRestrictions.validTo', 'staticRestrictions.connectorType', 'staticRestrictions.connectorPowerkW',
+ 'restrictions.minEnergyKWh', 'restrictions.maxEnergyKWh', 'restrictions.minDurationSecs', 'restrictions.maxDurationSecs',
+ 'dimensions.flatFee.active', 'dimensions.flatFee.price', 'dimensions.flatFee.stepSize', 'dimensions.flatFee.pricedData',
+ 'dimensions.energy.active', 'dimensions.energy.price', 'dimensions.energy.stepSize', 'dimensions.energy.pricedData',
+ 'dimensions.chargingTime.active', 'dimensions.chargingTime.price', 'dimensions.chargingTime.stepSize', 'dimensions.chargingTime.pricedData',
+ 'dimensions.parkingTime.active', 'dimensions.parkingTime.price', 'dimensions.parkingTime.stepSize', 'dimensions.parkingTime.pricedData',]
+ },
{
resource: Entity.USER, action: [Action.READ, Action.UPDATE],
condition: {

MODIFY
src/storage/mongodb/PricingStorage.ts
src/storage/mongodb/PricingStorage.ts
@@ -34,6 +34,7 @@ export default class PricingStorage {
staticRestrictions: pricingDefinition.staticRestrictions,
restrictions: pricingDefinition.restrictions,
dimensions: pricingDefinition.dimensions,
+ siteID: DatabaseUtils.convertToObjectID(pricingDefinition.siteID)
};
// Check Created/Last Changed By
DatabaseUtils.addLastChangedCreatedProps(pricingDefinitionMDB, pricingDefinition);
@@ -63,8 +64,9 @@ export default class PricingStorage {
}
public static async getPricingDefinition(tenant: Tenant, id: string,
- params: { entityID?: string; entityType?: string; withEntityInformation?: boolean } = {}, projectFields?: string[]): Promise<PricingDefinition> {
+ params: { entityID?: string; entityType?: string; withEntityInformation?: boolean; siteIDs?: string[];} = {}, projectFields?: string[]): Promise<PricingDefinition> {
const pricingDefinitionMDB = await PricingStorage.getPricingDefinitions(tenant, {
+ siteIDs: params.siteIDs,
pricingDefinitionIDs: [id],
entityID: params.entityID,
entityType: params.entityType,
@@ -74,7 +76,7 @@ export default class PricingStorage {
}
public static async getPricingDefinitions(tenant: Tenant,
- params: { pricingDefinitionIDs?: string[], entityType?: string; entityID?: string; withEntityInformation?: boolean; },
+ params: { pricingDefinitionIDs?: string[], entityType?: string; entityID?: string; siteIDs?: string[]; withEntityInformation?: boolean; },
dbParams: DbParams, projectFields?: string[]): Promise<DataResult<PricingDefinition>> {
const uniqueTimerID = Logging.traceDatabaseRequestStart();
// Check Tenant
@@ -102,6 +104,12 @@ export default class PricingStorage {
filters.entityID = { $in: [DatabaseUtils.convertToObjectID(params.entityID)] };
}
}
+ // Site
+ if (!Utils.isEmptyArray(params.siteIDs)) {
+ filters.siteID = {
+ $in: params.siteIDs.map((siteID) => DatabaseUtils.convertToObjectID(siteID))
+ };
+ }
// Remove deleted
filters.deleted = { '$ne': true };
// Filters

MODIFY
src/types/Pricing.ts
src/types/Pricing.ts
@@ -53,6 +53,7 @@ export default interface PricingDefinition extends PricingDefinitionInternal, Cr
id: string;
entityID: string;
entityType: PricingEntity;
+ siteID: string;
}
export interface PricingDimensions {

added authorizations for sites for basic
added site to db