Fixed checking if all transactions have been fetched by using retrievedTransactionsFromOn (as first retrieved transaction may not is on the first day of the fetched period(
This commit is contained in:
parent
f96e7a4b30
commit
1bc8a93ba4
|
@ -354,18 +354,20 @@ open class BankingPresenter(
|
|||
|
||||
protected open fun didFetchAllTransactionsStoredOnBankServer(account: IBankAccount<IAccountTransaction>, fetchedTransactions: Collection<IAccountTransaction>): Boolean {
|
||||
account.customer.countDaysForWhichTransactionsAreKept?.let { countDaysForWhichTransactionsAreKept ->
|
||||
val firstAccountTransactions = if (account.bookedTransactions.isNotEmpty()) account.bookedTransactions else fetchedTransactions
|
||||
|
||||
firstAccountTransactions.map { it.valueDate }.minBy { it.millisSinceEpoch }?.let { dateOfFirstRetrievedTransaction ->
|
||||
(account.retrievedTransactionsFromOn ?: getDateOfFirstRetrievedTransaction(account.bookedTransactions) ?: getDateOfFirstRetrievedTransaction(fetchedTransactions))?.let { retrievedTransactionsFromOn ->
|
||||
val dayOfFirstTransactionStoredOnBankServer = Date(Date.today.millisSinceEpoch - countDaysForWhichTransactionsAreKept * OneDayMillis)
|
||||
|
||||
return dateOfFirstRetrievedTransaction.isBeforeOrEquals(dayOfFirstTransactionStoredOnBankServer)
|
||||
return retrievedTransactionsFromOn.isBeforeOrEquals(dayOfFirstTransactionStoredOnBankServer)
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
protected open fun getDateOfFirstRetrievedTransaction(transactions: Collection<IAccountTransaction>): Date? {
|
||||
return transactions.map { it.valueDate }.minBy { it.millisSinceEpoch }
|
||||
}
|
||||
|
||||
protected open fun receivedAccountsTransactionChunk(bankAccount: TypedBankAccount, accountTransactionsChunk: List<IAccountTransaction>) {
|
||||
if (accountTransactionsChunk.isNotEmpty()) {
|
||||
asyncRunner.runAsync { // don't block retrieving next chunk by blocked saving to db / json
|
||||
|
|
Loading…
Reference in New Issue