diff --git a/BankingUiCommon/src/main/java/net/dankito/banking/ui/presenter/MainWindowPresenter.kt b/BankingUiCommon/src/main/java/net/dankito/banking/ui/presenter/MainWindowPresenter.kt index f51419f1..7aaeb602 100644 --- a/BankingUiCommon/src/main/java/net/dankito/banking/ui/presenter/MainWindowPresenter.kt +++ b/BankingUiCommon/src/main/java/net/dankito/banking/ui/presenter/MainWindowPresenter.kt @@ -319,7 +319,7 @@ open class MainWindowPresenter( get() = getAccountTransactionsForAccounts(selectedBankAccounts.map { it.account }.toSet()) open val balanceOfSelectedBankAccounts: BigDecimal - get() = getBalanceForAccounts(selectedBankAccounts.map { it.account }.toSet()) + get() = sumBalance(selectedBankAccounts.map { it.balance }) open fun selectedAllBankAccounts() { setSelectedBankAccounts(bankAccounts) @@ -403,6 +403,10 @@ open class MainWindowPresenter( return accounts.map { it.balance }.fold(BigDecimal.ZERO) { acc, e -> acc + e } } + protected open fun sumBalance(singleBalances: Collection): BigDecimal { + return singleBalances.fold(BigDecimal.ZERO) { acc, e -> acc + e } + } + open fun addAccountsChangedListener(listener: (List) -> Unit): Boolean { return accountsChangedListeners.add(listener)