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) {
|
callback: (AddAccountResponse) -> Unit) {
|
||||||
// TODO: or add a default RetrievedAccountData instance for each account?
|
// TODO: or add a default RetrievedAccountData instance for each account?
|
||||||
val retrievedAccountData = mutableListOf<RetrievedAccountData>()
|
val retrievedAccountData = mutableListOf<RetrievedAccountData>()
|
||||||
var successfullyReceivedAccountTransactionsResponse = false
|
|
||||||
|
|
||||||
val accountSupportingRetrievingTransactions = bank.accounts.filter { it.supportsFeature(AccountFeature.RetrieveBalance) || it.supportsFeature(AccountFeature.RetrieveAccountTransactions) }
|
val accountSupportingRetrievingTransactions = bank.accounts.filter { it.supportsFeature(AccountFeature.RetrieveBalance) || it.supportsFeature(AccountFeature.RetrieveAccountTransactions) }
|
||||||
val countAccountSupportingRetrievingTransactions = accountSupportingRetrievingTransactions.size
|
val countAccountSupportingRetrievingTransactions = accountSupportingRetrievingTransactions.size
|
||||||
|
@ -293,21 +292,17 @@ open class FinTsClient(
|
||||||
|
|
||||||
if (countAccountSupportingRetrievingTransactions == 0) {
|
if (countAccountSupportingRetrievingTransactions == 0) {
|
||||||
addAccountAfterRetrievingTransactions(bank, newUserInfoResponse, didOverwriteUserUnselectedTanProcedure,
|
addAccountAfterRetrievingTransactions(bank, newUserInfoResponse, didOverwriteUserUnselectedTanProcedure,
|
||||||
originalAreWeThatGentleToCloseDialogs, retrievedAccountData, successfullyReceivedAccountTransactionsResponse, callback)
|
originalAreWeThatGentleToCloseDialogs, retrievedAccountData, callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
accountSupportingRetrievingTransactions.forEach { account ->
|
accountSupportingRetrievingTransactions.forEach { account ->
|
||||||
tryGetTransactionsOfLast90DaysWithoutTan(bank, account) { response ->
|
tryGetTransactionsOfLast90DaysWithoutTan(bank, account) { response ->
|
||||||
retrievedAccountData.addAll(response.retrievedData)
|
retrievedAccountData.addAll(response.retrievedData)
|
||||||
|
|
||||||
if (response.isSuccessful) {
|
|
||||||
successfullyReceivedAccountTransactionsResponse = true
|
|
||||||
}
|
|
||||||
|
|
||||||
countRetrievedAccounts++
|
countRetrievedAccounts++
|
||||||
if (countRetrievedAccounts == countAccountSupportingRetrievingTransactions) {
|
if (countRetrievedAccounts == countAccountSupportingRetrievingTransactions) {
|
||||||
addAccountAfterRetrievingTransactions(bank, newUserInfoResponse, didOverwriteUserUnselectedTanProcedure, originalAreWeThatGentleToCloseDialogs,
|
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,
|
protected open fun addAccountAfterRetrievingTransactions(bank: BankData, newUserInfoResponse: AddAccountResponse,
|
||||||
didOverwriteUserUnselectedTanProcedure: Boolean, originalAreWeThatGentleToCloseDialogs: Boolean,
|
didOverwriteUserUnselectedTanProcedure: Boolean, originalAreWeThatGentleToCloseDialogs: Boolean,
|
||||||
retrievedAccountData: List<RetrievedAccountData>, successfullyReceivedAccountTransactionsResponse: Boolean,
|
retrievedAccountData: List<RetrievedAccountData>,
|
||||||
callback: (AddAccountResponse) -> Unit) {
|
callback: (AddAccountResponse) -> Unit) {
|
||||||
if (didOverwriteUserUnselectedTanProcedure) {
|
if (didOverwriteUserUnselectedTanProcedure) {
|
||||||
bank.resetSelectedTanProcedure()
|
bank.resetSelectedTanProcedure()
|
||||||
|
@ -324,7 +319,7 @@ open class FinTsClient(
|
||||||
areWeThatGentleToCloseDialogs = originalAreWeThatGentleToCloseDialogs
|
areWeThatGentleToCloseDialogs = originalAreWeThatGentleToCloseDialogs
|
||||||
|
|
||||||
// TODO: to evaluate if adding account has been successful also check if count accounts > 0
|
// 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(
|
open class AddAccountResponse(
|
||||||
response: Response,
|
response: Response,
|
||||||
open val bank: BankData,
|
open val bank: BankData,
|
||||||
open val supportsRetrievingTransactionsOfLast90DaysWithoutTan: Boolean = false,
|
|
||||||
retrievedData: List<RetrievedAccountData> = listOf()
|
retrievedData: List<RetrievedAccountData> = listOf()
|
||||||
) : GetTransactionsResponse(response, retrievedData)
|
) : GetTransactionsResponse(response, retrievedData)
|
|
@ -266,6 +266,7 @@ open class AddAccountDialog(protected val presenter: BankingPresenter) : Window(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleSuccessfullyAddedAccountResultOnUiThread(response: AddAccountResponse) {
|
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"]
|
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"]
|
else messages["add.account.dialog.successfully.added.account"]
|
||||||
|
|
||||||
|
|
|
@ -8,11 +8,14 @@ open class AddAccountResponse(
|
||||||
isSuccessful: Boolean,
|
isSuccessful: Boolean,
|
||||||
errorToShowToUser: String?,
|
errorToShowToUser: String?,
|
||||||
open val customer: TypedCustomer,
|
open val customer: TypedCustomer,
|
||||||
open val supportsRetrievingTransactionsOfLast90DaysWithoutTan: Boolean = false,
|
|
||||||
open val retrievedData: List<RetrievedAccountData> = listOf(),
|
open val retrievedData: List<RetrievedAccountData> = listOf(),
|
||||||
userCancelledAction: Boolean = false
|
userCancelledAction: Boolean = false
|
||||||
) : BankingClientResponse(isSuccessful, errorToShowToUser, userCancelledAction) {
|
) : BankingClientResponse(isSuccessful, errorToShowToUser, userCancelledAction) {
|
||||||
|
|
||||||
|
open val supportsRetrievingTransactionsOfLast90DaysWithoutTan: Boolean
|
||||||
|
get() = retrievedData.isNotEmpty() && retrievedData.any { it.successfullyRetrievedData }
|
||||||
|
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
return customer.toString() + " " + super.toString()
|
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 {
|
open fun mapResponse(customer: TypedCustomer, response: net.dankito.banking.fints.response.client.AddAccountResponse): AddAccountResponse {
|
||||||
|
|
||||||
return AddAccountResponse(response.isSuccessful, mapErrorToShowToUser(response),
|
return AddAccountResponse(response.isSuccessful, mapErrorToShowToUser(response),
|
||||||
customer, response.supportsRetrievingTransactionsOfLast90DaysWithoutTan,
|
customer, map(customer, response.retrievedData), response.userCancelledAction)
|
||||||
map(customer, response.retrievedData),
|
|
||||||
response.userCancelledAction)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun mapResponse(bankAccount: TypedBankAccount, response: net.dankito.banking.fints.response.client.GetTransactionsResponse): GetTransactionsResponse {
|
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 {
|
protected open fun tryToRetrieveAccountTransactionsForAddedAccounts(customer: TypedCustomer): AddAccountResponse {
|
||||||
var supportsRetrievingTransactionsOfLast90DaysWithoutTan = false
|
|
||||||
var userCancelledAction = false
|
var userCancelledAction = false
|
||||||
|
|
||||||
val retrievedData = customer.accounts.map { account ->
|
val retrievedData = customer.accounts.map { account ->
|
||||||
if (account.supportsRetrievingAccountTransactions) {
|
if (account.supportsRetrievingAccountTransactions) {
|
||||||
val response = getTransactionsOfLast90Days(account)
|
val response = getTransactionsOfLast90Days(account)
|
||||||
if (response.isSuccessful) {
|
|
||||||
supportsRetrievingTransactionsOfLast90DaysWithoutTan = true
|
|
||||||
}
|
|
||||||
if (response.userCancelledAction) {
|
if (response.userCancelledAction) {
|
||||||
userCancelledAction = true
|
userCancelledAction = true
|
||||||
}
|
}
|
||||||
|
@ -109,8 +106,7 @@ open class hbci4jBankingClient(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return AddAccountResponse(true, null, customer, supportsRetrievingTransactionsOfLast90DaysWithoutTan,
|
return AddAccountResponse(true, null, customer, retrievedData, userCancelledAction)
|
||||||
retrievedData, userCancelledAction)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue