Fixed that balance of selected accounts got calculated wrong (balances of accounts with multiple bank accounts got added multiple times)
This commit is contained in:
parent
69dea311bf
commit
2a626a8b7c
|
@ -319,7 +319,7 @@ open class MainWindowPresenter(
|
||||||
get() = getAccountTransactionsForAccounts(selectedBankAccounts.map { it.account }.toSet())
|
get() = getAccountTransactionsForAccounts(selectedBankAccounts.map { it.account }.toSet())
|
||||||
|
|
||||||
open val balanceOfSelectedBankAccounts: BigDecimal
|
open val balanceOfSelectedBankAccounts: BigDecimal
|
||||||
get() = getBalanceForAccounts(selectedBankAccounts.map { it.account }.toSet())
|
get() = sumBalance(selectedBankAccounts.map { it.balance })
|
||||||
|
|
||||||
open fun selectedAllBankAccounts() {
|
open fun selectedAllBankAccounts() {
|
||||||
setSelectedBankAccounts(bankAccounts)
|
setSelectedBankAccounts(bankAccounts)
|
||||||
|
@ -403,6 +403,10 @@ open class MainWindowPresenter(
|
||||||
return accounts.map { it.balance }.fold(BigDecimal.ZERO) { acc, e -> acc + e }
|
return accounts.map { it.balance }.fold(BigDecimal.ZERO) { acc, e -> acc + e }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected open fun sumBalance(singleBalances: Collection<BigDecimal>): BigDecimal {
|
||||||
|
return singleBalances.fold(BigDecimal.ZERO) { acc, e -> acc + e }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
open fun addAccountsChangedListener(listener: (List<Account>) -> Unit): Boolean {
|
open fun addAccountsChangedListener(listener: (List<Account>) -> Unit): Boolean {
|
||||||
return accountsChangedListeners.add(listener)
|
return accountsChangedListeners.add(listener)
|
||||||
|
|
Loading…
Reference in New Issue