pricing - endpoint constants fixed
MODIFY
src/server/rest/v1/router/api/PricingRouter.ts
src/server/rest/v1/router/api/PricingRouter.ts
@@ -25,34 +25,34 @@ export default class PricingRouter {
}
protected buildRoutePricingDefinitions(): void {
- this.router.get(`/${ServerRoute.REST_PRICING_MODELS}`, async (req: Request, res: Response, next: NextFunction) => {
+ this.router.get(`/${ServerRoute.REST_PRICING_DEFINITIONS}`, async (req: Request, res: Response, next: NextFunction) => {
await RouterUtils.handleServerAction(PricingService.handleGetPricingDefinitions.bind(this), ServerAction.PRICING_DEFINITIONS, req, res, next);
});
}
protected buildRoutePricingDefinition(): void {
- this.router.get(`/${ServerRoute.REST_PRICING_MODEL}`, async (req: Request, res: Response, next: NextFunction) => {
+ this.router.get(`/${ServerRoute.REST_PRICING_DEFINITION}`, async (req: Request, res: Response, next: NextFunction) => {
req.query.ID = req.params.id;
await RouterUtils.handleServerAction(PricingService.handleGetPricingDefinition.bind(this), ServerAction.PRICING_DEFINITION, req, res, next);
});
}
protected buildRouteCreatePricingDefinition(): void {
- this.router.post(`/${ServerRoute.REST_PRICING_MODELS}`, async (req: Request, res: Response, next: NextFunction) => {
+ this.router.post(`/${ServerRoute.REST_PRICING_DEFINITIONS}`, async (req: Request, res: Response, next: NextFunction) => {
req.query.ID = req.params.id;
await RouterUtils.handleServerAction(PricingService.handleCreatePricingDefinition.bind(this), ServerAction.PRICING_DEFINITION_CREATE, req, res, next);
});
}
protected buildRouteDeletePricingDefinition(): void {
- this.router.delete(`/${ServerRoute.REST_PRICING_MODEL}`, async (req: Request, res: Response, next: NextFunction) => {
+ this.router.delete(`/${ServerRoute.REST_PRICING_DEFINITION}`, async (req: Request, res: Response, next: NextFunction) => {
req.query.ID = req.params.id;
await RouterUtils.handleServerAction(PricingService.handleDeletePricingDefinition.bind(this), ServerAction.PRICING_DEFINITION_DELETE, req, res, next);
});
}
protected buildRouteUpdatePricingDefinition(): void {
- this.router.put(`/${ServerRoute.REST_PRICING_MODEL}`, async (req: Request, res: Response, next: NextFunction) => {
+ this.router.put(`/${ServerRoute.REST_PRICING_DEFINITION}`, async (req: Request, res: Response, next: NextFunction) => {
await RouterUtils.handleServerAction(PricingService.handleUpdatePricingDefinition.bind(this), ServerAction.PRICING_DEFINITION_UPDATE, req, res, next);
});
}

MODIFY
src/types/Server.ts
src/types/Server.ts
@@ -571,8 +571,8 @@ export enum ServerRoute {
REST_BILLING_DOWNLOAD_INVOICE = 'invoices/:invoiceID/download',
// PRICING URLs for CRUD operations
- REST_PRICING_MODELS = 'pricing-models',
- REST_PRICING_MODEL = 'pricing-models/:id'
+ REST_PRICING_DEFINITIONS = 'pricing-definitions',
+ REST_PRICING_DEFINITION = 'pricing-definitions/:id'
}
export enum ServerProtocol {

MODIFY
test/api/BillingStripeTestData.ts
test/api/BillingStripeTestData.ts
@@ -19,6 +19,7 @@ import UserStorage from '../../src/storage/mongodb/UserStorage';
import Utils from '../../src/utils/Utils';
import chaiSubset from 'chai-subset';
import config from '../config';
+import moment from 'moment';
import responseHelper from '../helpers/responseHelper';
chai.use(chaiSubset);
@@ -443,6 +444,9 @@ export default class StripeIntegrationTestData {
entityType: null,
name: 'BLUE Tariff',
description: 'Tariff for low EVSE',
+ connectorTypes: null,
+ validFrom: new Date(),
+ validTo: moment().add(10, 'minutes').toDate(),
maxOutputPowerkW: 40000,
dimensions: {
chargingTime: parkingPrice,
@@ -466,6 +470,9 @@ export default class StripeIntegrationTestData {
name: 'GREEN Tariff',
description: 'Tariff for fast chargers',
minOutputPowerkW: 40000,
+ connectorTypes: null,
+ validFrom: new Date(),
+ validTo: moment().add(10, 'minutes').toDate(),
dimensions: {
// chargingTime: parkingPrice, // parking time is free while charging
energy: price4TheEnergy,

MODIFY
test/api/BillingTest.ts
test/api/BillingTest.ts
import AsyncTask, { AsyncTaskStatus } from '../../src/types/AsyncTask';
import { BillingChargeInvoiceAction, BillingDataTransactionStop, BillingInvoiceStatus, BillingStatus, BillingUser } from '../../src/types/Billing';
import { BillingSettings, BillingSettingsType, SettingDB } from '../../src/types/Setting';
+import ChargingStation, { ConnectorType } from '../../src/types/ChargingStation';
import FeatureToggles, { Feature } from '../../src/utils/FeatureToggles';
import PricingDefinition, { PricingDimensions, PricingEntity } from '../../src/types/Pricing';
import chai, { assert, expect } from 'chai';
import AsyncTaskStorage from '../../src/storage/mongodb/AsyncTaskStorage';
import CentralServerService from './client/CentralServerService';
-import ChargingStation from '../../src/types/ChargingStation';
import ChargingStationContext from './context/ChargingStationContext';
import Constants from '../../src/utils/Constants';
import ContextDefinition from './context/ContextDefinition';
@@ -407,7 +407,7 @@ class TestData {
assert(response?.data?.status === 'Success', 'The operation should succeed');
}
- public async createTariff4ChargingStation(chargingStation: ChargingStation, dimensions: PricingDimensions = null): Promise<void> {
+ public async createTariff4ChargingStation(chargingStation: ChargingStation, dimensions: PricingDimensions = null, connectorTypes: ConnectorType[] = null): Promise<void> {
dimensions = dimensions || {
flatFee: {
price: 1.25,
@@ -427,11 +427,17 @@ class TestData {
},
};
+ // Set a default value
+ connectorTypes = connectorTypes || [ ConnectorType.TYPE_2 ];
+
const tariff: Partial<PricingDefinition> = {
entityID: chargingStation.id, // a pricing model for the site
entityType: PricingEntity.CHARGING_STATION,
name: 'CS Tariff - ' + chargingStation.id,
- description: 'Tariff for CS' + chargingStation.id,
+ description: 'Tariff for CS -' + chargingStation.id,
+ connectorTypes,
+ validFrom: new Date(),
+ validTo: moment().add(10, 'minutes').toDate(),
dimensions
};

MODIFY
test/api/client/PricingApi.ts
test/api/client/PricingApi.ts
@@ -11,23 +11,23 @@ export default class PricingApi extends CrudApi {
}
public async readPricingDefinitions(params, paging = TestConstants.DEFAULT_PAGING, ordering = TestConstants.DEFAULT_ORDERING) {
- return super.readAll(params, paging, ordering, this.buildRestEndpointUrl(ServerRoute.REST_PRICING_MODELS));
+ return super.readAll(params, paging, ordering, this.buildRestEndpointUrl(ServerRoute.REST_PRICING_DEFINITIONS));
}
public async readPricingDefinition(id: string) {
- return super.read({ ID: id }, this.buildRestEndpointUrl(ServerRoute.REST_PRICING_MODEL, { id }));
+ return super.read({ ID: id }, this.buildRestEndpointUrl(ServerRoute.REST_PRICING_DEFINITION, { id }));
}
public async updatePricingDefinition(data: PricingDefinition) {
- return super.update(data, this.buildRestEndpointUrl(ServerRoute.REST_PRICING_MODEL, { id: data.id }));
+ return super.update(data, this.buildRestEndpointUrl(ServerRoute.REST_PRICING_DEFINITION, { id: data.id }));
}
public async createPricingDefinition(data: Partial<PricingDefinition>) {
- return super.create(data, this.buildRestEndpointUrl(ServerRoute.REST_PRICING_MODELS));
+ return super.create(data, this.buildRestEndpointUrl(ServerRoute.REST_PRICING_DEFINITIONS));
}
public async deletePricingDefinition(id: string) {
- return super.delete(id, this.buildRestEndpointUrl(ServerRoute.REST_PRICING_MODEL, { id }));
+ return super.delete(id, this.buildRestEndpointUrl(ServerRoute.REST_PRICING_DEFINITION, { id }));
}
}

pricing - endpoint constants fixed