Fixed updating BankAccount.balance and .retrievedTransactionsFrom
This commit is contained in:
parent
6238b5abb2
commit
d689c7663f
|
@ -77,12 +77,20 @@ open class FinTsModelMapper {
|
||||||
|
|
||||||
customerAccount.accounts.forEach { bankAccount ->
|
customerAccount.accounts.forEach { bankAccount ->
|
||||||
retrievedData.firstOrNull { it.account.accountIdentifier == bankAccount.identifier }?.let { accountTransactionsResponse ->
|
retrievedData.firstOrNull { it.account.accountIdentifier == bankAccount.identifier }?.let { accountTransactionsResponse ->
|
||||||
bankAccount.balance = accountTransactionsResponse.balance ?: Money.Zero
|
accountTransactionsResponse.balance?.let { balance ->
|
||||||
bankAccount.retrievedTransactionsFrom = accountTransactionsResponse.retrievedTransactionsFrom
|
bankAccount.balance = balance
|
||||||
|
}
|
||||||
|
|
||||||
|
if (accountTransactionsResponse.retrievedTransactionsFrom != null && (bankAccount.retrievedTransactionsFrom == null ||
|
||||||
|
accountTransactionsResponse.retrievedTransactionsFrom!! < bankAccount.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)
|
||||||
if (bankAccount.lastTransactionRetrievalTime == null || bankAccount.lastTransactionRetrievalTime!! <= retrievalTime) { // if retrieveTransactionsTo is set it may is older than current account's lastTransactionRetrievalTime
|
if (bankAccount.lastTransactionRetrievalTime == null || bankAccount.lastTransactionRetrievalTime!! <= retrievalTime) { // if retrieveTransactionsTo is set it may is older than current account's lastTransactionRetrievalTime
|
||||||
bankAccount.lastTransactionRetrievalTime = retrievalTime
|
bankAccount.lastTransactionRetrievalTime = retrievalTime
|
||||||
}
|
}
|
||||||
|
|
||||||
bankAccount.bookedTransactions = map(accountTransactionsResponse)
|
bankAccount.bookedTransactions = map(accountTransactionsResponse)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue