Implemented using updated account information after retrieving new bank data

This commit is contained in:
dankito 2021-10-31 02:03:08 +02:00
parent e8e35a3fe2
commit fb33a7c58a
2 changed files with 13 additions and 2 deletions

View File

@ -194,6 +194,9 @@ open class FinTsJobExecutor(
callback(GetTransactionsResponse(initDialogResponse, RetrievedAccountData.unsuccessfulList(parameter.account))) callback(GetTransactionsResponse(initDialogResponse, RetrievedAccountData.unsuccessfulList(parameter.account)))
} }
else { else {
// we now retrieved the fresh account information from FinTS server, use that one
parameter.account = getUpdatedAccount(bank, parameter.account)
mayGetBalance(parameter, dialogContext) { balanceResponse -> mayGetBalance(parameter, dialogContext) { balanceResponse ->
if (dialogContext.didBankCloseDialog) { if (dialogContext.didBankCloseDialog) {
callback(GetTransactionsResponse(balanceResponse ?: initDialogResponse, RetrievedAccountData.unsuccessfulList(parameter.account))) callback(GetTransactionsResponse(balanceResponse ?: initDialogResponse, RetrievedAccountData.unsuccessfulList(parameter.account)))
@ -206,6 +209,10 @@ open class FinTsJobExecutor(
} }
} }
private fun getUpdatedAccount(bank: BankData, account: AccountData): AccountData {
return bank.accounts.firstOrNull { it.accountIdentifier == account.accountIdentifier } ?: account
}
protected open fun getTransactionsAfterInitAndGetBalance(parameter: GetTransactionsParameter, dialogContext: DialogContext, protected open fun getTransactionsAfterInitAndGetBalance(parameter: GetTransactionsParameter, dialogContext: DialogContext,
balanceResponse: BankResponse?, callback: (GetTransactionsResponse) -> Unit) { balanceResponse: BankResponse?, callback: (GetTransactionsResponse) -> Unit) {
var balance: Money? = balanceResponse?.getFirstSegmentById<BalanceSegment>(InstituteSegmentId.Balance)?.let { var balance: Money? = balanceResponse?.getFirstSegmentById<BalanceSegment>(InstituteSegmentId.Balance)?.let {
@ -352,7 +359,8 @@ open class FinTsJobExecutor(
open fun doBankTransferAsync(bankTransferData: BankTransferData, bank: BankData, account: AccountData, callback: (FinTsClientResponse) -> Unit) { open fun doBankTransferAsync(bankTransferData: BankTransferData, bank: BankData, account: AccountData, callback: (FinTsClientResponse) -> Unit) {
sendMessageAndHandleResponse(bank, null, true, { dialogContext -> sendMessageAndHandleResponse(bank, null, true, { dialogContext ->
messageBuilder.createBankTransferMessage(bankTransferData, account, dialogContext) val updatedAccount = getUpdatedAccount(bank, account)
messageBuilder.createBankTransferMessage(bankTransferData, updatedAccount, dialogContext)
}) { response -> }) { response ->
callback(FinTsClientResponse(response)) callback(FinTsClientResponse(response))
} }

View File

@ -5,7 +5,7 @@ import kotlin.jvm.JvmOverloads
open class GetTransactionsParameter @JvmOverloads constructor( open class GetTransactionsParameter @JvmOverloads constructor(
open val account: AccountData, account: AccountData,
open val alsoRetrieveBalance: Boolean = true, open val alsoRetrieveBalance: Boolean = true,
open val fromDate: Date? = null, open val fromDate: Date? = null,
open val toDate: Date? = null, open val toDate: Date? = null,
@ -20,6 +20,9 @@ open class GetTransactionsParameter @JvmOverloads constructor(
open val retrievedChunkListener: ((Collection<AccountTransaction>) -> Unit)? = null open val retrievedChunkListener: ((Collection<AccountTransaction>) -> Unit)? = null
) { ) {
open var account: AccountData = account
internal set
internal open var isSettingMaxCountEntriesAllowedByBank = false internal open var isSettingMaxCountEntriesAllowedByBank = false
internal open val maxCountEntriesIfSettingItIsAllowed: Int? internal open val maxCountEntriesIfSettingItIsAllowed: Int?