From fb33a7c58a964473d25eeb7fddd8520ec86ca047 Mon Sep 17 00:00:00 2001 From: dankito Date: Sun, 31 Oct 2021 02:03:08 +0200 Subject: [PATCH] Implemented using updated account information after retrieving new bank data --- .../net/dankito/banking/fints/FinTsJobExecutor.kt | 10 +++++++++- .../banking/fints/model/GetTransactionsParameter.kt | 5 ++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/FinTsJobExecutor.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/FinTsJobExecutor.kt index 8d3d6900..d4d72c2d 100644 --- a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/FinTsJobExecutor.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/FinTsJobExecutor.kt @@ -194,6 +194,9 @@ open class FinTsJobExecutor( callback(GetTransactionsResponse(initDialogResponse, RetrievedAccountData.unsuccessfulList(parameter.account))) } else { + // we now retrieved the fresh account information from FinTS server, use that one + parameter.account = getUpdatedAccount(bank, parameter.account) + mayGetBalance(parameter, dialogContext) { balanceResponse -> if (dialogContext.didBankCloseDialog) { 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, balanceResponse: BankResponse?, callback: (GetTransactionsResponse) -> Unit) { var balance: Money? = balanceResponse?.getFirstSegmentById(InstituteSegmentId.Balance)?.let { @@ -352,7 +359,8 @@ open class FinTsJobExecutor( open fun doBankTransferAsync(bankTransferData: BankTransferData, bank: BankData, account: AccountData, callback: (FinTsClientResponse) -> Unit) { sendMessageAndHandleResponse(bank, null, true, { dialogContext -> - messageBuilder.createBankTransferMessage(bankTransferData, account, dialogContext) + val updatedAccount = getUpdatedAccount(bank, account) + messageBuilder.createBankTransferMessage(bankTransferData, updatedAccount, dialogContext) }) { response -> callback(FinTsClientResponse(response)) } diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/GetTransactionsParameter.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/GetTransactionsParameter.kt index 3567c568..3e97d72d 100644 --- a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/GetTransactionsParameter.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/GetTransactionsParameter.kt @@ -5,7 +5,7 @@ import kotlin.jvm.JvmOverloads open class GetTransactionsParameter @JvmOverloads constructor( - open val account: AccountData, + account: AccountData, open val alsoRetrieveBalance: Boolean = true, open val fromDate: Date? = null, open val toDate: Date? = null, @@ -20,6 +20,9 @@ open class GetTransactionsParameter @JvmOverloads constructor( open val retrievedChunkListener: ((Collection) -> Unit)? = null ) { + open var account: AccountData = account + internal set + internal open var isSettingMaxCountEntriesAllowedByBank = false internal open val maxCountEntriesIfSettingItIsAllowed: Int?