Mapping BankingGroup (TODO: but is duplicated code from BankListCreator); added BankingGroup to CustomerAccountViewInfo
This commit is contained in:
parent
72889aeeed
commit
a983df42b1
|
@ -10,7 +10,8 @@ import net.codinux.banking.client.model.config.NoArgConstructor
|
|||
open class CustomerAccountViewInfo(
|
||||
val bankCode: String,
|
||||
var loginName: String,
|
||||
val bankName: String
|
||||
val bankName: String,
|
||||
val bankingGroup: BankingGroup? = null
|
||||
) {
|
||||
override fun toString() = "$bankCode $bankName $loginName"
|
||||
}
|
|
@ -21,6 +21,7 @@ import net.codinux.banking.fints.messages.datenelemente.implementierte.tan.TanMe
|
|||
import net.codinux.banking.fints.messages.datenelemente.implementierte.tan.MobilePhoneTanMedium
|
||||
import net.codinux.banking.fints.messages.datenelemente.implementierte.tan.TanGeneratorTanMedium
|
||||
import net.codinux.banking.fints.messages.datenelemente.implementierte.tan.TanMediumStatus
|
||||
import net.dankito.banking.banklistcreator.prettifier.BankingGroupMapper
|
||||
import kotlin.io.encoding.Base64
|
||||
import kotlin.io.encoding.ExperimentalEncodingApi
|
||||
|
||||
|
@ -28,6 +29,8 @@ open class FinTs4kMapper {
|
|||
|
||||
protected val fintsModelMapper = FinTsModelMapper()
|
||||
|
||||
protected val bankingGroupMapper = BankingGroupMapper()
|
||||
|
||||
|
||||
open fun mapToGetAccountDataParameter(credentials: AccountCredentials, options: GetAccountDataOptions) = GetAccountDataParameter(
|
||||
credentials.bankCode, credentials.loginName, credentials.password,
|
||||
|
@ -52,7 +55,7 @@ open class FinTs4kMapper {
|
|||
|
||||
|
||||
open fun mapToCustomerAccountViewInfo(bank: BankData): CustomerAccountViewInfo = CustomerAccountViewInfo(
|
||||
bank.bankCode, bank.customerId, bank.bankName
|
||||
bank.bankCode, bank.customerId, bank.bankName, getBankingGroup(bank.bankName, bank.bic)
|
||||
)
|
||||
|
||||
open fun mapToBankAccountViewInfo(account: AccountData): BankAccountViewInfo = BankAccountViewInfo(
|
||||
|
@ -68,9 +71,14 @@ open class FinTs4kMapper {
|
|||
customer.accounts.map { mapAccount(it) },
|
||||
|
||||
customer.selectedTanMethod?.securityFunction?.code, customer.tanMethods.map { mapTanMethod(it) },
|
||||
customer.selectedTanMedium?.mediumName, customer.tanMedia.map { mapTanMedium(it) }
|
||||
customer.selectedTanMedium?.mediumName, customer.tanMedia.map { mapTanMedium(it) },
|
||||
|
||||
getBankingGroup(customer.bankName, customer.bic)
|
||||
)
|
||||
|
||||
protected open fun getBankingGroup(bankName: String, bic: String): BankingGroup? =
|
||||
bankingGroupMapper.getBankingGroup(bankName, bic)
|
||||
|
||||
|
||||
protected open fun mapAccount(account: net.dankito.banking.client.model.BankAccount): BankAccount = BankAccount(
|
||||
account.identifier, account.accountHolderName, mapAccountType(account.type), account.iban, account.subAccountNumber,
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
package net.dankito.banking.banklistcreator.prettifier
|
||||
|
||||
import net.codinux.banking.client.model.BankingGroup
|
||||
|
||||
// TODO: class has been duplicated from BankListCreator, find a better place for it
|
||||
class BankingGroupMapper {
|
||||
|
||||
fun getBankingGroup(bankName: String, bic: String): BankingGroup? {
|
||||
val lowercase = bankName.lowercase()
|
||||
|
||||
return when {
|
||||
bankName.contains("Sparda") -> BankingGroup.Sparda
|
||||
bankName.contains("PSD") -> BankingGroup.PSD
|
||||
bankName.contains("GLS") -> BankingGroup.GLS
|
||||
// see https://de.wikipedia.org/wiki/Liste_der_Genossenschaftsbanken_in_Deutschland
|
||||
bankName.contains("BBBank") || bankName.contains("Evangelische Bank") || bankName.contains("LIGA Bank")
|
||||
|| bankName.contains("Pax") || bankName.contains("Bank für Kirche und Diakonie") || bankName.contains("Bank im Bistum Essen")
|
||||
|| bankName.contains("Bank für Schiffahrt") || bankName.contains("Bank für Kirche")
|
||||
-> BankingGroup.SonstigeGenossenschaftsbank
|
||||
lowercase.contains("deutsche kreditbank") -> BankingGroup.DKB
|
||||
// may check against https://de.wikipedia.org/wiki/Liste_der_Sparkassen_in_Deutschland
|
||||
lowercase.contains("sparkasse") -> BankingGroup.Sparkasse
|
||||
lowercase.contains("comdirect") -> BankingGroup.Comdirect
|
||||
lowercase.contains("commerzbank") -> BankingGroup.Commerzbank
|
||||
lowercase.contains("targo") -> BankingGroup.Targobank
|
||||
lowercase.contains("santander") -> BankingGroup.Santander
|
||||
bankName.contains("KfW") -> BankingGroup.KfW
|
||||
bankName.contains("N26") -> BankingGroup.N26
|
||||
else -> getBankingGroupByBic(bic)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getBankingGroupByBic(bic: String): BankingGroup? {
|
||||
if (bic.length < 4) {
|
||||
return null
|
||||
}
|
||||
|
||||
if (bic.startsWith("CMCIDEDD")) {
|
||||
return BankingGroup.Targobank
|
||||
}
|
||||
|
||||
val bankCodeOfBic = bic.substring(0, 4)
|
||||
|
||||
return when (bankCodeOfBic) {
|
||||
"GENO", "VBMH", "VOHA", "VBRS", "DBPB", "VBGT", "FFVB", "WIBA", "VRBU", "MVBM", "VOBA", "ULMV", "VBRT", "VBRA", "VBPF", "VOLO" -> BankingGroup.VolksUndRaiffeisenbanken
|
||||
"BFSW", // Bank fuer Sozialwirtschaft
|
||||
"BEVO", // Berliner Volksbank
|
||||
"DAAE", // apoBank
|
||||
"MHYP", // Münchener Hypothekenbank
|
||||
"DZBM", // DZB Bank
|
||||
"EDEK" // Edekabank
|
||||
-> BankingGroup.SonstigeGenossenschaftsbank
|
||||
"BYLA", "SOLA", "NOLA", "WELA", "HELA", "MALA", "BRLA", "NASS", "TRIS", "OSDD", "ESSL", "GOPS", "SBCR", "BRUS" -> BankingGroup.Sparkasse // filter out DBK, (Bayr.) Landesbank, ...
|
||||
"OLBO" -> BankingGroup.OldenburgischeLandesbank
|
||||
"DEUT" -> BankingGroup.DeutscheBank
|
||||
"PBNK" -> BankingGroup.Postbank
|
||||
"COBA", "DRES" -> BankingGroup.Commerzbank // COBA could also be comdirect, but we cannot differentiate this at this level, this has to do getBankingGroup()
|
||||
"HYVE" -> BankingGroup.Unicredit
|
||||
"INGB" -> BankingGroup.ING
|
||||
"SCFB" -> BankingGroup.Santander
|
||||
"NORS" -> BankingGroup.Norisbank
|
||||
"DEGU" -> BankingGroup.Degussa
|
||||
"OBKL" -> BankingGroup.Oberbank
|
||||
"MARK" -> BankingGroup.Bundesbank
|
||||
"KFWI", "DTAB" -> BankingGroup.KfW
|
||||
"NTSB" -> BankingGroup.N26
|
||||
"CSDB" -> BankingGroup.Consors
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue