private void DisplayTransactions() { AccountDetails.Clear(); AccountSummaries.Clear(); var transactions = Dao.Query(GetCurrentRange(x => x.AccountId == SelectedAccount.Id)).OrderBy(x => x.Date); AccountDetails.AddRange(transactions.Select(x => new AccountDetailViewModel(x, SelectedAccount))); if (FilterType != Resources.All) { var pastDebit = Dao.Sum(x => x.Debit, GetPastRange(x => x.AccountId == SelectedAccount.Id)); var pastCredit = Dao.Sum(x => x.Credit, GetPastRange(x => x.AccountId == SelectedAccount.Id)); var pastExchange = Dao.Sum(x => x.Exchange, GetPastRange(x => x.AccountId == SelectedAccount.Id)); if (pastCredit > 0 || pastDebit > 0) { AccountSummaries.Add(new AccountSummaryViewModel(Resources.Total, AccountDetails.Sum(x => x.Debit), AccountDetails.Sum(x => x.Credit))); var detailValue = new AccountDetailViewModel(new AccountTransactionValue { Name = Resources.PastTransactions, Credit = pastCredit, Debit = pastDebit, Exchange = pastExchange }, SelectedAccount); AccountDetails.Insert(0, detailValue); detailValue.IsBold = true; } } AccountSummaries.Add(new AccountSummaryViewModel(Resources.GrandTotal, AccountDetails.Sum(x => x.Debit), AccountDetails.Sum(x => x.Credit))); for (var i = 0; i < AccountDetails.Count; i++) { AccountDetails[i].Balance = (AccountDetails[i].Debit - AccountDetails[i].Credit); if (i > 0) { (AccountDetails[i].Balance) += (AccountDetails[i - 1].Balance); } } RaisePropertyChanged(() => TotalBalance); }