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 7ded4d55..abaafa6c 100644 --- a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/FinTsClient.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/FinTsClient.kt @@ -318,7 +318,6 @@ 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, 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 af9407ed..63a06eb8 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 @@ -8,4 +8,9 @@ open class AddAccountResponse( response: Response, open val bank: BankData, retrievedData: List = listOf() -) : GetTransactionsResponse(response, retrievedData) \ No newline at end of file +) : GetTransactionsResponse(response, retrievedData) { + + override val isSuccessful: Boolean + get() = super.isSuccessful && bank.accounts.isNotEmpty() + +} \ No newline at end of file diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/client/GetTransactionsResponse.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/client/GetTransactionsResponse.kt index 9eb22985..52cb50cd 100644 --- a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/client/GetTransactionsResponse.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/client/GetTransactionsResponse.kt @@ -11,4 +11,9 @@ open class GetTransactionsResponse( * This value is only set if [GetTransactionsParameter.maxCountEntries] was set to tell caller if maxCountEntries parameter has been evaluated or not */ open var isSettingMaxCountEntriesAllowedByBank: Boolean? = null -) : FinTsClientResponse(response) \ No newline at end of file +) : FinTsClientResponse(response) { + + override val isSuccessful: Boolean + get() = super.isSuccessful && retrievedData.isNotEmpty() && retrievedData.none { it.successfullyRetrievedData == false } + +} \ No newline at end of file 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 44dffa28..ec83f5b4 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 @@ -5,12 +5,14 @@ import net.dankito.utils.multiplatform.BigDecimal open class AddAccountResponse( - isSuccessful: Boolean, errorToShowToUser: String?, open val customer: TypedCustomer, retrievedData: List = listOf(), userCancelledAction: Boolean = false -) : GetTransactionsResponse(isSuccessful, errorToShowToUser, retrievedData, userCancelledAction) { +) : GetTransactionsResponse(errorToShowToUser, retrievedData, userCancelledAction) { + + override val isSuccessful: Boolean + get() = super.isSuccessful && customer.accounts.isNotEmpty() open val supportsRetrievingTransactionsOfLast90DaysWithoutTan: Boolean get() = retrievedData.isNotEmpty() && retrievedData.any { it.successfullyRetrievedData } diff --git a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/responses/GetTransactionsResponse.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/responses/GetTransactionsResponse.kt index dac9f86f..a907157a 100644 --- a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/responses/GetTransactionsResponse.kt +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/responses/GetTransactionsResponse.kt @@ -4,9 +4,13 @@ import net.dankito.banking.ui.model.RetrievedAccountData open class GetTransactionsResponse( - isSuccessful: Boolean, errorToShowToUser: String?, open val retrievedData: List = listOf(), userCancelledAction: Boolean = false, open val tanRequiredButWeWereToldToAbortIfSo: Boolean = false -) : BankingClientResponse(isSuccessful, errorToShowToUser, userCancelledAction) +) : BankingClientResponse(true /* any value */, errorToShowToUser, userCancelledAction) { + + override val isSuccessful: Boolean + get() = errorToShowToUser == null && retrievedData.isNotEmpty() && retrievedData.none { it.successfullyRetrievedData == false } + +} diff --git a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/presenter/BankingPresenter.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/presenter/BankingPresenter.kt index 9c3a04a8..8f56c8e1 100644 --- a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/presenter/BankingPresenter.kt +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/presenter/BankingPresenter.kt @@ -161,7 +161,7 @@ open class BankingPresenter( persistAccountOffUiThread(account) response.retrievedData.forEach { retrievedData -> - retrievedAccountTransactions(GetTransactionsResponse(true, null, listOf(retrievedData)), startDate, false) + retrievedAccountTransactions(GetTransactionsResponse(null, listOf(retrievedData)), startDate, false) } findIconForBankAsync(account) @@ -353,7 +353,7 @@ open class BankingPresenter( asyncRunner.runAsync { // don't block retrieving next chunk by blocked saving to db / json updateAccountTransactions(bankAccount, accountTransactionsChunk) - callRetrievedAccountTransactionsResponseListener(GetTransactionsResponse(true, null, listOf(RetrievedAccountData(bankAccount, true, null, accountTransactionsChunk, listOf())))) + callRetrievedAccountTransactionsResponseListener(GetTransactionsResponse(null, listOf(RetrievedAccountData(bankAccount, true, null, accountTransactionsChunk, listOf())))) } } } diff --git a/ui/fints4kBankingClient/src/commonMain/kotlin/net/dankito/banking/fints4kBankingClient.kt b/ui/fints4kBankingClient/src/commonMain/kotlin/net/dankito/banking/fints4kBankingClient.kt index 88064b97..b8641454 100644 --- a/ui/fints4kBankingClient/src/commonMain/kotlin/net/dankito/banking/fints4kBankingClient.kt +++ b/ui/fints4kBankingClient/src/commonMain/kotlin/net/dankito/banking/fints4kBankingClient.kt @@ -78,7 +78,7 @@ open class fints4kBankingClient( override fun getTransactionsAsync(bankAccount: TypedBankAccount, parameter: GetTransactionsParameter, callback: (GetTransactionsResponse) -> Unit) { findAccountForBankAccount(bankAccount) { account, errorMessage -> if (account == null) { - callback(GetTransactionsResponse(false, errorMessage)) + callback(GetTransactionsResponse(errorMessage)) } else { val mappedParameter = GetTransactionsParameter(parameter.alsoRetrieveBalance, parameter.fromDate, 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 73256a05..00acb551 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 @@ -31,13 +31,13 @@ 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), + return AddAccountResponse(mapErrorToShowToUser(response), customer, map(customer, response.retrievedData), response.userCancelledAction) } open fun mapResponse(bankAccount: TypedBankAccount, response: net.dankito.banking.fints.response.client.GetTransactionsResponse): GetTransactionsResponse { - return GetTransactionsResponse(response.isSuccessful, mapErrorToShowToUser(response), + return GetTransactionsResponse(mapErrorToShowToUser(response), map(bankAccount.customer as TypedCustomer, response.retrievedData), response.userCancelledAction, response.tanRequiredButWeWereToldToAbortIfSo) } 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 8238807f..90f9390d 100644 --- a/ui/hbci4jBankingClient/src/main/kotlin/net/dankito/banking/hbci4jBankingClient.kt +++ b/ui/hbci4jBankingClient/src/main/kotlin/net/dankito/banking/hbci4jBankingClient.kt @@ -76,7 +76,7 @@ open class hbci4jBankingClient( val accounts = passport.accounts if (accounts == null || accounts.size == 0) { log.error("Keine Konten ermittelbar") - return AddAccountResponse(false, "Keine Konten ermittelbar", customer) // TODO: translate + return AddAccountResponse("Keine Konten ermittelbar", customer) // TODO: translate } this.customer.accounts = mapper.mapBankAccounts(customer, accounts, passport) @@ -85,7 +85,7 @@ open class hbci4jBankingClient( } } - return AddAccountResponse(false, connection.error.getInnerExceptionMessage(), customer) + return AddAccountResponse(connection.error.getInnerExceptionMessage(), customer) } protected open fun tryToRetrieveAccountTransactionsForAddedAccounts(customer: TypedCustomer): AddAccountResponse { @@ -106,7 +106,7 @@ open class hbci4jBankingClient( } } - return AddAccountResponse(true, null, customer, retrievedData, userCancelledAction) + return AddAccountResponse(null, customer, retrievedData, userCancelledAction) } @@ -153,7 +153,7 @@ open class hbci4jBankingClient( // Pruefen, ob die Kommunikation mit der Bank grundsaetzlich geklappt hat if (!status.isOK) { log.error("Could not connect to bank ${credentials.bankCode} $status: ${status.errorString}") - return GetTransactionsResponse(false, "Could not connect to bank ${credentials.bankCode}: $status", retrievingDataFailed) + return GetTransactionsResponse("Could not connect to bank ${credentials.bankCode}: $status", retrievingDataFailed) } // Auswertung des Saldo-Abrufs. @@ -162,7 +162,7 @@ open class hbci4jBankingClient( val balanceResult = nullableBalanceJob.jobResult as GVRSaldoReq if(balanceResult.isOK == false) { log.error("Could not fetch balance of bank account $bankAccount: $balanceResult", balanceResult.getJobStatus().exceptions) - return GetTransactionsResponse(false, "Could not fetch balance of bank account $bankAccount: $balanceResult", retrievingDataFailed) + return GetTransactionsResponse("Could not fetch balance of bank account $bankAccount: $balanceResult", retrievingDataFailed) } balance = balanceResult.entries[0].ready.value.bigDecimalValue.toBigDecimal() @@ -176,15 +176,15 @@ open class hbci4jBankingClient( // Pruefen, ob der Abruf der Umsaetze geklappt hat if (result.isOK == false) { log.error("Could not get fetch account transactions of bank account $bankAccount: $result", result.getJobStatus().exceptions) - return GetTransactionsResponse(false, "Could not fetch account transactions of bank account $bankAccount: $result", retrievingDataFailed) + return GetTransactionsResponse("Could not fetch account transactions of bank account $bankAccount: $result", retrievingDataFailed) } - return GetTransactionsResponse(true, null, listOf(RetrievedAccountData(bankAccount, true, balance.toBigDecimal(), + return GetTransactionsResponse(null, listOf(RetrievedAccountData(bankAccount, true, balance.toBigDecimal(), accountTransactionMapper.mapAccountTransactions(bankAccount, result), listOf()))) } catch(e: Exception) { log.error("Could not get accounting details for bank ${credentials.bankCode}", e) - return GetTransactionsResponse(false, e.getInnerExceptionMessage(), retrievingDataFailed) + return GetTransactionsResponse(e.getInnerExceptionMessage(), retrievingDataFailed) } finally { closeConnection(connection) @@ -193,7 +193,7 @@ open class hbci4jBankingClient( closeConnection(connection) - return GetTransactionsResponse(false, connection.error.getInnerExceptionMessage(), retrievingDataFailed) + return GetTransactionsResponse(connection.error.getInnerExceptionMessage(), retrievingDataFailed) } protected open fun executeJobsForGetAccountingEntries(handle: HBCIHandler, bankAccount: TypedBankAccount, parameter: GetTransactionsParameter): Triple {