Fixed that there are banks without BIC - which let the app crash

This commit is contained in:
dankito 2020-08-10 01:10:00 +02:00
parent f053a4a55f
commit 372c0ec15d
1 changed files with 2 additions and 2 deletions

View File

@ -452,12 +452,12 @@ open class BankingPresenter(
val groupedByBic = searchResult.groupBy { it.bic }
if (groupedByBic.size == 1) {
if (groupedByBic.size == 1 && groupedByBic.keys.first().isNullOrBlank() == false) {
return searchResult.first()
}
// check if all BICs belong to the same bank but may are for different branches
val bicsWithoutBranchCode = groupedByBic.map { it.key.substring(0, 8) }.toSet()
val bicsWithoutBranchCode = groupedByBic.mapNotNull { if (it.key.length >= 8) it.key.substring(0, 8) else null }.toSet()
if (bicsWithoutBranchCode.size == 1) {
return searchResult.firstOrNull { it.bic.endsWith("XXX") } // 'XXX' = primary office