From c5bddd94b0c9fb01ae90ce80b7d4207283022784 Mon Sep 17 00:00:00 2001 From: dankito Date: Sun, 20 Dec 2020 16:48:54 +0100 Subject: [PATCH] Implemented that errors when retrieving account transactions get displayed in UI --- .../kotlin/net/dankito/banking/fints/FinTsClient.kt | 2 +- .../net/dankito/banking/fints/model/RetrievedAccountData.kt | 3 ++- .../banking/fints/response/client/GetTransactionsResponse.kt | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/FinTsClient.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/FinTsClient.kt index 07135f40..5f79dbb5 100644 --- a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/FinTsClient.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/FinTsClient.kt @@ -423,7 +423,7 @@ open class FinTsClient( val fromDate = parameter.fromDate ?: parameter.account.countDaysForWhichTransactionsAreKept?.let { Date(Date.today.millisSinceEpoch - it * OneDayMillis) } ?: bookedTransactions.map { it.valueDate }.sortedBy { it.millisSinceEpoch }.firstOrNull() - val retrievedData = RetrievedAccountData(parameter.account, successful, balance, bookedTransactions, unbookedTransactions, fromDate, parameter.toDate ?: Date.today) + val retrievedData = RetrievedAccountData(parameter.account, successful, balance, bookedTransactions, unbookedTransactions, fromDate, parameter.toDate ?: Date.today, response.errorMessage) callback(GetTransactionsResponse(response, listOf(retrievedData), if (parameter.maxCountEntries != null) parameter.isSettingMaxCountEntriesAllowedByBank else null diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/RetrievedAccountData.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/RetrievedAccountData.kt index 2a39e0a1..66987cdb 100644 --- a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/RetrievedAccountData.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/RetrievedAccountData.kt @@ -10,7 +10,8 @@ open class RetrievedAccountData( open var bookedTransactions: Collection, open var unbookedTransactions: Collection, open val retrievedTransactionsFrom: Date?, - open val retrievedTransactionsTo: Date? + open val retrievedTransactionsTo: Date?, + open val errorMessage: String? = null ) { companion object { diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/client/GetTransactionsResponse.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/client/GetTransactionsResponse.kt index 377a00bd..6404fef5 100644 --- a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/client/GetTransactionsResponse.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/client/GetTransactionsResponse.kt @@ -18,4 +18,9 @@ open class GetTransactionsResponse( && retrievedData.isNotEmpty() && retrievedData.none { it.account.supportsRetrievingAccountTransactions && it.successfullyRetrievedData == false } + // TODO: remove again if then in AddAccountResponse errors get displayed that should or extract getRetrievingTransactionsError() and override in AddAccountResponse + override val errorMessage: String? + get() = super.errorMessage + ?: retrievedData.mapNotNull { it.errorMessage }.firstOrNull() + } \ No newline at end of file