pricing - testing specific consumption gaps
MODIFY
test/api/BillingTestHelper.ts
test/api/BillingTestHelper.ts
@@ -493,9 +493,10 @@ export default class BillingTestHelper {
const meterStart = 0;
const meterStop = 32325; // Unit: Wh
- const meterValue1 = Utils.createDecimal(meterStop).divToInt(80).toNumber();
- const meterValue2 = Utils.createDecimal(meterStop).divToInt(30).toNumber();
- const meterValue3 = Utils.createDecimal(meterStop).divToInt(60).toNumber();
+ const meterValueRampUp = Utils.createDecimal(meterStop).divToInt(80).toNumber();
+ const meterValueHighConsumption = Utils.createDecimal(meterStop).divToInt(30).toNumber();
+ const meterValuePoorConsumption = 0; // Simulate a gap in the energy provisioning
+ const meterValuePhaseOut = Utils.createDecimal(meterStop).divToInt(60).toNumber();
// const user:any = this.userContext;
const connectorId = 1;
@@ -509,24 +510,29 @@ export default class BillingTestHelper {
const currentTime = startDate.clone();
let cumulated = 0;
- // Phase #0
+ // Phase #0 - not charging yet
for (let index = 0; index < 5; index++) {
- // cumulated += meterValue1; - not charging yet!
+ // cumulated += meterValueRampUp;
await this.sendConsumptionMeterValue(connectorId, transactionId, currentTime, cumulated);
}
- // Phase #1
+ // Phase #1 - warm up
for (let index = 0; index < 15; index++) {
- cumulated += meterValue1;
+ cumulated += meterValueRampUp;
await this.sendConsumptionMeterValue(connectorId, transactionId, currentTime, cumulated);
}
- // Phase #2
+ // Phase #2 - high consumption
for (let index = 0; index < 20; index++) {
- cumulated += meterValue2;
+ cumulated += meterValueHighConsumption;
await this.sendConsumptionMeterValue(connectorId, transactionId, currentTime, cumulated);
}
- // Phase #3
- for (let index = 0; index < 15; index++) {
- cumulated = Math.min(meterStop, cumulated += meterValue3);
+ // Phase #2 - no consumption
+ for (let index = 0; index < 5; index++) {
+ cumulated += meterValuePoorConsumption;
+ await this.sendConsumptionMeterValue(connectorId, transactionId, currentTime, cumulated);
+ }
+ // Phase #3 - phase out
+ for (let index = 0; index < 10; index++) {
+ cumulated = Math.min(meterStop, cumulated += meterValuePhaseOut);
await this.sendConsumptionMeterValue(connectorId, transactionId, currentTime, cumulated);
}
assert(cumulated === meterStop, 'Inconsistent meter values - cumulated energy should equal meterStop - ' + cumulated);
@@ -535,7 +541,6 @@ export default class BillingTestHelper {
// cumulated += 0; // Parking time - not charging anymore
await this.sendConsumptionMeterValue(connectorId, transactionId, currentTime, meterStop);
}
-
// #end
const stopDate = startDate.clone().add(1, 'hour');
if (expectedStatus === 'Accepted') {

pricing - testing specific consumption gaps