From 9600e2f11b194694f0a894a058f6affe4d5cab2e Mon Sep 17 00:00:00 2001 From: dankito Date: Tue, 3 Sep 2024 21:24:33 +0200 Subject: [PATCH] Converted lastTransactionsRetrievalTime to Instant --- .../kotlin/net/codinux/banking/fints/FinTsJobExecutor.kt | 5 ++--- .../net/codinux/banking/fints/mapper/FinTsModelMapper.kt | 6 +++++- .../codinux/banking/fints/model/RetrievedAccountData.kt | 7 +++---- .../kotlin/net/dankito/banking/client/model/BankAccount.kt | 4 ++-- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/FinTsJobExecutor.kt b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/FinTsJobExecutor.kt index 87a8cac6..6ef0a7fe 100644 --- a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/FinTsJobExecutor.kt +++ b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/FinTsJobExecutor.kt @@ -1,8 +1,8 @@ package net.codinux.banking.fints import kotlinx.coroutines.delay +import kotlinx.datetime.Clock import kotlinx.datetime.LocalDate -import kotlinx.datetime.LocalDateTime import net.codinux.log.logger import net.codinux.banking.fints.messages.MessageBuilder import net.codinux.banking.fints.messages.MessageBuilderResult @@ -20,7 +20,6 @@ import net.codinux.banking.fints.tan.FlickerCodeDecoder import net.codinux.banking.fints.tan.TanImageDecoder import net.codinux.banking.fints.util.TanMethodSelector import net.codinux.banking.fints.extensions.minusDays -import net.codinux.banking.fints.extensions.nowAtEuropeBerlin import net.codinux.banking.fints.extensions.todayAtEuropeBerlin import net.codinux.banking.fints.extensions.todayAtSystemDefaultTimeZone import kotlin.math.max @@ -232,7 +231,7 @@ open class FinTsJobExecutor( } } - val startTime = LocalDateTime.nowAtEuropeBerlin() + val startTime = Clock.System.now() val response = getAndHandleResponseForMessage(context, message) diff --git a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/mapper/FinTsModelMapper.kt b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/mapper/FinTsModelMapper.kt index 0f50a58c..897c66e6 100644 --- a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/mapper/FinTsModelMapper.kt +++ b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/mapper/FinTsModelMapper.kt @@ -1,7 +1,10 @@ package net.codinux.banking.fints.mapper import kotlinx.datetime.LocalDate +import kotlinx.datetime.TimeZone import kotlinx.datetime.atTime +import kotlinx.datetime.toInstant +import net.codinux.banking.fints.extensions.EuropeBerlin import net.dankito.banking.client.model.* import net.dankito.banking.client.model.AccountTransaction import net.dankito.banking.client.model.parameter.FinTsClientParameter @@ -86,7 +89,8 @@ open class FinTsModelMapper { bankAccount.retrievedTransactionsFrom = accountTransactionsResponse.retrievedTransactionsFrom } - val retrievalTime = if (retrieveTransactionsTo == null) accountTransactionsResponse.retrievalTime else retrieveTransactionsTo.atTime(0, 0) + val retrievalTime = if (retrieveTransactionsTo == null) accountTransactionsResponse.retrievalTime + else retrieveTransactionsTo.atTime(0, 0).toInstant(TimeZone.EuropeBerlin) if (bankAccount.lastTransactionsRetrievalTime == null || bankAccount.lastTransactionsRetrievalTime!! <= retrievalTime) { // if retrieveTransactionsTo is set it may is older than current account's lastTransactionsRetrievalTime bankAccount.lastTransactionsRetrievalTime = retrievalTime } diff --git a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/model/RetrievedAccountData.kt b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/model/RetrievedAccountData.kt index 3e41191f..a7a0ba83 100644 --- a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/model/RetrievedAccountData.kt +++ b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/model/RetrievedAccountData.kt @@ -1,8 +1,7 @@ package net.codinux.banking.fints.model +import kotlinx.datetime.Instant import kotlinx.datetime.LocalDate -import kotlinx.datetime.LocalDateTime -import net.codinux.banking.fints.extensions.nowAtEuropeBerlin open class RetrievedAccountData( @@ -11,7 +10,7 @@ open class RetrievedAccountData( open val balance: Money?, open var bookedTransactions: Collection, open var unbookedTransactions: Collection, - open val retrievalTime: LocalDateTime, + open val retrievalTime: Instant, open val retrievedTransactionsFrom: LocalDate?, open val retrievedTransactionsTo: LocalDate?, open val errorMessage: String? = null @@ -20,7 +19,7 @@ open class RetrievedAccountData( companion object { fun unsuccessful(account: AccountData): RetrievedAccountData { - return RetrievedAccountData(account, false, null, listOf(), listOf(), LocalDateTime.nowAtEuropeBerlin(), null, null) + return RetrievedAccountData(account, false, null, listOf(), listOf(), Instant.DISTANT_PAST, null, null) } } diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/client/model/BankAccount.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/client/model/BankAccount.kt index ddf960b1..d2618344 100644 --- a/fints4k/src/commonMain/kotlin/net/dankito/banking/client/model/BankAccount.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/client/model/BankAccount.kt @@ -1,7 +1,7 @@ package net.dankito.banking.client.model +import kotlinx.datetime.Instant import kotlinx.datetime.LocalDate -import kotlinx.datetime.LocalDateTime import kotlinx.serialization.Serializable import net.codinux.banking.fints.model.Currency import net.codinux.banking.fints.model.Money @@ -36,7 +36,7 @@ open class BankAccount( open var retrievedTransactionsFrom: LocalDate? = null - open var lastTransactionsRetrievalTime: LocalDateTime? = null + open var lastTransactionsRetrievalTime: Instant? = null open var bookedTransactions: List = listOf()