From 6bf7fdcb448abbc6bb4a0d51fc5c5769a57014d7 Mon Sep 17 00:00:00 2001 From: dankito Date: Mon, 9 Sep 2024 23:01:06 +0200 Subject: [PATCH] Implemented passing default bank data to FinTsClient as e.g. bank names returned from bank server are often quite bad, e.g. DB24 for Deutsche Bank --- .../kotlin/net/codinux/banking/fints/FinTsClient.kt | 6 ++++-- .../net/codinux/banking/fints/mapper/FinTsModelMapper.kt | 7 +++++-- .../client/model/parameter/GetAccountDataParameter.kt | 3 ++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/FinTsClient.kt b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/FinTsClient.kt index a18fc39c..32d1b6ab 100644 --- a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/FinTsClient.kt +++ b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/FinTsClient.kt @@ -184,12 +184,14 @@ open class FinTsClient( return net.dankito.banking.client.model.response.FinTsClientResponse(null, null, emptyList(), param.finTsModel) } - val finTsServerAddress = config.finTsServerAddressFinder.findFinTsServerAddress(param.bankCode) + val defaultValues = (param as? GetAccountDataParameter)?.defaultBankValues + + val finTsServerAddress = defaultValues?.finTs3ServerAddress ?: config.finTsServerAddressFinder.findFinTsServerAddress(param.bankCode) if (finTsServerAddress.isNullOrBlank()) { return net.dankito.banking.client.model.response.FinTsClientResponse(ErrorCode.BankDoesNotSupportFinTs3, "Either bank does not support FinTS 3.0 or we don't know its FinTS server address", emptyList(), null) } - val bank = mapper.mapToBankData(param, finTsServerAddress) + val bank = mapper.mapToBankData(param, finTsServerAddress, defaultValues) val getAccountInfoResponse = getAccountInfo(param, bank) diff --git a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/mapper/FinTsModelMapper.kt b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/mapper/FinTsModelMapper.kt index 17d334ba..0c44f91b 100644 --- a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/mapper/FinTsModelMapper.kt +++ b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/mapper/FinTsModelMapper.kt @@ -26,8 +26,11 @@ open class FinTsModelMapper { protected open val bicFinder = BicFinder() - open fun mapToBankData(param: FinTsClientParameter, finTsServerAddress: String): BankData { - return BankData(param.bankCode, param.loginName, param.password, finTsServerAddress, bicFinder.findBic(param.bankCode) ?: "") + open fun mapToBankData(param: FinTsClientParameter, finTsServerAddress: String, defaultValues: BankData? = null): BankData { + return BankData( + param.bankCode, param.loginName, param.password, finTsServerAddress, + defaultValues?.bic ?: bicFinder.findBic(param.bankCode) ?: "", defaultValues?.bankName ?: "" + ) } open fun mapToAccountData(credentials: BankAccountIdentifier, param: FinTsClientParameter): AccountData { diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/client/model/parameter/GetAccountDataParameter.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/client/model/parameter/GetAccountDataParameter.kt index a821131b..556396dd 100644 --- a/fints4k/src/commonMain/kotlin/net/dankito/banking/client/model/parameter/GetAccountDataParameter.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/client/model/parameter/GetAccountDataParameter.kt @@ -23,7 +23,8 @@ open class GetAccountDataParameter( preferredTanMethods: List? = null, preferredTanMedium: String? = null, abortIfTanIsRequired: Boolean = false, - finTsModel: BankData? = null + finTsModel: BankData? = null, + open val defaultBankValues: BankData? = null ) : FinTsClientParameter(bankCode, loginName, password, preferredTanMethods, preferredTanMedium, abortIfTanIsRequired, finTsModel) { open val retrieveOnlyAccountInfo: Boolean