Renamed lastTransactionsRetrievalTime to lastAccountUpdateTime
This commit is contained in:
parent
5187e34797
commit
54940742f7
|
@ -36,8 +36,8 @@ interface BankingClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience wrapper around [getAccountDataAsync].
|
* Convenience wrapper around [getAccountDataAsync].
|
||||||
* Updates account's transactions beginning from [BankAccount.lastTransactionsRetrievalTime].
|
* Updates account's transactions beginning from [BankAccount.lastAccountUpdateTime].
|
||||||
* This may requires TAN if [BankAccount.lastTransactionsRetrievalTime] is older than 90 days.
|
* 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.
|
* Optionally specify which [accounts] should be updated. If not specified all accounts will be updated.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -37,8 +37,8 @@ interface BankingClientForUser {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience wrapper around [getAccountDataAsync].
|
* Convenience wrapper around [getAccountDataAsync].
|
||||||
* Updates account's transactions beginning from [BankAccount.lastTransactionsRetrievalTime].
|
* Updates account's transactions beginning from [BankAccount.lastAccountUpdateTime].
|
||||||
* This may requires TAN if [BankAccount.lastTransactionsRetrievalTime] is older than 90 days.
|
* This may requires TAN if [BankAccount.lastAccountUpdateTime] is older than 90 days.
|
||||||
*/
|
*/
|
||||||
suspend fun updateAccountTransactionsAsync(accounts: List<BankAccount>? = null): Response<List<GetTransactionsResponse>>
|
suspend fun updateAccountTransactionsAsync(accounts: List<BankAccount>? = null): Response<List<GetTransactionsResponse>>
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ open class BankAccount(
|
||||||
var balance: Amount = Amount.Zero, // TODO: add a BigDecimal library
|
var balance: Amount = Amount.Zero, // TODO: add a BigDecimal library
|
||||||
|
|
||||||
val serverTransactionsRetentionDays: Int? = null,
|
val serverTransactionsRetentionDays: Int? = null,
|
||||||
open var lastTransactionsRetrievalTime: Instant? = null,
|
open var lastAccountUpdateTime: Instant? = null,
|
||||||
var retrievedTransactionsFrom: LocalDate? = null,
|
var retrievedTransactionsFrom: LocalDate? = null,
|
||||||
|
|
||||||
open val bookedTransactions: MutableList<AccountTransaction> = mutableListOf(),
|
open val bookedTransactions: MutableList<AccountTransaction> = mutableListOf(),
|
||||||
|
|
|
@ -63,7 +63,7 @@ open class FinTs4kMapper {
|
||||||
val defaults = GetAccountDataOptions()
|
val defaults = GetAccountDataOptions()
|
||||||
|
|
||||||
val accountIdentifier = BankAccountIdentifierImpl(account.identifier, account.subAccountNumber, account.iban)
|
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 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 = 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) }
|
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 }
|
val finTsBankAccount = user?.accounts?.firstOrNull { it.identifier == account.identifier && it.subAccountNumber == account.subAccountNumber }
|
||||||
|
|
||||||
if (getAccountDataResponse.successful && user != null && finTsBankAccount != null) {
|
if (getAccountDataResponse.successful && user != null && finTsBankAccount != null) {
|
||||||
if (finTsBankAccount.lastTransactionsRetrievalTime != null) {
|
if (finTsBankAccount.lastAccountUpdateTime != null) {
|
||||||
account.lastTransactionsRetrievalTime = finTsBankAccount.lastTransactionsRetrievalTime
|
account.lastAccountUpdateTime = finTsBankAccount.lastAccountUpdateTime
|
||||||
}
|
}
|
||||||
if (account.retrievedTransactionsFrom == null || (finTsBankAccount.retrievedTransactionsFrom != null
|
if (account.retrievedTransactionsFrom == null || (finTsBankAccount.retrievedTransactionsFrom != null
|
||||||
&& account.retrievedTransactionsFrom!! < finTsBankAccount.retrievedTransactionsFrom!!)) {
|
&& account.retrievedTransactionsFrom!! < finTsBankAccount.retrievedTransactionsFrom!!)) {
|
||||||
|
@ -115,8 +115,8 @@ open class FinTs4kMapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
Response.success(GetTransactionsResponse(account, mapMoney(finTsBankAccount.balance), mapBookedTransactions(finTsBankAccount), emptyList(),
|
Response.success(GetTransactionsResponse(account, mapMoney(finTsBankAccount.balance), mapBookedTransactions(finTsBankAccount), emptyList(),
|
||||||
mapHoldings(finTsBankAccount.statementOfHoldings, finTsBankAccount.currency, finTsBankAccount.lastTransactionsRetrievalTime),
|
mapHoldings(finTsBankAccount.statementOfHoldings, finTsBankAccount.currency, finTsBankAccount.lastAccountUpdateTime),
|
||||||
finTsBankAccount.lastTransactionsRetrievalTime ?: Clock.System.now(), param.retrieveTransactionsFrom, param.retrieveTransactionsTo))
|
finTsBankAccount.lastAccountUpdateTime ?: Clock.System.now(), param.retrieveTransactionsFrom, param.retrieveTransactionsTo))
|
||||||
} else {
|
} else {
|
||||||
mapError(getAccountDataResponse)
|
mapError(getAccountDataResponse)
|
||||||
}
|
}
|
||||||
|
@ -162,9 +162,9 @@ open class FinTs4kMapper {
|
||||||
account.isAccountTypeSupportedByApplication, mapFeatures(account),
|
account.isAccountTypeSupportedByApplication, mapFeatures(account),
|
||||||
mapMoney(account.balance),
|
mapMoney(account.balance),
|
||||||
account.serverTransactionsRetentionDays,
|
account.serverTransactionsRetentionDays,
|
||||||
account.lastTransactionsRetrievalTime, account.retrievedTransactionsFrom,
|
account.lastAccountUpdateTime, account.retrievedTransactionsFrom,
|
||||||
bookedTransactions = mapBookedTransactions(account).toMutableList(),
|
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 =
|
protected open fun mapAccountType(type: net.dankito.banking.client.model.BankAccountType): BankAccountType =
|
||||||
|
|
|
@ -115,12 +115,12 @@ response.error?.let{ error ->
|
||||||
|
|
||||||
### Update Account Transactions
|
### 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
|
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
|
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)`:
|
`BankingModelService().findNewTransactions(retrieveTransactions, existingTransactions)`:
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
|
|
Loading…
Reference in New Issue