Implemented calculating isSuccessful in AddAccountResponse and GetTransactionsResponse
This commit is contained in:
parent
f444a45730
commit
2d4499514a
|
@ -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))
|
||||
}
|
||||
|
||||
|
|
|
@ -8,4 +8,9 @@ open class AddAccountResponse(
|
|||
response: Response,
|
||||
open val bank: BankData,
|
||||
retrievedData: List<RetrievedAccountData> = listOf()
|
||||
) : GetTransactionsResponse(response, retrievedData)
|
||||
) : GetTransactionsResponse(response, retrievedData) {
|
||||
|
||||
override val isSuccessful: Boolean
|
||||
get() = super.isSuccessful && bank.accounts.isNotEmpty()
|
||||
|
||||
}
|
|
@ -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)
|
||||
) : FinTsClientResponse(response) {
|
||||
|
||||
override val isSuccessful: Boolean
|
||||
get() = super.isSuccessful && retrievedData.isNotEmpty() && retrievedData.none { it.successfullyRetrievedData == false }
|
||||
|
||||
}
|
|
@ -5,12 +5,14 @@ import net.dankito.utils.multiplatform.BigDecimal
|
|||
|
||||
|
||||
open class AddAccountResponse(
|
||||
isSuccessful: Boolean,
|
||||
errorToShowToUser: String?,
|
||||
open val customer: TypedCustomer,
|
||||
retrievedData: List<RetrievedAccountData> = 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 }
|
||||
|
|
|
@ -4,9 +4,13 @@ import net.dankito.banking.ui.model.RetrievedAccountData
|
|||
|
||||
|
||||
open class GetTransactionsResponse(
|
||||
isSuccessful: Boolean,
|
||||
errorToShowToUser: String?,
|
||||
open val retrievedData: List<RetrievedAccountData> = 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 }
|
||||
|
||||
}
|
||||
|
|
|
@ -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()))))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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<HBCIJob?, HBCIJob, HBCIExecStatus> {
|
||||
|
|
Loading…
Reference in New Issue