diff --git a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/presenter/BankingPresenter.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/presenter/BankingPresenter.kt index b336e46a..2f6bf770 100644 --- a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/presenter/BankingPresenter.kt +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/presenter/BankingPresenter.kt @@ -533,14 +533,35 @@ open class BankingPresenter constructor( open fun findRemitteesForName(name: String): List { return remitteeSearcher.findRemittees(name).map { remittee -> - remittee.bic?.let { bic -> - remittee.bankName = bankFinder.findBankByBic(bic)?.name - } + remittee.bankName = tryToFindBankName(remittee) remittee } } + protected open fun tryToFindBankName(remittee: Remittee): String? { + remittee.bic?.let { bic -> + bankFinder.findBankByBic(bic)?.name?.let { + return it + } + + if (bic.length == 8) { + bankFinder.findBankByBic(bic + "XXX")?.name?.let { + return it + } + } + } + + remittee.iban?.let { iban -> + if (iban.length > 12) { + val bankCode = iban.substring(4, 12) + return bankFinder.findBankByBankCode(bankCode).firstOrNull()?.name + } + } + + return null + } + open fun searchSelectedAccountTransactions(query: String): List { return searchAccountTransactions(query, selectedBankAccountsAccountTransactions)