billing - removal of some feature toggles
MODIFY
src/integration/billing/BillingIntegration.ts
src/integration/billing/BillingIntegration.ts
@@ -89,7 +89,6 @@ export default abstract class BillingIntegration {
public async synchronizeUser(user: User): Promise<BillingUser> {
let billingUser: BillingUser = null;
- if (FeatureToggles.isFeatureActive(Feature.BILLING_SYNC_USER)) {
try {
billingUser = await this._synchronizeUser(user);
await Logging.logInfo({
@@ -112,15 +111,6 @@ export default abstract class BillingIntegration {
detailedMessages: { error: error.stack }
});
}
- } else {
- await Logging.logWarning({
- tenantID: this.tenant.id,
- source: Constants.CENTRAL_SERVER,
- action: ServerAction.BILLING_SYNCHRONIZE_USER,
- module: MODULE_NAME, method: 'synchronizeUser',
- message: 'Feature is switched OFF - operation has been aborted'
- });
- }
return billingUser;
}
@@ -308,7 +298,6 @@ export default abstract class BillingIntegration {
}
// Check Billing Data
if (!transaction.user?.billingData?.customerID) {
- if (FeatureToggles.isFeatureActive(Feature.BILLING_CHECK_USER_BILLING_DATA)) {
throw new BackendError({
message: 'User has no Billing Data',
source: Constants.CENTRAL_SERVER,
@@ -318,7 +307,6 @@ export default abstract class BillingIntegration {
});
}
}
- }
public checkStartTransaction(transaction: Transaction): void {
// Check User
@@ -333,7 +321,6 @@ export default abstract class BillingIntegration {
}
// Check Billing Data (only in Live Mode)
if (!transaction.user?.billingData?.customerID) {
- if (FeatureToggles.isFeatureActive(Feature.BILLING_CHECK_USER_BILLING_DATA)) {
throw new BackendError({
message: 'User has no billing data or no customer ID',
source: Constants.CENTRAL_SERVER,
@@ -343,7 +330,6 @@ export default abstract class BillingIntegration {
});
}
}
- }
private async _getUsersWithNoBillingData(): Promise<User[]> {
const newUsers = await UserStorage.getUsers(this.tenant.id,

MODIFY
src/utils/FeatureToggles.ts
src/utils/FeatureToggles.ts
// Declare here the list of features
export enum Feature {
BILLING_SYNC_USERS,
- BILLING_SYNC_USER,
- BILLING_CHECK_USER_BILLING_DATA,
BILLING_ITEM_WITH_PARKING_TIME,
- BILLING_ITEM_WITH_START_DATE,
BILLING_CHECK_THRESHOLD_ON_STOP,
- BILLING_PREVENT_CUSTOMER_DELETION,
+ BILLING_PREVENT_CUSTOMER_DELETION
}
export default class FeatureToggles {
// Comment out the features that you want to switch OFF
static activeFeatures: Feature[] = [
// Feature.BILLING_SYNC_USERS, - When switched OFF the sync of the user should be implicit (LAZY mode)
- Feature.BILLING_SYNC_USER,
- Feature.BILLING_CHECK_USER_BILLING_DATA,
// Feature.BILLING_ITEM_WITH_PARKING_TIME,
- Feature.BILLING_ITEM_WITH_START_DATE,
Feature.BILLING_CHECK_THRESHOLD_ON_STOP,
- Feature.BILLING_PREVENT_CUSTOMER_DELETION,
+ Feature.BILLING_PREVENT_CUSTOMER_DELETION
];
// Check whether the feature is active or not!

MODIFY
test/api/BillingTest.ts
test/api/BillingTest.ts
@@ -501,9 +501,6 @@ describe('Billing Service', function() {
testData.createdUsers.push(fakeUser);
// Let's check that the corresponding billing user exists as well (a Customer in the STRIPE DB)
let billingUser = await testData.billingImpl.getUser(fakeUser);
- if (!billingUser && !FeatureToggles.isFeatureActive(Feature.BILLING_SYNC_USER)) {
- billingUser = await testData.billingImpl.forceSynchronizeUser(fakeUser);
- }
expect(billingUser).to.be.not.null;
// Let's update the new user
fakeUser.firstName = 'Test';
@@ -514,9 +511,6 @@ describe('Billing Service', function() {
fakeUser,
false
);
- if (!FeatureToggles.isFeatureActive(Feature.BILLING_SYNC_USER)) {
- billingUser = await testData.billingImpl.forceSynchronizeUser(fakeUser);
- }
// Let's check that the corresponding billing user was updated as well
billingUser = await testData.billingImpl.getUser(fakeUser);
expect(billingUser.name).to.be.eq(fakeUser.firstName + ' ' + fakeUser.name);
@@ -754,11 +748,7 @@ describe('Billing Service', function() {
);
testData.createdUsers.push(fakeUser);
testData.billingImpl = await testData.setBillingSystemValidCredentials();
- if (FeatureToggles.isFeatureActive(Feature.BILLING_SYNC_USER)) {
await testData.userService.billingApi.synchronizeUser({ id: fakeUser.id });
- } else {
- await testData.userService.billingApi.forceSynchronizeUser(fakeUser);
- }
const userExists = await testData.billingImpl.isUserSynchronized(fakeUser);
expect(userExists).to.be.true;
});

billing - removal of some feature toggles