Fixed that if all BICs belong to the same bank but just have a different branch code (last three characters of a BIC), its BankInfo hasn't been returned
This commit is contained in:
parent
996204f54f
commit
8995100754
|
@ -443,7 +443,19 @@ open class BankingPresenter(
|
|||
|
||||
val groupedByBic = searchResult.groupBy { it.bic }
|
||||
|
||||
return if (groupedByBic.size == 1) searchResult.first() else null
|
||||
if (groupedByBic.size == 1) {
|
||||
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()
|
||||
|
||||
if (bicsWithoutBranchCode.size == 1) {
|
||||
return searchResult.firstOrNull { it.bic.endsWith("XXX") } // 'XXX' = primary office
|
||||
?: searchResult.first()
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
open fun searchBanksByNameBankCodeOrCity(query: String?): List<BankInfo> {
|
||||
|
|
Loading…
Reference in New Issue