From 025b91d318339062316109714425c9124561a914 Mon Sep 17 00:00:00 2001 From: dankito Date: Mon, 9 Sep 2024 22:59:05 +0200 Subject: [PATCH] Passing known bank data on to BankingClient (as e.g. bank names returned from bank server are often quite bad, e.g. DB24 for Deutsche Bank) --- .../net/codinux/banking/ui/service/BankingService.kt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/BankingService.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/BankingService.kt index c37a3cf..e2ed763 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/BankingService.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/BankingService.kt @@ -21,7 +21,6 @@ import net.codinux.banking.fints.config.FinTsClientOptions import net.codinux.banking.ui.IOorDefault import net.codinux.banking.ui.model.AccountTransactionViewModel import net.codinux.banking.ui.model.BankInfo -import net.codinux.banking.ui.model.TanChallengeReceived import net.codinux.banking.ui.model.error.* import net.codinux.banking.ui.model.events.AccountTransactionsRetrievedEvent import net.codinux.banking.ui.model.events.TransferredMoneyEvent @@ -74,7 +73,7 @@ class BankingService( suspend fun addAccount(bank: BankInfo, loginName: String, password: String, retrieveAllTransactions: Boolean = false): Boolean { try { val retrieveTransactions = if (retrieveAllTransactions) RetrieveTransactions.All else RetrieveTransactions.OfLast90Days - val response = client.getAccountDataAsync(GetAccountDataRequest(bank.bankCode, loginName, password, GetAccountDataOptions(retrieveTransactions))) + val response = client.getAccountDataAsync(GetAccountDataRequest(bank.bankCode, loginName, password, GetAccountDataOptions(retrieveTransactions), mapBankInfo(bank))) if (response.type == ResponseType.Success && response.data != null) { handleSuccessfulGetAccountDataResponse(response.data!!) @@ -92,6 +91,15 @@ class BankingService( } } + private fun mapBankInfo(bank: BankInfo): net.codinux.banking.client.model.BankInfo? = + if (bank.pinTanAddress != null) { + net.codinux.banking.client.model.BankInfo( + bank.name, bank.bic, bank.pinTanAddress, bank.bankingGroup + ) + } else { + null + } + private suspend fun handleSuccessfulGetAccountDataResponse(response: GetAccountDataResponse) { try { val newUser = response.user