Added convenience constructors for bank and bank accounts; settings now selected accounts so that we can use presenter.searchSelectedAccountTransactions()
This commit is contained in:
parent
d7c904a677
commit
6b3e4b65c3
|
@ -28,9 +28,21 @@ struct AccountTransactionsDialog: View {
|
||||||
|
|
||||||
|
|
||||||
@Inject private var presenter: BankingPresenterSwift
|
@Inject private var presenter: BankingPresenterSwift
|
||||||
|
|
||||||
|
|
||||||
|
init(bank: Customer) {
|
||||||
|
self.init(title: bank.displayName, transactions: bank.accounts.flatMap { $0.bookedTransactions }, balance: bank.balance)
|
||||||
|
|
||||||
|
presenter.selectedAccount(customer: bank)
|
||||||
|
}
|
||||||
|
|
||||||
init(title: String, transactions: [AccountTransaction], balance: CommonBigDecimal) {
|
init(account: BankAccount) {
|
||||||
|
self.init(title: account.displayName, transactions: account.bookedTransactions, balance: account.balance)
|
||||||
|
|
||||||
|
presenter.selectedBankAccount(bankAccount: account)
|
||||||
|
}
|
||||||
|
|
||||||
|
fileprivate init(title: String, transactions: [AccountTransaction], balance: CommonBigDecimal) {
|
||||||
self.title = title
|
self.title = title
|
||||||
|
|
||||||
self.allTransactions = transactions
|
self.allTransactions = transactions
|
||||||
|
@ -66,7 +78,7 @@ struct AccountTransactionsDialog: View {
|
||||||
|
|
||||||
|
|
||||||
private func filterTransactions(_ query: String) {
|
private func filterTransactions(_ query: String) {
|
||||||
self.filteredTransactions = presenter.searchAccountTransactions(query: query, transactions: allTransactions)
|
self.filteredTransactions = presenter.searchSelectedAccountTransactions(query: query)
|
||||||
|
|
||||||
self.balanceOfFilteredTransactions = query.isEmpty ? balanceOfAllTransactions : filteredTransactions.sumAmounts()
|
self.balanceOfFilteredTransactions = query.isEmpty ? balanceOfAllTransactions : filteredTransactions.sumAmounts()
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ struct BankAccountListItem : View {
|
||||||
Spacer()
|
Spacer()
|
||||||
}.frame(height: 35)
|
}.frame(height: 35)
|
||||||
|
|
||||||
NavigationLink(destination: AccountTransactionsDialog(title: account.displayName, transactions: account.bookedTransactions, balance: account.balance)) {
|
NavigationLink(destination: AccountTransactionsDialog(account: account)) {
|
||||||
EmptyView()
|
EmptyView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ struct BankListItem : View {
|
||||||
Spacer()
|
Spacer()
|
||||||
}.frame(height: 35)
|
}.frame(height: 35)
|
||||||
|
|
||||||
NavigationLink(destination: AccountTransactionsDialog(title: bank.displayName, transactions: bank.accounts.flatMap { $0.bookedTransactions }, balance: bank.balance)) {
|
NavigationLink(destination: AccountTransactionsDialog(bank: bank)) {
|
||||||
EmptyView()
|
EmptyView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue