diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/NavigationMenuItem.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/NavigationMenuItem.kt index 6aa78bb..677367b 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/NavigationMenuItem.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/NavigationMenuItem.kt @@ -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)) } } diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/CalculatorService.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/CalculatorService.kt index f9fb39c..5006122 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/CalculatorService.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/CalculatorService.kt @@ -10,9 +10,15 @@ class CalculatorService { fun sumTransactions(transactions: Collection): Amount = transactions.map { it.amount }.sum() + fun calculateBalanceOfAllBank(banks: List): Amount = + calculateBalanceOfAllAccounts(banks.flatMap { it.accounts }) + fun calculateBalanceOfBankAccess(bank: BankAccess): Amount = sumAmounts(bank.accounts.map { it.balance }) + fun calculateBalanceOfAllAccounts(accounts: List): Amount = + sumAmounts(accounts.map { it.balance }) + fun sumAmounts(amounts: Collection): Amount = amounts.sum()