pricing - allow pricing model for charging stations
MODIFY
src/integration/pricing/PricingEngine.ts
src/integration/pricing/PricingEngine.ts
@@ -29,10 +29,10 @@ export default class PricingEngine {
// Merge the pricing definitions from the different contexts
const pricingDefinitions: PricingDefinition[] = [];
// pricingDefinitions.push(...await PricingEngine.getPricingDefinitions4Entity(tenant, transaction.userID));
- // pricingDefinitions.push(...await PricingEngine.getPricingDefinitions4Entity(tenant, transaction.chargeBoxID));
- pricingDefinitions.push(...await PricingEngine.getPricingDefinitions4Entity(tenant, transaction.siteAreaID));
- pricingDefinitions.push(...await PricingEngine.getPricingDefinitions4Entity(tenant, transaction.siteID));
- pricingDefinitions.push(...await PricingEngine.getPricingDefinitions4Entity(tenant, transaction.companyID));
+ pricingDefinitions.push(...await PricingEngine.getPricingDefinitions4Entity(tenant, transaction.chargeBoxID.toString()));
+ pricingDefinitions.push(...await PricingEngine.getPricingDefinitions4Entity(tenant, transaction.siteAreaID.toString()));
+ pricingDefinitions.push(...await PricingEngine.getPricingDefinitions4Entity(tenant, transaction.siteID.toString()));
+ pricingDefinitions.push(...await PricingEngine.getPricingDefinitions4Entity(tenant, transaction.companyID.toString()));
// TODO - No pricing definition? => Throw an exception ? or create dynamically a simple one based on the simple pricing settings?
const resolvedPricingModel: ResolvedPricingModel = {
pricingDefinitions

MODIFY
src/storage/mongodb/PricingStorage.ts
src/storage/mongodb/PricingStorage.ts
@@ -21,7 +21,7 @@ export default class PricingStorage {
DatabaseUtils.checkTenantObject(tenant);
const pricingModelMDB = {
_id: pricingModel.id ? DatabaseUtils.convertToObjectID(pricingModel.id) : new ObjectId(),
- contextID: DatabaseUtils.convertToObjectID(pricingModel.contextID),
+ contextID: pricingModel.contextID,
pricingDefinitions: pricingModel.pricingDefinitions, // TODO - check here some data consistency
};
// Check Created/Last Changed By
@@ -86,7 +86,7 @@ export default class PricingStorage {
}
// Context IDs
if (!Utils.isEmptyArray(params.contextIDs)) {
- filters.contextID = { $in: params.contextIDs.map((contextID) => DatabaseUtils.convertToObjectID(contextID)) };
+ filters.contextID = { $in: params.contextIDs };
}
// Remove deleted
filters.deleted = { '$ne': true };
@@ -133,7 +133,7 @@ export default class PricingStorage {
// Handle the ID
DatabaseUtils.pushRenameDatabaseID(aggregation);
// Convert Object ID to string
- DatabaseUtils.pushConvertObjectIDToString(aggregation, 'contextID');
+ // DatabaseUtils.pushConvertObjectIDToString(aggregation, 'contextID');
// Add Created By / Last Changed By
DatabaseUtils.pushCreatedLastChangedInAggregation(tenant.id, aggregation);
// Project

pricing - allow pricing model for charging stations