diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/AccountTransactionsFilterService.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/AccountTransactionsFilterService.kt index a377438..2b9f00a 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/AccountTransactionsFilterService.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/AccountTransactionsFilterService.kt @@ -7,6 +7,9 @@ import net.codinux.banking.ui.model.AccountTransactionViewModel import net.codinux.banking.ui.model.AccountTransactionsFilter import net.codinux.banking.ui.model.BankAccountFilter + +private const val SearchTermOrSeparatorSymbol = ',' + class AccountTransactionsFilterService { fun filterAccounts(transactions: List, filter: AccountTransactionsFilter): List { @@ -22,11 +25,13 @@ class AccountTransactionsFilterService { appliedAccountFilter = appliedAccountFilter.filter { it.valueDate.year == year && (month == null || it.valueDate.monthNumber == month) } } - val searchTerm = filter.searchTerm - return if (searchTerm.isBlank()) { + val searchTerms = filter.searchTerm.split(SearchTermOrSeparatorSymbol).filter { it.isNotBlank() } + return if (searchTerms.isEmpty()) { appliedAccountFilter } else { - appliedAccountFilter.filter { matchesSearchTerm(it, searchTerm) } + appliedAccountFilter.filter { transaction -> + searchTerms.any { matchesSearchTerm(transaction, it) } + } } }