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