Implemented also showing total amount in BanksList
This commit is contained in:
parent
12c9becd17
commit
466ab84c36
|
@ -94,6 +94,8 @@ fun NavigationMenuItem(
|
|||
bankAccount.balance
|
||||
} else if (bank != null) {
|
||||
calculator.calculateBalanceOfBankAccess(bank)
|
||||
} else if (text == "Alle Konten") {
|
||||
calculator.calculateBalanceOfAllAccounts(DI.uiState.accounts.value)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
@ -113,7 +115,7 @@ fun NavigationMenuItem(
|
|||
}
|
||||
}
|
||||
}
|
||||
if (bankAccount != null) { // show a place holder to match Settings icon's width
|
||||
if (bankAccount != null || bank == null) { // show a place holder to match Settings icon's width
|
||||
Spacer(Modifier.padding(start = 8.dp).size(24.dp))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,9 +10,15 @@ class CalculatorService {
|
|||
fun sumTransactions(transactions: Collection<AccountTransactionViewModel>): Amount =
|
||||
transactions.map { it.amount }.sum()
|
||||
|
||||
fun calculateBalanceOfAllBank(banks: List<BankAccess>): Amount =
|
||||
calculateBalanceOfAllAccounts(banks.flatMap { it.accounts })
|
||||
|
||||
fun calculateBalanceOfBankAccess(bank: BankAccess): Amount =
|
||||
sumAmounts(bank.accounts.map { it.balance })
|
||||
|
||||
fun calculateBalanceOfAllAccounts(accounts: List<BankAccount>): Amount =
|
||||
sumAmounts(accounts.map { it.balance })
|
||||
|
||||
fun sumAmounts(amounts: Collection<Amount>): Amount =
|
||||
amounts.sum()
|
||||
|
||||
|
|
Loading…
Reference in New Issue