Fixed filtering out accounts for which no transactions have been retrieved (otherwise .first() throws an exception)

This commit is contained in:
dankito 2021-04-18 01:23:37 +02:00
parent 1b3ec8f7c1
commit 9c63394922
1 changed files with 6 additions and 2 deletions

View File

@ -44,10 +44,14 @@ open class DtoMapper {
throw InternalServerErrorException("Could not fetch account transactions. Either TAN hasn't been entered or developers made a mistake.") throw InternalServerErrorException("Could not fetch account transactions. Either TAN hasn't been entered or developers made a mistake.")
} }
return GetAccountsTransactionsResponseDto(accountsTransactions.map { map(it) }) return GetAccountsTransactionsResponseDto(accountsTransactions.mapNotNull { map(it) }) // TODO: is this correct removing accounts from result for which no transactions have been retrieved?
} }
open fun map(accountTransactions: GetTransactionsResponse): GetAccountTransactionsResponseDto { open fun map(accountTransactions: GetTransactionsResponse): GetAccountTransactionsResponseDto? {
if (accountTransactions.retrievedData.isEmpty()) {
return null
}
val retrievedData = accountTransactions.retrievedData.first() val retrievedData = accountTransactions.retrievedData.first()
val balance = mapNullable(retrievedData.balance) val balance = mapNullable(retrievedData.balance)
val bookedTransactions = map(retrievedData.bookedTransactions) val bookedTransactions = map(retrievedData.bookedTransactions)