diff --git a/projectforge-business/src/main/kotlin/org/projectforge/birthdaybutler/BirthdayButlerService.kt b/projectforge-business/src/main/kotlin/org/projectforge/birthdaybutler/BirthdayButlerService.kt index 63dfd9763f..00e13c1261 100644 --- a/projectforge-business/src/main/kotlin/org/projectforge/birthdaybutler/BirthdayButlerService.kt +++ b/projectforge-business/src/main/kotlin/org/projectforge/birthdaybutler/BirthdayButlerService.kt @@ -39,7 +39,6 @@ import org.projectforge.business.configuration.ConfigurationService import org.projectforge.business.user.UserDao import org.projectforge.common.StringHelper import org.projectforge.framework.i18n.translate -import org.projectforge.framework.persistence.api.QueryFilter import org.projectforge.framework.persistence.user.api.ThreadLocalUserContext import org.projectforge.framework.time.PFDateTime import org.projectforge.mail.Mail @@ -203,8 +202,7 @@ class BirthdayButlerService { * return list of users with birthday in selected month. Null, if no address with matching company found or empty, if no address with birthday in selected month found. */ private fun getBirthdayList(month: Month): MutableList? { - val queryFilter = QueryFilter() - var addressList = addressDao.internalGetList(queryFilter).filter { + var addressList = addressDao.internalLoadAllNotDeleted().filter { it.organization?.contains( birthdayButlerConfiguration.organization, ignoreCase = true @@ -218,15 +216,16 @@ class BirthdayButlerService { address.birthday?.month == Month.values()[month.ordinal] } val activeUsers = userDao.internalLoadAll().filter { it.hasSystemAccess() } - val foundUser = mutableListOf() + val foundUsers = mutableListOf() addressList.forEach { address -> activeUsers.firstOrNull { user -> address.firstName?.trim().equals(user.firstname?.trim(), ignoreCase = true) && address.name?.trim().equals(user.lastname?.trim(), ignoreCase = true) - foundUser.add(address) + }?.let { + foundUsers.add(address) } } - return foundUser + return foundUsers } private fun getEMailAddressesFromConfig(): MutableList? {