diff --git a/tools/BankFinder/src/commonMain/kotlin/net/dankito/banking/bankfinder/BankInfo.kt b/tools/BankFinder/src/commonMain/kotlin/net/dankito/banking/bankfinder/BankInfo.kt index 7050cc5e..53a0666d 100644 --- a/tools/BankFinder/src/commonMain/kotlin/net/dankito/banking/bankfinder/BankInfo.kt +++ b/tools/BankFinder/src/commonMain/kotlin/net/dankito/banking/bankfinder/BankInfo.kt @@ -8,7 +8,8 @@ open class BankInfo( open val postalCode: String, open val city: String, open val pinTanAddress: String?, - open val pinTanVersion: String? + open val pinTanVersion: String?, + open var branchesInOtherCities: List = listOf() // to have only one entry per bank its branches's cities are now stored in branchesInOtherCities so that branches' cities are still searchable ) { protected constructor() : this("", "", "", "", "", null, "") // for object deserializers diff --git a/tools/BankFinder/src/commonMain/kotlin/net/dankito/banking/bankfinder/InMemoryBankFinder.kt b/tools/BankFinder/src/commonMain/kotlin/net/dankito/banking/bankfinder/InMemoryBankFinder.kt index 43701381..1c46d46e 100644 --- a/tools/BankFinder/src/commonMain/kotlin/net/dankito/banking/bankfinder/InMemoryBankFinder.kt +++ b/tools/BankFinder/src/commonMain/kotlin/net/dankito/banking/bankfinder/InMemoryBankFinder.kt @@ -40,6 +40,7 @@ open class InMemoryBankFinder() : BankFinderBase(), IBankFinder { protected open fun checkIfQueryMatchesBankNameOrCity(bankInfo: BankInfo, queryLowerCase: String): Boolean { return bankInfo.name.toLowerCase().contains(queryLowerCase) || bankInfo.city.toLowerCase().startsWith(queryLowerCase) + || bankInfo.branchesInOtherCities.any { it.toLowerCase().startsWith(queryLowerCase) } } diff --git a/tools/BankFinder/src/iosMain/kotlin/net/dankito/banking/bankfinder/BankListDeserializer.kt b/tools/BankFinder/src/iosMain/kotlin/net/dankito/banking/bankfinder/BankListDeserializer.kt index 06c2bbbf..ceba2472 100644 --- a/tools/BankFinder/src/iosMain/kotlin/net/dankito/banking/bankfinder/BankListDeserializer.kt +++ b/tools/BankFinder/src/iosMain/kotlin/net/dankito/banking/bankfinder/BankListDeserializer.kt @@ -35,7 +35,8 @@ actual class BankListDeserializer { bankInfoDict.getStringOrEmpty("postalCode"), bankInfoDict.getStringOrEmpty("city"), bankInfoDict.getString("pinTanAddress"), - bankInfoDict.getString("pinTanVersion") + bankInfoDict.getString("pinTanVersion"), + bankInfoDict.mutableArrayValueForKey("branchesInOtherCities").mapNotNull { it as? String } ) } diff --git a/tools/BankListCreator/src/main/kotlin/net/dankito/banking/banklistcreator/prettifier/BankListPrettifier.kt b/tools/BankListCreator/src/main/kotlin/net/dankito/banking/banklistcreator/prettifier/BankListPrettifier.kt index 878d0b39..4ebf3356 100644 --- a/tools/BankListCreator/src/main/kotlin/net/dankito/banking/banklistcreator/prettifier/BankListPrettifier.kt +++ b/tools/BankListCreator/src/main/kotlin/net/dankito/banking/banklistcreator/prettifier/BankListPrettifier.kt @@ -20,6 +20,10 @@ open class BankListPrettifier { prettifiedList = removeBanksWithSameBankCodeAndCity(prettifiedList) } + if (options.contains(BankListPrettifierOption.MergeAllBranchesOfBankIntoOne)) { + prettifiedList = mergeAllBranchesOfBankIntoOne(prettifiedList) + } + if (options.contains(BankListPrettifierOption.MapBankNamesToWellKnownNames)) { prettifiedList = mapBankNamesToWellKnownNames(prettifiedList) } @@ -105,4 +109,40 @@ open class BankListPrettifier { return prettifiedList } + open fun mergeAllBranchesOfBankIntoOne(banks: List): List { + val groupedByBankCodeAndPinTanAddress = banks.groupBy { it.bankCode + "_" + it.pinTanAddress } + + val banksToRemove = groupedByBankCodeAndPinTanAddress.values.flatMap { banksWithSameBankCodeAndPinTanAddress -> + if (banksWithSameBankCodeAndPinTanAddress.size > 1) { + val banksToRemove = banksWithSameBankCodeAndPinTanAddress.toMutableList() + val mainBranch = findMainBranch(banksWithSameBankCodeAndPinTanAddress) + + banksToRemove.remove(banksWithSameBankCodeAndPinTanAddress.first()) + + mainBranch.branchesInOtherCities = banksToRemove.map { it.city }.toSet().toList() + + return@flatMap banksToRemove + } + + listOf() + } + + val prettifiedList = banks.toMutableList() + prettifiedList.removeAll(banksToRemove) + + return prettifiedList + } + + private fun findMainBranch(banksWithSameBankCodeAndPinTanAddress: List): BankInfo { +// banksWithSameBankCodeAndPinTanAddress.forEach { bank -> +// if (bank.name.contains(bank.city)) { +// println("${bank.name}: Picked ${bank.city} from ${banksWithSameBankCodeAndPinTanAddress.map { it.city }}") +// return bank +// } +// } + + // in most cases this turned out to be the best one + return banksWithSameBankCodeAndPinTanAddress.first() + } + } \ No newline at end of file diff --git a/tools/BankListCreator/src/main/kotlin/net/dankito/banking/banklistcreator/prettifier/BankListPrettifierOption.kt b/tools/BankListCreator/src/main/kotlin/net/dankito/banking/banklistcreator/prettifier/BankListPrettifierOption.kt index 532ea92b..cf5d4d2f 100644 --- a/tools/BankListCreator/src/main/kotlin/net/dankito/banking/banklistcreator/prettifier/BankListPrettifierOption.kt +++ b/tools/BankListCreator/src/main/kotlin/net/dankito/banking/banklistcreator/prettifier/BankListPrettifierOption.kt @@ -18,6 +18,11 @@ enum class BankListPrettifierOption { */ RemoveBanksWithSameBankCodeAndCity, + /** + * By default each branch has its own BankInfo. With this option only main branch keeps its BankInfo and all branches get added to branchesInOtherCities. + */ + MergeAllBranchesOfBankIntoOne, + /** * Removes banks like 'Deutsche Bank (Gf intern)' or 'UniCredit Bank - HVB Settlement EAC01' etc. */ diff --git a/tools/LuceneBankFinder/src/main/kotlin/net/dankito/banking/bankfinder/LuceneBankFinder.kt b/tools/LuceneBankFinder/src/main/kotlin/net/dankito/banking/bankfinder/LuceneBankFinder.kt index 8f86b03e..540bf0d3 100644 --- a/tools/LuceneBankFinder/src/main/kotlin/net/dankito/banking/bankfinder/LuceneBankFinder.kt +++ b/tools/LuceneBankFinder/src/main/kotlin/net/dankito/banking/bankfinder/LuceneBankFinder.kt @@ -180,7 +180,7 @@ open class LuceneBankFinder(indexFolder: File) : BankFinderBase(), IBankFinder { } protected open fun createDocumentForBank(bank: BankInfo, writer: DocumentsWriter): Document { - return writer.createDocumentForNonNullFields( + val indexableFields = mutableListOf( fields.fullTextSearchField(BankInfoNameFieldName, bank.name, true), fields.keywordField(BankInfoBankCodeFieldName, bank.bankCode, true), fields.keywordField(BankInfoBicFieldName, bank.bic, true), @@ -191,6 +191,12 @@ open class LuceneBankFinder(indexFolder: File) : BankFinderBase(), IBankFinder { fields.nullableStoredField(BankInfoPinTanServerAddressFieldName, bank.pinTanAddress), fields.nullableStoredField(BankInfoPinTanVersionFieldName, bank.pinTanVersion) ) + + bank.branchesInOtherCities.forEach { branchCity -> + indexableFields.add(fields.storedField(BankInfoCityStoredFieldName, branchCity)) + } + + return writer.createDocumentForNonNullFields(indexableFields) } diff --git a/ui/BankingAndroidApp/build.gradle b/ui/BankingAndroidApp/build.gradle index ac65e22e..0284878f 100644 --- a/ui/BankingAndroidApp/build.gradle +++ b/ui/BankingAndroidApp/build.gradle @@ -71,11 +71,19 @@ android { pickFirst 'META-INF/ktor-http-cio.kotlin_module' pickFirst 'META-INF/atomicfu.kotlin_module' + pickFirst 'META-INF/common.kotlin_module' + pickFirst 'META-INF/fints4k.kotlin_module' + pickFirst 'META-INF/BankFinder.kotlin_module' + pickFirst 'META-INF/BankFinder.kotlin_module' + pickFirst 'META-INF/DEPENDENCIES' pickFirst 'META-INF/NOTICE' pickFirst 'META-INF/LICENSE' pickFirst 'META-INF/LICENSE.txt' pickFirst 'META-INF/NOTICE.txt' + + pickFirst 'BankList.json' + exclude 'DetailedBankList.json' } lintOptions { diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/listitems/BankInfoListItem.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/listitems/BankInfoListItem.swift index adfc7f2f..6a0b1c38 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/listitems/BankInfoListItem.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/listitems/BankInfoListItem.swift @@ -59,7 +59,7 @@ struct BankInfoListItem: View { struct BankInfoListItem_Previews: PreviewProvider { static var previews: some View { - BankInfoListItem(BankInfo(name: "Abzockbank Berlin", bankCode: "12345678", bic: "ABZODEBBXXX", postalCode: "12345", city: "Berlin", pinTanAddress: nil, pinTanVersion: "FinTS 3.0")) + BankInfoListItem(BankInfo(name: "Abzockbank Berlin", bankCode: "12345678", bic: "ABZODEBBXXX", postalCode: "12345", city: "Berlin", pinTanAddress: nil, pinTanVersion: "FinTS 3.0", branchesInOtherCities: [])) } }