Renamed haveAllTransactionsBeenRetrieved to haveAllRetainedTransactionsBeenRetrieved and made it evaluating countDaysForWhichTransactionsAreKeptOnBankServer and retrievedTransactionsFrom instead of being set to a fixed value
This commit is contained in:
parent
bd052587c5
commit
1e5c83c369
|
@ -1,7 +1,6 @@
|
||||||
package net.codinux.banking.client.model
|
package net.codinux.banking.client.model
|
||||||
|
|
||||||
import kotlinx.datetime.Instant
|
import kotlinx.datetime.*
|
||||||
import kotlinx.datetime.LocalDate
|
|
||||||
import net.codinux.banking.client.model.config.JsonIgnore
|
import net.codinux.banking.client.model.config.JsonIgnore
|
||||||
import net.codinux.banking.client.model.config.NoArgConstructor
|
import net.codinux.banking.client.model.config.NoArgConstructor
|
||||||
|
|
||||||
|
@ -22,12 +21,10 @@ open class BankAccount(
|
||||||
val isAccountTypeSupportedByApplication: Boolean = false,
|
val isAccountTypeSupportedByApplication: Boolean = false,
|
||||||
val features: Set<BankAccountFeatures> = emptySet(),
|
val features: Set<BankAccountFeatures> = emptySet(),
|
||||||
|
|
||||||
|
val countDaysForWhichTransactionsAreKeptOnBankServer: Int? = null,
|
||||||
open var lastTransactionsRetrievalTime: Instant? = null,
|
open var lastTransactionsRetrievalTime: Instant? = null,
|
||||||
var retrievedTransactionsFrom: LocalDate? = null,
|
var retrievedTransactionsFrom: LocalDate? = null,
|
||||||
|
|
||||||
var haveAllTransactionsBeenRetrieved: Boolean = false,
|
|
||||||
val countDaysForWhichTransactionsAreKept: Int? = null,
|
|
||||||
|
|
||||||
open val bookedTransactions: MutableList<AccountTransaction> = mutableListOf(),
|
open val bookedTransactions: MutableList<AccountTransaction> = mutableListOf(),
|
||||||
open val unbookedTransactions: MutableList<UnbookedAccountTransaction> = mutableListOf(),
|
open val unbookedTransactions: MutableList<UnbookedAccountTransaction> = mutableListOf(),
|
||||||
|
|
||||||
|
@ -44,5 +41,21 @@ open class BankAccount(
|
||||||
fun supportsAnyFeature(vararg features: BankAccountFeatures): Boolean =
|
fun supportsAnyFeature(vararg features: BankAccountFeatures): Boolean =
|
||||||
features.any { this.features.contains(it) }
|
features.any { this.features.contains(it) }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if all transactions that are retained on bank server have been fetched.
|
||||||
|
*
|
||||||
|
* Does this by comparing [countDaysForWhichTransactionsAreKeptOnBankServer] to [retrievedTransactionsFrom].
|
||||||
|
*/
|
||||||
|
open val haveAllRetainedTransactionsBeenRetrieved: Boolean by lazy {
|
||||||
|
val fromDay = retrievedTransactionsFrom
|
||||||
|
if (fromDay == null) {
|
||||||
|
false
|
||||||
|
} else {
|
||||||
|
// if countDaysForWhichTransactionsAreKeptOnBankServer is not set, we cannot know for how long bank server keeps transactions. We then assume for 90 days
|
||||||
|
val storageDays = countDaysForWhichTransactionsAreKeptOnBankServer ?: 90
|
||||||
|
fromDay < Clock.System.now().toLocalDateTime(TimeZone.of("Europe/Berlin")).date.minus(storageDays, DateTimeUnit.DAY)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun toString() = "$type $identifier $productName (IBAN: $iban)"
|
override fun toString() = "$type $identifier $productName (IBAN: $iban)"
|
||||||
}
|
}
|
Loading…
Reference in New Issue