bp - tests - one step beyond
MODIFY
test/api/BillingPlatformTest.ts
test/api/BillingPlatformTest.ts
@@ -44,8 +44,6 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
await stripeTestHelper.initialize(ContextDefinition.TENANT_CONTEXTS.TENANT_BILLING_PLATFORM);
// TODO - This is ugly and confusing - rethink that part (merge BillingTestHelper and StripeTestHelper methods)
await billingTestHelper.initialize(ContextDefinition.TENANT_CONTEXTS.TENANT_BILLING_PLATFORM);
- // Initialize the Billing module
- await billingTestHelper.setBillingSystemValidCredentials(true, false /* immediateBillingAllowed OFF, so periodicBilling ON */);
// Set the admin as the current user context
billingTestHelper.setCurrentUserContextAsAdmin();
});
@@ -249,10 +247,12 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
await billingTestHelper.initContext2TestConnectedAccounts();
});
- it('should create an invoice, and get transfers generated', async () => {
- // -------------------------------------------------------------------------------------------------------------
- // -------------------------------------------------------------------------------------------------------------
- // -------------------------------------------------------------------------------------------------------------
+ describe('with Periodic Billing ON ', () => {
+ beforeAll(async () => {
+ // Initialize the Billing module
+ await billingTestHelper.setBillingSystemValidCredentials(true, false /* immediateBillingAllowed OFF */);
+ });
+
// -------------------------------------------------------------------------------------------------------------
// TO DO - GENERATE SEVERAL TRANSACTIONS
// -------------------------------------------------------------------------------------------------------------
@@ -267,12 +267,12 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
// - finalize the transfers!!!!
// - send the transfers to STRIPE to generate the real transfer of funds
// -------------------------------------------------------------------------------------------------------------
+ it('should create an invoice, and get transfers generated', async () => {
// Create a account
await billingTestHelper.makeCurrentUserContextReadyForBilling();
- const transactionID = await billingTestHelper.generateTransaction(billingTestHelper.userContext);
- assert(transactionID, 'transactionID should not be null');
- // Check that we have a new invoice with an invoiceID and but no invoiceNumber yet
- await billingTestHelper.checkTransactionBillingData(transactionID, BillingInvoiceStatus.DRAFT);
+ // Generate a DRAFT transaction
+ const transactionID1 = await billingTestHelper.generateTransactionAndCheckBillingStatus(BillingInvoiceStatus.DRAFT);
+ const transactionID2 = await billingTestHelper.generateTransactionAndCheckBillingStatus(BillingInvoiceStatus.DRAFT);
// Let's simulate the periodic billing operation
const taskConfiguration: BillingPeriodicOperationTaskConfig = {
onlyProcessUnpaidInvoices: false,
@@ -282,7 +282,32 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
assert(operationResult.inSuccess > 0, 'The operation should have been able to process at least one invoice');
assert(operationResult.inError === 0, 'The operation should detect any errors');
// The transaction should now have a different status and know the final invoice number
- await billingTestHelper.checkTransactionBillingData(transactionID, BillingInvoiceStatus.PAID);
+ const billingDataStop1 = await billingTestHelper.checkTransactionBillingData(transactionID1, BillingInvoiceStatus.PAID);
+ const billingDataStop2 = await billingTestHelper.checkTransactionBillingData(transactionID2, BillingInvoiceStatus.PAID);
+ // Check billing data
+ assert(billingDataStop1.invoiceID === billingDataStop2.invoiceID, 'The two transactions should be billed by a single invoice');
+ await billingTestHelper.checkInvoiceData(billingDataStop1.invoiceID, BillingInvoiceStatus.PAID, 2, 20.16);
+ // The user should have no DRAFT invoices
+ const nbDraftInvoices = await billingTestHelper.checkForDraftInvoices();
+ assert(nbDraftInvoices === 0, 'The expected number of DRAFT invoices is not correct');
+ });
+ });
+
+ describe('with Immediate Billing ON ', () => {
+ beforeAll(async () => {
+ // Initialize the Billing module
+ await billingTestHelper.setBillingSystemValidCredentials(true, true /* immediateBillingAllowed ON */);
+ });
+
+ it('should create an invoice, pay for it immediately and get a transfer generated or updated', async () => {
+ // Create a account
+ await billingTestHelper.makeCurrentUserContextReadyForBilling();
+ // Generate a PAID transaction
+ const transactionID = await billingTestHelper.generateTransactionAndCheckBillingStatus(BillingInvoiceStatus.PAID);
+ // The transaction should now have a different status and know the final invoice number
+ const billingDataStop = await billingTestHelper.checkTransactionBillingData(transactionID, BillingInvoiceStatus.PAID);
+ // Check billing data
+ await billingTestHelper.checkInvoiceData(billingDataStop.invoiceID, BillingInvoiceStatus.PAID, 1, 10.08);
// The user should have no DRAFT invoices
const nbDraftInvoices = await billingTestHelper.checkForDraftInvoices();
assert(nbDraftInvoices === 0, 'The expected number of DRAFT invoices is not correct');
@@ -290,6 +315,7 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
});
});
+ });
describe('Where basic user', () => {

MODIFY
test/api/BillingTest.ts
test/api/BillingTest.ts
@@ -312,7 +312,7 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
it('should add an item to a DRAFT invoice after a transaction', async () => {
await billingTestHelper.makeCurrentUserContextReadyForBilling();
const itemsBefore = await billingTestHelper.getNumberOfSessions(billingTestHelper.userContext.id);
- const transactionID = await billingTestHelper.generateTransaction(billingTestHelper.userContext);
+ const transactionID = await billingTestHelper.generateTransaction();
assert(transactionID, 'transactionID should not be null');
const itemsAfter = await billingTestHelper.getNumberOfSessions(billingTestHelper.userContext.id);
expect(itemsAfter).to.be.gt(itemsBefore);
@@ -373,7 +373,7 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
async () => {
await billingTestHelper.userService.billingApi.forceSynchronizeUser({ id: billingTestHelper.userContext.id });
const itemsBefore = await billingTestHelper.getNumberOfSessions(billingTestHelper.userContext.id);
- const transactionID = await billingTestHelper.generateTransaction(billingTestHelper.userContext);
+ const transactionID = await billingTestHelper.generateTransaction();
expect(transactionID).to.not.be.null;
const itemsAfter = await billingTestHelper.getNumberOfSessions(billingTestHelper.userContext.id);
expect(itemsAfter).to.be.eq(itemsBefore + 1);
@@ -439,7 +439,7 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
const userWithBillingData = await billingTestHelper.billingImpl.getUser(billingTestHelper.userContext);
await billingTestHelper.assignPaymentMethod(userWithBillingData, 'tok_fr');
const itemsBefore = await billingTestHelper.getNumberOfSessions(basicUser.id);
- const transactionID = await billingTestHelper.generateTransaction(billingTestHelper.userContext);
+ const transactionID = await billingTestHelper.generateTransaction();
assert(transactionID, 'transactionID should not be null');
const itemsAfter = await billingTestHelper.getNumberOfSessions(basicUser.id);
expect(itemsAfter).to.be.eq(itemsBefore + 1);
@@ -453,7 +453,7 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
});
it('should not delete a transaction linked to an invoice', async () => {
- const transactionID = await billingTestHelper.generateTransaction(billingTestHelper.userContext);
+ const transactionID = await billingTestHelper.generateTransaction();
expect(transactionID).to.not.be.null;
const transactionDeleted = await billingTestHelper.userService.transactionApi.delete(transactionID);
expect(transactionDeleted.data.inError).to.be.eq(1);
@@ -507,7 +507,7 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
});
it('Should not be able to start a transaction', async () => {
- const transactionID = await billingTestHelper.generateTransaction(billingTestHelper.userContext, 'Invalid');
+ const transactionID = await billingTestHelper.generateTransaction('Invalid');
assert(!transactionID, 'Transaction ID should not be set');
});
@@ -525,7 +525,7 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
});
xit('Should set a transaction in error', async () => {
- const transactionID = await billingTestHelper.generateTransaction(billingTestHelper.userContext);
+ const transactionID = await billingTestHelper.generateTransaction();
const transactions = await billingTestHelper.userService.transactionApi.readAllInError({});
expect(transactions.data.result.find((transaction) => transaction.id === transactionID)).to.not.be.null;
});
@@ -553,7 +553,7 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
async () => {
await billingTestHelper.userService.billingApi.forceSynchronizeUser({ id: billingTestHelper.userContext.id });
const itemsBefore = await billingTestHelper.getNumberOfSessions(billingTestHelper.userContext.id);
- const transactionID = await billingTestHelper.generateTransaction(billingTestHelper.userContext);
+ const transactionID = await billingTestHelper.generateTransaction();
assert(transactionID, 'transactionID should not be null');
const itemsAfter = await billingTestHelper.getNumberOfSessions(billingTestHelper.userContext.id);
expect(itemsAfter).to.be.eq(itemsBefore);
@@ -580,7 +580,7 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
it('should create and bill an invoice with FF + CT', async () => {
await billingTestHelper.makeCurrentUserContextReadyForBilling();
- const transactionID = await billingTestHelper.generateTransaction(billingTestHelper.userContext);
+ const transactionID = await billingTestHelper.generateTransaction();
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, 1.29);
@@ -596,7 +596,7 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
it('should create and bill an invoice with FF + ENERGY', async () => {
await billingTestHelper.initChargingStationContext2TestCS3Phased();
await billingTestHelper.makeCurrentUserContextReadyForBilling();
- const transactionID = await billingTestHelper.generateTransaction(billingTestHelper.userContext);
+ const transactionID = await billingTestHelper.generateTransaction();
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, 10.08);
@@ -605,7 +605,7 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
it('should create and bill an invoice with FF+ENERGY(STEP)', async () => {
await billingTestHelper.initChargingStationContext2TestCS3Phased('FF+E(STEP)');
await billingTestHelper.makeCurrentUserContextReadyForBilling();
- const transactionID = await billingTestHelper.generateTransaction(billingTestHelper.userContext);
+ const transactionID = await billingTestHelper.generateTransaction();
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, 9.50);
@@ -620,7 +620,7 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
it('should bill the Energy on COMBO CCS - DC', async () => {
await billingTestHelper.initChargingStationContext2TestFastCharger();
await billingTestHelper.makeCurrentUserContextReadyForBilling();
- const transactionID = await billingTestHelper.generateTransaction(billingTestHelper.userContext);
+ const transactionID = await billingTestHelper.generateTransaction();
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, 16.16);
@@ -629,7 +629,7 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
it('should bill the FF+CT+PT on COMBO CCS - DC', async () => {
await billingTestHelper.initChargingStationContext2TestFastCharger('FF+CT+PT');
await billingTestHelper.makeCurrentUserContextReadyForBilling();
- const transactionID = await billingTestHelper.generateTransaction(billingTestHelper.userContext);
+ const transactionID = await billingTestHelper.generateTransaction();
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, 11.49);
@@ -638,7 +638,7 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
it('should bill the CT(STEP)+PT(STEP) on COMBO CCS - DC', async () => {
await billingTestHelper.initChargingStationContext2TestFastCharger('CT(STEP)+PT(STEP)');
await billingTestHelper.makeCurrentUserContextReadyForBilling();
- const transactionID = await billingTestHelper.generateTransaction(billingTestHelper.userContext);
+ const transactionID = await billingTestHelper.generateTransaction();
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, 21.00);
@@ -647,7 +647,7 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
it('should bill the ENERGY + PT(STEP) on COMBO CCS - DC', async () => {
await billingTestHelper.initChargingStationContext2TestFastCharger('E+PT(STEP)');
await billingTestHelper.makeCurrentUserContextReadyForBilling();
- const transactionID = await billingTestHelper.generateTransaction(billingTestHelper.userContext);
+ const transactionID = await billingTestHelper.generateTransaction();
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);
@@ -656,7 +656,7 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
it('should bill the ENERGY + CT(STEP80S) on COMBO CCS - DC', async () => {
await billingTestHelper.initChargingStationContext2TestFastCharger('E+CT(STEP80S)');
await billingTestHelper.makeCurrentUserContextReadyForBilling();
- const transactionID = await billingTestHelper.generateTransaction(billingTestHelper.userContext);
+ const transactionID = await billingTestHelper.generateTransaction();
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, 10.11);
@@ -669,7 +669,7 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
await billingTestHelper.initChargingStationContext2TestFastCharger('E-After30mins+PT');
// A tariff applied immediately
await billingTestHelper.makeCurrentUserContextReadyForBilling();
- const transactionID = await billingTestHelper.generateTransaction(billingTestHelper.userContext);
+ const transactionID = await billingTestHelper.generateTransaction();
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, 34.63);
@@ -684,7 +684,7 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
await billingTestHelper.initChargingStationContext2TestFastCharger('E(STEP)-After30mins');
// A tariff applied immediately
await billingTestHelper.makeCurrentUserContextReadyForBilling();
- const transactionID = await billingTestHelper.generateTransaction(billingTestHelper.userContext);
+ const transactionID = await billingTestHelper.generateTransaction();
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, 25);
@@ -700,7 +700,7 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
await billingTestHelper.initChargingStationContext2TestFastCharger('E(STEP)-After30mins');
// A tariff applied immediately
await billingTestHelper.makeCurrentUserContextReadyForBilling();
- const transactionID = await billingTestHelper.generateTransaction(billingTestHelper.userContext);
+ const transactionID = await billingTestHelper.generateTransaction();
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, 17.37);
@@ -722,7 +722,7 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
billingTestHelper.checkTimezone();
// A tariff applied immediately
await billingTestHelper.makeCurrentUserContextReadyForBilling();
- const transactionID = await billingTestHelper.generateTransaction(billingTestHelper.userContext);
+ const transactionID = await billingTestHelper.generateTransaction();
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, 33.82);
@@ -738,7 +738,7 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
billingTestHelper.checkTimezone();
// A tariff applied immediately
await billingTestHelper.makeCurrentUserContextReadyForBilling();
- const transactionID = await billingTestHelper.generateTransaction(billingTestHelper.userContext);
+ const transactionID = await billingTestHelper.generateTransaction();
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, 59.99);
@@ -754,7 +754,7 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
billingTestHelper.checkTimezone();
// A tariff applied immediately
await billingTestHelper.makeCurrentUserContextReadyForBilling();
- const transactionID = await billingTestHelper.generateTransaction(billingTestHelper.userContext);
+ const transactionID = await billingTestHelper.generateTransaction();
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, 16.16);
@@ -793,7 +793,7 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
async () => {
await billingTestHelper.makeCurrentUserContextReadyForBilling();
const itemsBefore = await billingTestHelper.getNumberOfSessions(billingTestHelper.userContext.id);
- const transactionID = await billingTestHelper.generateTransaction(billingTestHelper.userContext);
+ const transactionID = await billingTestHelper.generateTransaction();
assert(transactionID, 'transactionID should not be null');
// await testData.checkTransactionBillingData(transactionID); // TODO - Check not yet possible!
// await testData.userService.billingApi.synchronizeInvoices({});
@@ -831,7 +831,7 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
it('should add an item to a DRAFT invoice after a transaction', async () => {
await billingTestHelper.userService.billingApi.forceSynchronizeUser({ id: billingTestHelper.userContext.id });
const itemsBefore = await billingTestHelper.getNumberOfSessions(billingTestHelper.userContext.id);
- const transactionID = await billingTestHelper.generateTransaction(billingTestHelper.userContext);
+ const transactionID = await billingTestHelper.generateTransaction();
assert(transactionID, 'transactionID should not be null');
// await testData.checkTransactionBillingData(transactionID); // TODO - Check not yet possible!
// await testData.userService.billingApi.synchronizeInvoices({});
@@ -858,7 +858,7 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
it('should create a DRAFT invoice, Finalize it and Pay it', async () => {
await billingTestHelper.makeCurrentUserContextReadyForBilling();
- const transactionID = await billingTestHelper.generateTransaction(billingTestHelper.userContext);
+ const transactionID = await billingTestHelper.generateTransaction();
assert(transactionID, 'transactionID should not be null');
// Check that we have a new invoice with an invoiceID and but no invoiceNumber yet
await billingTestHelper.checkTransactionBillingData(transactionID, BillingInvoiceStatus.DRAFT);
@@ -907,7 +907,7 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
const dateInThePast = moment().add(-5, 'hours').toDate();
await billingTestHelper.initChargingStationContext2TestFastCharger('E+PT(STEP)', dateInThePast);
await billingTestHelper.makeCurrentUserContextReadyForBilling();
- const transactionID = await billingTestHelper.generateTransaction(billingTestHelper.userContext, 'Accepted', dateInThePast, true);
+ const transactionID = await billingTestHelper.generateTransaction('Accepted', dateInThePast, 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, 19.49);

MODIFY
test/api/BillingTestHelper.ts
test/api/BillingTestHelper.ts
@@ -111,7 +111,8 @@ export default class BillingTestHelper {
public async initContext2TestConnectedAccounts() : Promise<void> {
// Assign a tariff the the charger
- const chargingStationContext = await this.initChargingStationContext2TestChargingTime();
+ // const chargingStationContext = await this.initChargingStationContext2TestChargingTime();
+ const chargingStationContext = await this.initChargingStationContext2TestCS3Phased();
// Get an active account (create it if necessary)
const billingAccount = await this.getActivatedAccount();
const chargingStation = chargingStationContext.getChargingStation();
@@ -512,7 +513,17 @@ export default class BillingTestHelper {
await this.adminUserService.settingApi.update(componentSetting);
}
- public async checkTransactionBillingData(transactionId: number, expectedInvoiceStatus: BillingInvoiceStatus, expectedPrice: number = null) : Promise<void> {
+ public async checkInvoiceData(invoiceID: string, expectedStatus: BillingInvoiceStatus, expectedSessionCounter: number, expectedAmount: number): Promise<void> {
+ const response = await this.userService.billingApi.readInvoice(invoiceID);
+ expect(response.status).to.equal(StatusCodes.OK);
+ const invoice = response.data as BillingInvoice;
+ expect(invoice.status).to.equal(expectedStatus);
+ expect(invoice.sessions?.length).to.equal(expectedSessionCounter);
+ expect(invoice.amount).to.equal(expectedAmount * 100); // TODO - This is in cents - migration required :(
+ expect(response.data?.billingData, 'Billing Data should be set');
+ }
+
+ public async checkTransactionBillingData(transactionId: number, expectedInvoiceStatus: BillingInvoiceStatus, expectedPrice: number = null) : Promise<BillingDataTransactionStop> {
// Check the transaction status
const transactionResponse = await this.adminUserService.transactionApi.readById(transactionId);
expect(transactionResponse.status).to.equal(StatusCodes.OK);
@@ -538,6 +549,8 @@ export default class BillingTestHelper {
const billedPrice = this.getBilledRoundedPrice(billingDataStop);
assert(billedPrice.equals(expectedPrice), `The billed price should be: ${expectedPrice} - actual value: ${billedPrice.toNumber()}`);
}
+ // Returns the STOP information
+ return billingDataStop;
}
public getBilledRoundedPrice(billingDataStop: BillingDataTransactionStop): Decimal {
@@ -579,7 +592,15 @@ export default class BillingTestHelper {
}
}
- public async generateTransaction(user: any, expectedStatus = 'Accepted', expectedStartDate = new Date(), withSoftStopSimulation = false): Promise<number> {
+ public async generateTransactionAndCheckBillingStatus(expectedBillingStatus : BillingInvoiceStatus): Promise<number> {
+ const transactionID = await this.generateTransaction();
+ assert(transactionID, 'transactionID should not be null');
+ // Check that we have a new invoice with an invoiceID and but no invoiceNumber yet
+ await this.checkTransactionBillingData(transactionID, expectedBillingStatus);
+ return transactionID;
+ }
+
+ public async generateTransaction(expectedStatus = 'Accepted', expectedStartDate = new Date(), withSoftStopSimulation = false): Promise<number> {
const meterStart = 0;
const meterStop = 32325; // Unit: Wh
const meterValueRampUp = Utils.createDecimal(meterStop).divToInt(80).toNumber();
@@ -587,8 +608,10 @@ export default class BillingTestHelper {
const meterValuePoorConsumption = 0; // Simulate a gap in the energy provisioning
const meterValuePhaseOut = Utils.createDecimal(meterStop).divToInt(60).toNumber();
const connectorId = 1;
- assert((user.tags && user.tags.length), 'User must have a valid tag');
- const tagId = user.tags[0].id;
+ // TODO - wrong type User vs UserContext?
+ const user = this.userContext as any;
+ const tagId = user?.tags?.[0]?.id;
+ assert(tagId, 'User must have a valid tag');
// # Begin
const startDate = moment(expectedStartDate);
// Let's send an OCCP status notification to simulate some extra inactivities

MODIFY
test/api/client/BillingApi.ts
test/api/client/BillingApi.ts
@@ -52,6 +52,10 @@ export default class BillingApi extends CrudApi {
return super.readAll(params, paging, ordering, super.buildRestEndpointUrl(RESTServerRoute.REST_BILLING_INVOICES));
}
+ public async readInvoice(id: string) {
+ return super.read({}, super.buildRestEndpointUrl(RESTServerRoute.REST_BILLING_INVOICE, { id }));
+ }
+
public async createBillingAccount(params) {
return super.create(params, super.buildRestEndpointUrl(RESTServerRoute.REST_BILLING_ACCOUNTS));
}

bp - tests - one step beyond