transaction - test soft stop
MODIFY
test/api/BillingTest.ts
test/api/BillingTest.ts
@@ -863,6 +863,30 @@ describe('Billing', function() {
await billingTestHelper.checkPricingDefinitionEndpoints();
});
});
+
+ describe('Transaction Inconsistency Recovery', () => {
+ before(async () => {
+ billingTestHelper.initUserContextAsAdmin();
+ // Initialize the Billing module
+ billingTestHelper.billingImpl = await billingTestHelper.setBillingSystemValidCredentials(true, true /* immediateBillingAllowed ON */);
+ await billingTestHelper.initChargingStationContext2TestChargingTime();
+ });
+
+ after(async () => {
+ });
+
+ it('check Soft Stop Transaction', async () => {
+ await billingTestHelper.initChargingStationContext2TestFastCharger('E+PT(STEP)');
+ await billingTestHelper.userService.billingApi.forceSynchronizeUser({ id: billingTestHelper.userContext.id });
+ const userWithBillingData = await billingTestHelper.billingImpl.getUser(billingTestHelper.userContext);
+ await billingTestHelper.assignPaymentMethod(userWithBillingData, 'tok_fr');
+ const transactionID = await billingTestHelper.generateTransaction(billingTestHelper.userContext, 'Accepted', true);
+ assert(transactionID, 'transactionID should not be null');
+ // Check that we have a new invoice with an invoiceID and an invoiceNumber
+ await billingTestHelper.checkTransactionBillingData(transactionID, BillingInvoiceStatus.PAID, 29.49);
+ });
+ });
+
});
describe('Billing Test Data Cleanup (utbilling)', () => {

MODIFY
test/api/BillingTestHelper.ts
test/api/BillingTestHelper.ts
@@ -500,8 +500,7 @@ export default class BillingTestHelper {
}
- public async generateTransaction(user: any, expectedStatus = 'Accepted', withExtraNotificationStatus = true): Promise<number> {
-
+ public async generateTransaction(user: any, expectedStatus = 'Accepted', withSoftStopSimulation = false): Promise<number> {
const meterStart = 0;
const meterStop = 32325; // Unit: Wh
const meterValueRampUp = Utils.createDecimal(meterStop).divToInt(80).toNumber();
@@ -563,14 +562,23 @@ 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') {
+ if (withSoftStopSimulation) {
+ // #end - simulating the situation where the stop is not received
+ await this.sendStatusNotification(connectorId, stopDate.clone().add(29, 'minutes').toDate(), ChargePointStatus.FINISHING);
+ await this.sendStatusNotification(connectorId, stopDate.clone().add(30, 'minutes').toDate(), ChargePointStatus.AVAILABLE);
+ // SOFT STOP TRANSACTION
+ const stopTransactionResponse = await this.chargingStationContext.softStopTransaction(transactionId);
+ expect(stopTransactionResponse).to.be.transactionStatus('Accepted');
+ } else {
+ // #end
const stopTransactionResponse = await this.chargingStationContext.stopTransaction(transactionId, tagId, meterStop, stopDate.toDate());
expect(stopTransactionResponse).to.be.transactionStatus('Accepted');
// Let's send an OCCP status notification to simulate some extra inactivities
await this.sendStatusNotification(connectorId, stopDate.clone().add(29, 'minutes').toDate(), ChargePointStatus.FINISHING);
await this.sendStatusNotification(connectorId, stopDate.clone().add(30, 'minutes').toDate(), ChargePointStatus.AVAILABLE);
+ }
// Give some time to the asyncTask to bill the transaction
await this.waitForAsyncTasks();
}

MODIFY
test/api/client/TransactionApi.ts
test/api/client/TransactionApi.ts
@@ -61,4 +61,8 @@ export default class TransactionApi extends CrudApi {
return await super.read(params, this.buildRestEndpointUrl(ServerRoute.REST_TRANSACTIONS_EXPORT));
}
+ public async softStopTransaction(params) {
+ return super.update(params, this.buildRestEndpointUrl(ServerRoute.REST_TRANSACTION_SOFT_STOP, { id: params.ID }));
+ }
+
}

MODIFY
test/api/context/ChargingStationContext.ts
test/api/context/ChargingStationContext.ts
@@ -60,6 +60,11 @@ export default class ChargingStationContext {
this.transactionsStarted.clear();
}
+ public async softStopTransaction(transactionID: number): Promise<any> {
+ const response = await this.tenantContext.getAdminCentralServerService().transactionApi.softStopTransaction({ ID: transactionID });
+ return response;
+ }
+
public getChargingStation(): ChargingStation {
return this.chargingStation;
}

transaction - test soft stop