diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/FinTsClient.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/FinTsClient.kt index 6ca59ea2..7ded4d55 100644 --- a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/FinTsClient.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/FinTsClient.kt @@ -285,7 +285,6 @@ open class FinTsClient( callback: (AddAccountResponse) -> Unit) { // TODO: or add a default RetrievedAccountData instance for each account? val retrievedAccountData = mutableListOf() - var successfullyReceivedAccountTransactionsResponse = false val accountSupportingRetrievingTransactions = bank.accounts.filter { it.supportsFeature(AccountFeature.RetrieveBalance) || it.supportsFeature(AccountFeature.RetrieveAccountTransactions) } val countAccountSupportingRetrievingTransactions = accountSupportingRetrievingTransactions.size @@ -293,21 +292,17 @@ open class FinTsClient( if (countAccountSupportingRetrievingTransactions == 0) { addAccountAfterRetrievingTransactions(bank, newUserInfoResponse, didOverwriteUserUnselectedTanProcedure, - originalAreWeThatGentleToCloseDialogs, retrievedAccountData, successfullyReceivedAccountTransactionsResponse, callback) + originalAreWeThatGentleToCloseDialogs, retrievedAccountData, callback) } accountSupportingRetrievingTransactions.forEach { account -> tryGetTransactionsOfLast90DaysWithoutTan(bank, account) { response -> retrievedAccountData.addAll(response.retrievedData) - if (response.isSuccessful) { - successfullyReceivedAccountTransactionsResponse = true - } - countRetrievedAccounts++ if (countRetrievedAccounts == countAccountSupportingRetrievingTransactions) { addAccountAfterRetrievingTransactions(bank, newUserInfoResponse, didOverwriteUserUnselectedTanProcedure, originalAreWeThatGentleToCloseDialogs, - retrievedAccountData, successfullyReceivedAccountTransactionsResponse, callback) + retrievedAccountData, callback) } } } @@ -315,7 +310,7 @@ open class FinTsClient( protected open fun addAccountAfterRetrievingTransactions(bank: BankData, newUserInfoResponse: AddAccountResponse, didOverwriteUserUnselectedTanProcedure: Boolean, originalAreWeThatGentleToCloseDialogs: Boolean, - retrievedAccountData: List, successfullyReceivedAccountTransactionsResponse: Boolean, + retrievedAccountData: List, callback: (AddAccountResponse) -> Unit) { if (didOverwriteUserUnselectedTanProcedure) { bank.resetSelectedTanProcedure() @@ -324,7 +319,7 @@ open class FinTsClient( areWeThatGentleToCloseDialogs = originalAreWeThatGentleToCloseDialogs // TODO: to evaluate if adding account has been successful also check if count accounts > 0 - callback(AddAccountResponse(newUserInfoResponse.toResponse(), bank, successfullyReceivedAccountTransactionsResponse, retrievedAccountData)) + callback(AddAccountResponse(newUserInfoResponse.toResponse(), bank, retrievedAccountData)) } diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/client/AddAccountResponse.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/client/AddAccountResponse.kt index 53be5e93..af9407ed 100644 --- a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/client/AddAccountResponse.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/client/AddAccountResponse.kt @@ -7,6 +7,5 @@ import net.dankito.banking.fints.response.Response open class AddAccountResponse( response: Response, open val bank: BankData, - open val supportsRetrievingTransactionsOfLast90DaysWithoutTan: Boolean = false, retrievedData: List = listOf() ) : GetTransactionsResponse(response, retrievedData) \ No newline at end of file diff --git a/ui/BankingJavaFxControls/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/AddAccountDialog.kt b/ui/BankingJavaFxControls/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/AddAccountDialog.kt index e9a929f4..492f0b9e 100755 --- a/ui/BankingJavaFxControls/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/AddAccountDialog.kt +++ b/ui/BankingJavaFxControls/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/AddAccountDialog.kt @@ -266,6 +266,7 @@ open class AddAccountDialog(protected val presenter: BankingPresenter) : Window( } private fun handleSuccessfullyAddedAccountResultOnUiThread(response: AddAccountResponse) { + // TODO: remove this message and display a button to load all transactions val message = if (response.supportsRetrievingTransactionsOfLast90DaysWithoutTan) messages["add.account.dialog.successfully.added.account.bank.supports.retrieving.transactions.of.last.90.days.without.tan"] else messages["add.account.dialog.successfully.added.account"] diff --git a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/responses/AddAccountResponse.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/responses/AddAccountResponse.kt index 25dd874c..fed27dfc 100644 --- a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/responses/AddAccountResponse.kt +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/responses/AddAccountResponse.kt @@ -8,11 +8,14 @@ open class AddAccountResponse( isSuccessful: Boolean, errorToShowToUser: String?, open val customer: TypedCustomer, - open val supportsRetrievingTransactionsOfLast90DaysWithoutTan: Boolean = false, open val retrievedData: List = listOf(), userCancelledAction: Boolean = false ) : BankingClientResponse(isSuccessful, errorToShowToUser, userCancelledAction) { + open val supportsRetrievingTransactionsOfLast90DaysWithoutTan: Boolean + get() = retrievedData.isNotEmpty() && retrievedData.any { it.successfullyRetrievedData } + + override fun toString(): String { return customer.toString() + " " + super.toString() } diff --git a/ui/fints4kBankingClient/src/commonMain/kotlin/net/dankito/banking/mapper/fints4kModelMapper.kt b/ui/fints4kBankingClient/src/commonMain/kotlin/net/dankito/banking/mapper/fints4kModelMapper.kt index f4474e83..73256a05 100644 --- a/ui/fints4kBankingClient/src/commonMain/kotlin/net/dankito/banking/mapper/fints4kModelMapper.kt +++ b/ui/fints4kBankingClient/src/commonMain/kotlin/net/dankito/banking/mapper/fints4kModelMapper.kt @@ -32,9 +32,7 @@ open class fints4kModelMapper(protected val modelCreator: IModelCreator) { open fun mapResponse(customer: TypedCustomer, response: net.dankito.banking.fints.response.client.AddAccountResponse): AddAccountResponse { return AddAccountResponse(response.isSuccessful, mapErrorToShowToUser(response), - customer, response.supportsRetrievingTransactionsOfLast90DaysWithoutTan, - map(customer, response.retrievedData), - response.userCancelledAction) + customer, map(customer, response.retrievedData), response.userCancelledAction) } open fun mapResponse(bankAccount: TypedBankAccount, response: net.dankito.banking.fints.response.client.GetTransactionsResponse): GetTransactionsResponse { diff --git a/ui/hbci4jBankingClient/src/main/kotlin/net/dankito/banking/hbci4jBankingClient.kt b/ui/hbci4jBankingClient/src/main/kotlin/net/dankito/banking/hbci4jBankingClient.kt index e8ee2188..8238807f 100644 --- a/ui/hbci4jBankingClient/src/main/kotlin/net/dankito/banking/hbci4jBankingClient.kt +++ b/ui/hbci4jBankingClient/src/main/kotlin/net/dankito/banking/hbci4jBankingClient.kt @@ -89,15 +89,12 @@ open class hbci4jBankingClient( } protected open fun tryToRetrieveAccountTransactionsForAddedAccounts(customer: TypedCustomer): AddAccountResponse { - var supportsRetrievingTransactionsOfLast90DaysWithoutTan = false var userCancelledAction = false val retrievedData = customer.accounts.map { account -> if (account.supportsRetrievingAccountTransactions) { val response = getTransactionsOfLast90Days(account) - if (response.isSuccessful) { - supportsRetrievingTransactionsOfLast90DaysWithoutTan = true - } + if (response.userCancelledAction) { userCancelledAction = true } @@ -109,8 +106,7 @@ open class hbci4jBankingClient( } } - return AddAccountResponse(true, null, customer, supportsRetrievingTransactionsOfLast90DaysWithoutTan, - retrievedData, userCancelledAction) + return AddAccountResponse(true, null, customer, retrievedData, userCancelledAction) }