Some transactions are twice or trice in database; fixed at least that they are not displayed anymore twice or trice in UI

This commit is contained in:
dankito 2021-11-06 02:00:44 +01:00
parent babc74179a
commit fc243f2a54
1 changed files with 4 additions and 4 deletions

View File

@ -794,14 +794,14 @@ open class BankingPresenter(
open fun searchAccountTransactions(query: String, transactions: List<IAccountTransaction>): List<IAccountTransaction> { open fun searchAccountTransactions(query: String, transactions: List<IAccountTransaction>): List<IAccountTransaction> {
val queryLowercase = query.trim().toLowerCase() val queryLowercase = query.trim().toLowerCase()
// get transactions sorted by date // get unique transactions sorted by date
val transactionsSorted = transactions.toSet().sortedByDate() val uniqueTransactionsSorted = transactions.toSet().sortedByDate()
if (queryLowercase.isEmpty()) { if (queryLowercase.isEmpty()) {
return transactionsSorted return uniqueTransactionsSorted
} }
return transactionsSorted.filter { return uniqueTransactionsSorted.filter {
it.otherPartyName?.toLowerCase()?.contains(queryLowercase) == true it.otherPartyName?.toLowerCase()?.contains(queryLowercase) == true
|| it.reference.toLowerCase().contains(queryLowercase) || it.reference.toLowerCase().contains(queryLowercase)
|| it.bookingText?.toLowerCase()?.contains(queryLowercase) == true || it.bookingText?.toLowerCase()?.contains(queryLowercase) == true