Added invoice notification checkbox
MODIFY
src/migration/tasks/AddNotificationsFlagsToUsersTask.ts
src/migration/tasks/AddNotificationsFlagsToUsersTask.ts
@@ -67,6 +67,7 @@ export default class AddNotificationsFlagsToUsersTask extends MigrationTask {
sendBillingSynchronizationFailed: user.notifications?.sendBillingSynchronizationFailed ? user.notifications.sendBillingSynchronizationFailed : false,
sendCarCatalogSynchronizationFailed: user.notifications?.sendCarCatalogSynchronizationFailed ? user.notifications.sendCarCatalogSynchronizationFailed : false,
sendEndUserErrorNotification: user.notifications?.sendEndUserErrorNotification ? user.notifications.sendEndUserErrorNotification : false,
+ sendBillingNewInvoice: user.notifications?.sendBillingNewInvoice ? user.notifications.sendBillingNewInvoice : false,
};
// Add new prop
if (user.role === UserRole.ADMIN) {

MODIFY
src/notification/NotificationHandler.ts
src/notification/NotificationHandler.ts
@@ -903,12 +903,20 @@ export default class NotificationHandler {
// Active?
if (notificationSource.enabled) {
try {
+ // Check notification
+ const hasBeenNotified = await NotificationHandler.hasNotifiedSourceByID(
+ tenantID, notificationSource.channel, notificationID);
+ if (!hasBeenNotified) {
+ // Enabled?
+ if (sourceData.user.notificationsActive && sourceData.user.notifications.sendBillingNewInvoice) {
// Save
await NotificationHandler.saveNotification(
tenantID, notificationSource.channel, notificationID, ServerAction.BILLING_NEW_INVOICE, { user });
// Send
await notificationSource.notificationTask.sendBillingNewInvoice(
sourceData, user, tenant, NotificationSeverity.INFO);
+ }
+ }
} catch (error) {
Logging.logActionExceptionMessage(tenantID, ServerAction.BILLING_NEW_INVOICE, error);
}

MODIFY
src/server/rest/service/security/UserSecurity.ts
src/server/rest/service/security/UserSecurity.ts
@@ -296,6 +296,7 @@ export default class UserSecurity {
sendUserAccountInactivity: notifications ? UtilsSecurity.filterBoolean(notifications.sendUserAccountInactivity) : false,
sendPreparingSessionNotStarted: notifications ? UtilsSecurity.filterBoolean(notifications.sendPreparingSessionNotStarted) : false,
sendBillingSynchronizationFailed: notifications ? UtilsSecurity.filterBoolean(notifications.sendBillingSynchronizationFailed) : false,
+ sendBillingNewInvoice: notifications ? UtilsSecurity.filterBoolean(notifications.sendBillingNewInvoice) : false,
sendNewRegisteredUser: false,
sendUnknownUserBadged: false,
sendChargingStationStatusError: false,

MODIFY
src/storage/mongodb/UserStorage.ts
src/storage/mongodb/UserStorage.ts
@@ -273,6 +273,7 @@ export default class UserStorage {
sendSessionNotStarted: userToSave.notifications ? Utils.convertToBoolean(userToSave.notifications.sendSessionNotStarted) : false,
sendCarCatalogSynchronizationFailed: userToSave.notifications ? Utils.convertToBoolean(userToSave.notifications.sendCarCatalogSynchronizationFailed) : false,
sendEndUserErrorNotification: userToSave.notifications ? Utils.convertToBoolean(userToSave.notifications.sendEndUserErrorNotification) : false,
+ sendBillingNewInvoice: userToSave.notifications ? Utils.convertToBoolean(userToSave.notifications.sendBillingNewInvoice) : false,
},
deleted: Utils.objectHasProperty(userToSave, 'deleted') ? userToSave.deleted : false
};
@@ -1129,7 +1130,8 @@ export default class UserStorage {
sendBillingSynchronizationFailed: false,
sendSessionNotStarted: false,
sendCarCatalogSynchronizationFailed: false,
- sendEndUserErrorNotification: false
+ sendEndUserErrorNotification: false,
+ sendBillingNewInvoice: false
},
role: UserRole.BASIC,
status: UserStatus.PENDING,

MODIFY
src/types/UserNotifications.ts
src/types/UserNotifications.ts
@@ -18,6 +18,7 @@ export default interface UserNotifications {
sendPreparingSessionNotStarted: boolean;
sendOfflineChargingStations: boolean;
sendBillingSynchronizationFailed: boolean;
+ sendBillingNewInvoice: boolean;
sendCarCatalogSynchronizationFailed: boolean;
sendSessionNotStarted: boolean;
sendEndUserErrorNotification: boolean;
@@ -38,6 +39,7 @@ export type UserNotificationKeys =
'sendPreparingSessionNotStarted' |
'sendOfflineChargingStations' |
'sendBillingSynchronizationFailed' |
+ 'sendBillingNewInvoice' |
'sendSessionNotStarted' |
'sendCarCatalogSynchronizationFailed' |
'sendEndUserErrorNotification'

MODIFY
test/factories/UserFactory.ts
test/factories/UserFactory.ts
@@ -32,6 +32,7 @@ const userFactory = Factory.define('user')
sendSessionNotStarted: false,
sendCarCatalogSynchronizationFailed: false,
sendEndUserErrorNotification: false,
+ sendBillingNewInvoice: false
}))
.attr('role', 'B')
.attr('status', 'A')

Added invoice notification checkbox