From 54940742f7924e0155cc8544266b37e3264d2902 Mon Sep 17 00:00:00 2001 From: dankito Date: Wed, 11 Sep 2024 23:21:06 +0200 Subject: [PATCH] Renamed lastTransactionsRetrievalTime to lastAccountUpdateTime --- .../net/codinux/banking/client/BankingClient.kt | 4 ++-- .../codinux/banking/client/BankingClientForUser.kt | 4 ++-- .../codinux/banking/client/model/BankAccount.kt | 2 +- .../banking/client/fints4k/FinTs4kMapper.kt | 14 +++++++------- README.md | 6 +++--- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/BankingClient/src/commonMain/kotlin/net/codinux/banking/client/BankingClient.kt b/BankingClient/src/commonMain/kotlin/net/codinux/banking/client/BankingClient.kt index e81c07aa..8979983f 100644 --- a/BankingClient/src/commonMain/kotlin/net/codinux/banking/client/BankingClient.kt +++ b/BankingClient/src/commonMain/kotlin/net/codinux/banking/client/BankingClient.kt @@ -36,8 +36,8 @@ interface BankingClient { /** * Convenience wrapper around [getAccountDataAsync]. - * Updates account's transactions beginning from [BankAccount.lastTransactionsRetrievalTime]. - * This may requires TAN if [BankAccount.lastTransactionsRetrievalTime] is older than 90 days. + * Updates account's transactions beginning from [BankAccount.lastAccountUpdateTime]. + * This may requires TAN if [BankAccount.lastAccountUpdateTime] is older than 90 days. * * Optionally specify which [accounts] should be updated. If not specified all accounts will be updated. */ diff --git a/BankingClient/src/commonMain/kotlin/net/codinux/banking/client/BankingClientForUser.kt b/BankingClient/src/commonMain/kotlin/net/codinux/banking/client/BankingClientForUser.kt index 16648a39..84195fdd 100644 --- a/BankingClient/src/commonMain/kotlin/net/codinux/banking/client/BankingClientForUser.kt +++ b/BankingClient/src/commonMain/kotlin/net/codinux/banking/client/BankingClientForUser.kt @@ -37,8 +37,8 @@ interface BankingClientForUser { /** * Convenience wrapper around [getAccountDataAsync]. - * Updates account's transactions beginning from [BankAccount.lastTransactionsRetrievalTime]. - * This may requires TAN if [BankAccount.lastTransactionsRetrievalTime] is older than 90 days. + * Updates account's transactions beginning from [BankAccount.lastAccountUpdateTime]. + * This may requires TAN if [BankAccount.lastAccountUpdateTime] is older than 90 days. */ suspend fun updateAccountTransactionsAsync(accounts: List? = null): Response> diff --git a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/BankAccount.kt b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/BankAccount.kt index 1e533150..f3ec1019 100644 --- a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/BankAccount.kt +++ b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/BankAccount.kt @@ -24,7 +24,7 @@ open class BankAccount( var balance: Amount = Amount.Zero, // TODO: add a BigDecimal library val serverTransactionsRetentionDays: Int? = null, - open var lastTransactionsRetrievalTime: Instant? = null, + open var lastAccountUpdateTime: Instant? = null, var retrievedTransactionsFrom: LocalDate? = null, open val bookedTransactions: MutableList = mutableListOf(), diff --git a/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kMapper.kt b/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kMapper.kt index 381a21ed..5229f1cc 100644 --- a/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kMapper.kt +++ b/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kMapper.kt @@ -63,7 +63,7 @@ open class FinTs4kMapper { val defaults = GetAccountDataOptions() val accountIdentifier = BankAccountIdentifierImpl(account.identifier, account.subAccountNumber, account.iban) - val from = account.lastTransactionsRetrievalTime?.toLocalDateTime(TimeZone.EuropeBerlin)?.date // TODO: in case lastTransactionsUpdateTime is not set, this would retrieve all transactions (and require a TAN im most cases) + val from = account.lastAccountUpdateTime?.toLocalDateTime(TimeZone.EuropeBerlin)?.date // TODO: in case lastTransactionsUpdateTime is not set, this would retrieve all transactions (and require a TAN im most cases) val retrieveTransactions = if (from != null) RetrieveTransactions.AccordingToRetrieveFromAndTo else RetrieveTransactions.valueOf(defaults.retrieveTransactions.name) // val preferredTanMethods = listOf(mapTanMethodType(user.selectedTanMethod.type)) // TODO: currently we aren't saving TanMethods in database, re-enable as soon as TanMethods get saved val preferredTanMethods = defaults.preferredTanMethods?.map { mapTanMethodType(it) } @@ -106,8 +106,8 @@ open class FinTs4kMapper { val finTsBankAccount = user?.accounts?.firstOrNull { it.identifier == account.identifier && it.subAccountNumber == account.subAccountNumber } if (getAccountDataResponse.successful && user != null && finTsBankAccount != null) { - if (finTsBankAccount.lastTransactionsRetrievalTime != null) { - account.lastTransactionsRetrievalTime = finTsBankAccount.lastTransactionsRetrievalTime + if (finTsBankAccount.lastAccountUpdateTime != null) { + account.lastAccountUpdateTime = finTsBankAccount.lastAccountUpdateTime } if (account.retrievedTransactionsFrom == null || (finTsBankAccount.retrievedTransactionsFrom != null && account.retrievedTransactionsFrom!! < finTsBankAccount.retrievedTransactionsFrom!!)) { @@ -115,8 +115,8 @@ open class FinTs4kMapper { } Response.success(GetTransactionsResponse(account, mapMoney(finTsBankAccount.balance), mapBookedTransactions(finTsBankAccount), emptyList(), - mapHoldings(finTsBankAccount.statementOfHoldings, finTsBankAccount.currency, finTsBankAccount.lastTransactionsRetrievalTime), - finTsBankAccount.lastTransactionsRetrievalTime ?: Clock.System.now(), param.retrieveTransactionsFrom, param.retrieveTransactionsTo)) + mapHoldings(finTsBankAccount.statementOfHoldings, finTsBankAccount.currency, finTsBankAccount.lastAccountUpdateTime), + finTsBankAccount.lastAccountUpdateTime ?: Clock.System.now(), param.retrieveTransactionsFrom, param.retrieveTransactionsTo)) } else { mapError(getAccountDataResponse) } @@ -162,9 +162,9 @@ open class FinTs4kMapper { account.isAccountTypeSupportedByApplication, mapFeatures(account), mapMoney(account.balance), account.serverTransactionsRetentionDays, - account.lastTransactionsRetrievalTime, account.retrievedTransactionsFrom, + account.lastAccountUpdateTime, account.retrievedTransactionsFrom, bookedTransactions = mapBookedTransactions(account).toMutableList(), - holdings = mapHoldings(account.statementOfHoldings, account.currency, account.lastTransactionsRetrievalTime) + holdings = mapHoldings(account.statementOfHoldings, account.currency, account.lastAccountUpdateTime) ) protected open fun mapAccountType(type: net.dankito.banking.client.model.BankAccountType): BankAccountType = diff --git a/README.md b/README.md index adb4211f..03ced598 100644 --- a/README.md +++ b/README.md @@ -115,12 +115,12 @@ response.error?.let{ error -> ### Update Account Transactions -The data model saves when it retrieved account transactions the last time (in `BankAccount.lastTransactionsRetrievalTime`). +The data model saves when it retrieved account transactions the last time (in `BankAccount.lastAccountUpdateTime`). So you only need to call `FinTs4kBankingClient.updateAccountTransactions()` to retrieve all transactions starting from -`BankAccount.lastTransactionsRetrievalTime`. +`BankAccount.lastAccountUpdateTime`. But as we can only specify from which day on account transactions should be retrieved, response may contain some transactions -from the day of `lastTransactionsRetrievalTime` that we already have locally. To filter out these you can use +from the day of `lastAccountUpdateTime` that we already have locally. To filter out these you can use `BankingModelService().findNewTransactions(retrieveTransactions, existingTransactions)`: ```kotlin