Calculating supportsRetrievingTransactionsOfLast90DaysWithoutTan now from retrieved data (but try to get rid of it anyway)
This commit is contained in:
parent
99205b53c9
commit
044648f569
|
@ -285,7 +285,6 @@ open class FinTsClient(
|
|||
callback: (AddAccountResponse) -> Unit) {
|
||||
// TODO: or add a default RetrievedAccountData instance for each account?
|
||||
val retrievedAccountData = mutableListOf<RetrievedAccountData>()
|
||||
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<RetrievedAccountData>, successfullyReceivedAccountTransactionsResponse: Boolean,
|
||||
retrievedAccountData: List<RetrievedAccountData>,
|
||||
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))
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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<RetrievedAccountData> = listOf()
|
||||
) : GetTransactionsResponse(response, retrievedData)
|
|
@ -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"]
|
||||
|
||||
|
|
|
@ -8,11 +8,14 @@ open class AddAccountResponse(
|
|||
isSuccessful: Boolean,
|
||||
errorToShowToUser: String?,
|
||||
open val customer: TypedCustomer,
|
||||
open val supportsRetrievingTransactionsOfLast90DaysWithoutTan: Boolean = false,
|
||||
open val retrievedData: List<RetrievedAccountData> = 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()
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue