Updated to fints4k changes: lastTransactionRetrievalTime has been renamed to lastTransactionsRetrievalTime and its type has been changed to Instant
This commit is contained in:
parent
ba662fda15
commit
469ee275c9
|
@ -34,8 +34,8 @@ interface BankingClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience wrapper around [getAccountDataAsync].
|
* Convenience wrapper around [getAccountDataAsync].
|
||||||
* Updates account's transactions beginning from [BankAccount.lastTransactionRetrievalTime].
|
* Updates account's transactions beginning from [BankAccount.lastTransactionsRetrievalTime].
|
||||||
* This may requires TAN if [BankAccount.lastTransactionRetrievalTime] is older than 90 days.
|
* This may requires TAN if [BankAccount.lastTransactionsRetrievalTime] is older than 90 days.
|
||||||
*/
|
*/
|
||||||
suspend fun updateAccountTransactionsAsync(user: UserAccount, accounts: List<BankAccount>? = null): Response<List<GetTransactionsResponse>>
|
suspend fun updateAccountTransactionsAsync(user: UserAccount, accounts: List<BankAccount>? = null): Response<List<GetTransactionsResponse>>
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,8 @@ interface BankingClientForUser {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience wrapper around [getAccountDataAsync].
|
* Convenience wrapper around [getAccountDataAsync].
|
||||||
* Updates account's transactions beginning from [BankAccount.lastTransactionRetrievalTime].
|
* Updates account's transactions beginning from [BankAccount.lastTransactionsRetrievalTime].
|
||||||
* This may requires TAN if [BankAccount.lastTransactionRetrievalTime] is older than 90 days.
|
* This may requires TAN if [BankAccount.lastTransactionsRetrievalTime] is older than 90 days.
|
||||||
*/
|
*/
|
||||||
suspend fun updateAccountTransactionsAsync(): Response<List<GetTransactionsResponse>>
|
suspend fun updateAccountTransactionsAsync(): Response<List<GetTransactionsResponse>>
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package net.codinux.banking.client.model
|
package net.codinux.banking.client.model
|
||||||
|
|
||||||
|
import kotlinx.datetime.Instant
|
||||||
import kotlinx.datetime.LocalDate
|
import kotlinx.datetime.LocalDate
|
||||||
import kotlinx.datetime.LocalDateTime
|
|
||||||
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
|
||||||
|
|
||||||
|
@ -21,8 +21,9 @@ open class BankAccount(
|
||||||
|
|
||||||
// var balance: BigDecimal = BigDecimal.ZERO,
|
// var balance: BigDecimal = BigDecimal.ZERO,
|
||||||
var balance: Amount = Amount.Zero, // TODO: add a BigDecimal library
|
var balance: Amount = Amount.Zero, // TODO: add a BigDecimal library
|
||||||
|
|
||||||
|
open var lastTransactionsRetrievalTime: Instant? = null,
|
||||||
var retrievedTransactionsFrom: LocalDate? = null,
|
var retrievedTransactionsFrom: LocalDate? = null,
|
||||||
open var lastTransactionRetrievalTime: LocalDateTime? = null,
|
|
||||||
|
|
||||||
var haveAllTransactionsBeenRetrieved: Boolean = false,
|
var haveAllTransactionsBeenRetrieved: Boolean = false,
|
||||||
val countDaysForWhichTransactionsAreKept: Int? = null,
|
val countDaysForWhichTransactionsAreKept: Int? = null,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package net.codinux.banking.client.model.response
|
package net.codinux.banking.client.model.response
|
||||||
|
|
||||||
|
import kotlinx.datetime.Instant
|
||||||
import kotlinx.datetime.LocalDate
|
import kotlinx.datetime.LocalDate
|
||||||
import kotlinx.datetime.LocalDateTime
|
|
||||||
import net.codinux.banking.client.model.AccountTransaction
|
import net.codinux.banking.client.model.AccountTransaction
|
||||||
import net.codinux.banking.client.model.Amount
|
import net.codinux.banking.client.model.Amount
|
||||||
import net.codinux.banking.client.model.BankAccount
|
import net.codinux.banking.client.model.BankAccount
|
||||||
|
@ -14,7 +14,7 @@ open class GetTransactionsResponse(
|
||||||
val balance: Amount? = null,
|
val balance: Amount? = null,
|
||||||
val bookedTransactions: List<AccountTransaction>,
|
val bookedTransactions: List<AccountTransaction>,
|
||||||
val unbookedTransactions: List<UnbookedAccountTransaction>,
|
val unbookedTransactions: List<UnbookedAccountTransaction>,
|
||||||
val transactionRetrievalTime: LocalDateTime,
|
val transactionsRetrievalTime: Instant,
|
||||||
val retrievedTransactionsFrom: LocalDate? = null,
|
val retrievedTransactionsFrom: LocalDate? = null,
|
||||||
val retrievedTransactionsTo: LocalDate? = null
|
val retrievedTransactionsTo: LocalDate? = null
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package net.codinux.banking.client.fints4k
|
package net.codinux.banking.client.fints4k
|
||||||
|
|
||||||
import kotlinx.datetime.LocalDateTime
|
import kotlinx.datetime.Clock
|
||||||
|
import kotlinx.datetime.TimeZone
|
||||||
|
import kotlinx.datetime.toLocalDateTime
|
||||||
import net.codinux.banking.client.model.*
|
import net.codinux.banking.client.model.*
|
||||||
import net.codinux.banking.client.model.AccountTransaction
|
import net.codinux.banking.client.model.AccountTransaction
|
||||||
import net.codinux.banking.client.model.Amount
|
import net.codinux.banking.client.model.Amount
|
||||||
|
@ -12,7 +14,7 @@ import net.codinux.banking.client.model.tan.TanChallenge
|
||||||
import net.codinux.banking.client.model.tan.TanImage
|
import net.codinux.banking.client.model.tan.TanImage
|
||||||
import net.codinux.banking.client.model.tan.TanMethod
|
import net.codinux.banking.client.model.tan.TanMethod
|
||||||
import net.codinux.banking.client.model.tan.TanMethodType
|
import net.codinux.banking.client.model.tan.TanMethodType
|
||||||
import net.codinux.banking.fints.extensions.nowAtEuropeBerlin
|
import net.codinux.banking.fints.extensions.EuropeBerlin
|
||||||
import net.dankito.banking.client.model.BankAccountIdentifierImpl
|
import net.dankito.banking.client.model.BankAccountIdentifierImpl
|
||||||
import net.dankito.banking.client.model.parameter.GetAccountDataParameter
|
import net.dankito.banking.client.model.parameter.GetAccountDataParameter
|
||||||
import net.dankito.banking.client.model.parameter.RetrieveTransactions
|
import net.dankito.banking.client.model.parameter.RetrieveTransactions
|
||||||
|
@ -45,7 +47,7 @@ open class FinTs4kMapper {
|
||||||
|
|
||||||
open fun mapToUpdateAccountTransactionsParameter(user: UserAccount, account: BankAccount, finTsModel: BankData?): GetAccountDataParameter {
|
open fun mapToUpdateAccountTransactionsParameter(user: UserAccount, account: BankAccount, finTsModel: BankData?): GetAccountDataParameter {
|
||||||
val accountIdentifier = BankAccountIdentifierImpl(account.identifier, account.subAccountNumber, account.iban)
|
val accountIdentifier = BankAccountIdentifierImpl(account.identifier, account.subAccountNumber, account.iban)
|
||||||
val from = account.lastTransactionRetrievalTime?.date
|
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 retrieveTransactions = if (from != null) RetrieveTransactions.AccordingToRetrieveFromAndTo else RetrieveTransactions.OfLast90Days
|
val retrieveTransactions = if (from != null) RetrieveTransactions.AccordingToRetrieveFromAndTo else RetrieveTransactions.OfLast90Days
|
||||||
// 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 = emptyList<net.codinux.banking.fints.model.TanMethodType>()
|
val preferredTanMethods = emptyList<net.codinux.banking.fints.model.TanMethodType>()
|
||||||
|
@ -79,8 +81,12 @@ 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) {
|
||||||
|
account.lastTransactionsRetrievalTime = finTsBankAccount.lastTransactionsRetrievalTime
|
||||||
|
}
|
||||||
|
|
||||||
Response.success(GetTransactionsResponse(account, mapAmount(finTsBankAccount.balance), mapBookedTransactions(finTsBankAccount), emptyList(),
|
Response.success(GetTransactionsResponse(account, mapAmount(finTsBankAccount.balance), mapBookedTransactions(finTsBankAccount), emptyList(),
|
||||||
finTsBankAccount.lastTransactionRetrievalTime ?: LocalDateTime.nowAtEuropeBerlin(), param.retrieveTransactionsFrom, param.retrieveTransactionsTo))
|
finTsBankAccount.lastTransactionsRetrievalTime ?: Clock.System.now(), param.retrieveTransactionsFrom, param.retrieveTransactionsTo))
|
||||||
} else {
|
} else {
|
||||||
mapError(getAccountDataResponse)
|
mapError(getAccountDataResponse)
|
||||||
}
|
}
|
||||||
|
@ -122,7 +128,7 @@ open class FinTs4kMapper {
|
||||||
account.identifier, account.accountHolderName, mapAccountType(account.type), account.iban, account.subAccountNumber,
|
account.identifier, account.accountHolderName, mapAccountType(account.type), account.iban, account.subAccountNumber,
|
||||||
account.productName, account.currency, account.accountLimit, account.isAccountTypeSupportedByApplication,
|
account.productName, account.currency, account.accountLimit, account.isAccountTypeSupportedByApplication,
|
||||||
mapFeatures(account),
|
mapFeatures(account),
|
||||||
mapAmount(account.balance), account.retrievedTransactionsFrom, account.lastTransactionRetrievalTime,
|
mapAmount(account.balance), account.lastTransactionsRetrievalTime, account.retrievedTransactionsFrom,
|
||||||
// TODO: map haveAllTransactionsBeenRetrieved
|
// TODO: map haveAllTransactionsBeenRetrieved
|
||||||
countDaysForWhichTransactionsAreKept = account.countDaysForWhichTransactionsAreKept,
|
countDaysForWhichTransactionsAreKept = account.countDaysForWhichTransactionsAreKept,
|
||||||
bookedTransactions = mapBookedTransactions(account).toMutableList()
|
bookedTransactions = mapBookedTransactions(account).toMutableList()
|
||||||
|
|
|
@ -19,7 +19,7 @@ class FinTs4kBankingClientTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private val underTest = FinTs4KBankingClientForUser(bankCode, loginName, password, SimpleBankingClientCallback { tanChallenge, callback ->
|
private val underTest = FinTs4kBankingClientForUser(bankCode, loginName, password, SimpleBankingClientCallback { tanChallenge, callback ->
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue