Fixed that there are banks without BIC - which let the app crash
This commit is contained in:
parent
f053a4a55f
commit
372c0ec15d
|
@ -452,12 +452,12 @@ open class BankingPresenter(
|
||||||
|
|
||||||
val groupedByBic = searchResult.groupBy { it.bic }
|
val groupedByBic = searchResult.groupBy { it.bic }
|
||||||
|
|
||||||
if (groupedByBic.size == 1) {
|
if (groupedByBic.size == 1 && groupedByBic.keys.first().isNullOrBlank() == false) {
|
||||||
return searchResult.first()
|
return searchResult.first()
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if all BICs belong to the same bank but may are for different branches
|
// 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) {
|
if (bicsWithoutBranchCode.size == 1) {
|
||||||
return searchResult.firstOrNull { it.bic.endsWith("XXX") } // 'XXX' = primary office
|
return searchResult.firstOrNull { it.bic.endsWith("XXX") } // 'XXX' = primary office
|
||||||
|
|
Loading…
Reference in New Issue