Converted lastTransactionsRetrievalTime to Instant

This commit is contained in:
dankito 2024-09-03 21:24:33 +02:00
parent b2fb04372f
commit 9600e2f11b
4 changed files with 12 additions and 10 deletions

View File

@ -1,8 +1,8 @@
package net.codinux.banking.fints package net.codinux.banking.fints
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.datetime.Clock
import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalDate
import kotlinx.datetime.LocalDateTime
import net.codinux.log.logger import net.codinux.log.logger
import net.codinux.banking.fints.messages.MessageBuilder import net.codinux.banking.fints.messages.MessageBuilder
import net.codinux.banking.fints.messages.MessageBuilderResult 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.tan.TanImageDecoder
import net.codinux.banking.fints.util.TanMethodSelector import net.codinux.banking.fints.util.TanMethodSelector
import net.codinux.banking.fints.extensions.minusDays 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.todayAtEuropeBerlin
import net.codinux.banking.fints.extensions.todayAtSystemDefaultTimeZone import net.codinux.banking.fints.extensions.todayAtSystemDefaultTimeZone
import kotlin.math.max 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) val response = getAndHandleResponseForMessage(context, message)

View File

@ -1,7 +1,10 @@
package net.codinux.banking.fints.mapper package net.codinux.banking.fints.mapper
import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalDate
import kotlinx.datetime.TimeZone
import kotlinx.datetime.atTime 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.*
import net.dankito.banking.client.model.AccountTransaction import net.dankito.banking.client.model.AccountTransaction
import net.dankito.banking.client.model.parameter.FinTsClientParameter import net.dankito.banking.client.model.parameter.FinTsClientParameter
@ -86,7 +89,8 @@ open class FinTsModelMapper {
bankAccount.retrievedTransactionsFrom = accountTransactionsResponse.retrievedTransactionsFrom 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 if (bankAccount.lastTransactionsRetrievalTime == null || bankAccount.lastTransactionsRetrievalTime!! <= retrievalTime) { // if retrieveTransactionsTo is set it may is older than current account's lastTransactionsRetrievalTime
bankAccount.lastTransactionsRetrievalTime = retrievalTime bankAccount.lastTransactionsRetrievalTime = retrievalTime
} }

View File

@ -1,8 +1,7 @@
package net.codinux.banking.fints.model package net.codinux.banking.fints.model
import kotlinx.datetime.Instant
import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalDate
import kotlinx.datetime.LocalDateTime
import net.codinux.banking.fints.extensions.nowAtEuropeBerlin
open class RetrievedAccountData( open class RetrievedAccountData(
@ -11,7 +10,7 @@ open class RetrievedAccountData(
open val balance: Money?, open val balance: Money?,
open var bookedTransactions: Collection<AccountTransaction>, open var bookedTransactions: Collection<AccountTransaction>,
open var unbookedTransactions: Collection<Any>, open var unbookedTransactions: Collection<Any>,
open val retrievalTime: LocalDateTime, open val retrievalTime: Instant,
open val retrievedTransactionsFrom: LocalDate?, open val retrievedTransactionsFrom: LocalDate?,
open val retrievedTransactionsTo: LocalDate?, open val retrievedTransactionsTo: LocalDate?,
open val errorMessage: String? = null open val errorMessage: String? = null
@ -20,7 +19,7 @@ open class RetrievedAccountData(
companion object { companion object {
fun unsuccessful(account: AccountData): RetrievedAccountData { 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)
} }
} }

View File

@ -1,7 +1,7 @@
package net.dankito.banking.client.model package net.dankito.banking.client.model
import kotlinx.datetime.Instant
import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalDate
import kotlinx.datetime.LocalDateTime
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import net.codinux.banking.fints.model.Currency import net.codinux.banking.fints.model.Currency
import net.codinux.banking.fints.model.Money import net.codinux.banking.fints.model.Money
@ -36,7 +36,7 @@ open class BankAccount(
open var retrievedTransactionsFrom: LocalDate? = null open var retrievedTransactionsFrom: LocalDate? = null
open var lastTransactionsRetrievalTime: LocalDateTime? = null open var lastTransactionsRetrievalTime: Instant? = null
open var bookedTransactions: List<AccountTransaction> = listOf() open var bookedTransactions: List<AccountTransaction> = listOf()