public void Update(ICacheService cacheService, Account selectedAccount, WorkPeriod currentWorkPeriod) { var accountType = cacheService.GetAccountTypeById(selectedAccount.AccountTypeId); var transactions = Dao.Query(GetCurrentRange(accountType.DefaultFilterType, x => x.AccountId == selectedAccount.Id, currentWorkPeriod)).OrderBy(x => x.Date); Transactions = transactions.Select(x => new AccountDetailData(x, selectedAccount)).ToList(); if (accountType.DefaultFilterType > 0) { var pastDebit = Dao.Sum(x => x.Debit, GetPastRange(accountType.DefaultFilterType, x => x.AccountId == selectedAccount.Id, currentWorkPeriod)); var pastCredit = Dao.Sum(x => x.Credit, GetPastRange(accountType.DefaultFilterType, x => x.AccountId == selectedAccount.Id, currentWorkPeriod)); var pastExchange = Dao.Sum(x => x.Exchange, GetPastRange(accountType.DefaultFilterType, x => x.AccountId == selectedAccount.Id, currentWorkPeriod)); if (pastCredit > 0 || pastDebit > 0) { Summaries.Add(new AccountSummaryData(Resources.Total, Transactions.Sum(x => x.Debit), Transactions.Sum(x => x.Credit))); var detailValue = new AccountDetailData( new AccountTransactionValue { Name = Resources.PastTransactions, Credit = pastCredit, Debit = pastDebit, Exchange = pastExchange }, selectedAccount) { IsBold = true }; Transactions.Insert(0, detailValue); } } Summaries.Add(new AccountSummaryData(Resources.GrandTotal, Transactions.Sum(x => x.Debit), Transactions.Sum(x => x.Credit))); for (var i = 0; i < Transactions.Count; i++) { Transactions[i].Balance = (Transactions[i].Debit - Transactions[i].Credit); if (i > 0) (Transactions[i].Balance) += (Transactions[i - 1].Balance); } }
public void Update(Account selectedAccount, DateTime? start, DateTime? end) { Start = start; End = end; var transactions = Dao.Query(GetCurrentRange(start, end, x => x.AccountId == selectedAccount.Id)).OrderBy(x => x.Date); Transactions = transactions.Select(x => new AccountDetailData(x, selectedAccount)).ToList(); if (start.HasValue) { var pastDebit = Dao.Sum(x => x.Debit, GetPastRange(start, x => x.AccountId == selectedAccount.Id)); var pastCredit = Dao.Sum(x => x.Credit, GetPastRange(start, x => x.AccountId == selectedAccount.Id)); var pastExchange = Dao.Sum(x => x.Exchange, GetPastRange(start, x => x.AccountId == selectedAccount.Id)); if (pastCredit > 0 || pastDebit > 0) { Summaries.Add(new AccountSummaryData(Resources.TransactionTotal, Transactions.Sum(x => x.Debit), Transactions.Sum(x => x.Credit))); var detailValue = new AccountDetailData( new AccountTransactionValue { Date = start.GetValueOrDefault(), Name = Resources.BalanceBroughtForward, Credit = pastCredit, Debit = pastDebit, Exchange = pastExchange }, selectedAccount) { IsBold = true }; Transactions.Insert(0, detailValue); } } if (end.HasValue && end != start) { var futureDebit = Dao.Sum(x => x.Debit, GetFutureRange(end, x => x.AccountId == selectedAccount.Id)); var futureCredit = Dao.Sum(x => x.Credit, GetFutureRange(end, x => x.AccountId == selectedAccount.Id)); var futureExchange = Dao.Sum(x => x.Exchange, GetFutureRange(end, x => x.AccountId == selectedAccount.Id)); if (futureCredit > 0 || futureDebit > 0) { Summaries.Add(new AccountSummaryData(Resources.DateRangeTotal, Transactions.Sum(x => x.Debit), Transactions.Sum(x => x.Credit))); var detailValue = new AccountDetailData( new AccountTransactionValue { Date = end.GetValueOrDefault(), Name = Resources.BalanceAfterDate, Credit = futureCredit, Debit = futureDebit, Exchange = futureExchange }, selectedAccount) { IsBold = true }; Transactions.Add(detailValue); } } Summaries.Add(new AccountSummaryData(Resources.GrandTotal, Transactions.Sum(x => x.Debit), Transactions.Sum(x => x.Credit))); for (var i = 0; i < Transactions.Count; i++) { Transactions[i].Balance = (Transactions[i].Debit - Transactions[i].Credit); if (i > 0) (Transactions[i].Balance) += (Transactions[i - 1].Balance); } }
public void Update(ICacheService cacheService, Account selectedAccount, WorkPeriod currentWorkPeriod) { var accountType = cacheService.GetAccountTypeById(selectedAccount.AccountTypeId); var transactions = Dao.Query(GetCurrentRange(accountType.DefaultFilterType, x => x.AccountId == selectedAccount.Id, currentWorkPeriod)).OrderBy(x => x.Date); Transactions = transactions.Select(x => new AccountDetailData(x, selectedAccount)).ToList(); if (accountType.DefaultFilterType > 0) { var pastDebit = Dao.Sum(x => x.Debit, GetPastRange(accountType.DefaultFilterType, x => x.AccountId == selectedAccount.Id, currentWorkPeriod)); var pastCredit = Dao.Sum(x => x.Credit, GetPastRange(accountType.DefaultFilterType, x => x.AccountId == selectedAccount.Id, currentWorkPeriod)); var pastExchange = Dao.Sum(x => x.Exchange, GetPastRange(accountType.DefaultFilterType, x => x.AccountId == selectedAccount.Id, currentWorkPeriod)); if (pastCredit > 0 || pastDebit > 0) { Summaries.Add(new AccountSummaryData(Resources.Total, Transactions.Sum(x => x.Debit), Transactions.Sum(x => x.Credit))); var detailValue = new AccountDetailData( new AccountTransactionValue { Name = Resources.PastTransactions, Credit = pastCredit, Debit = pastDebit, Exchange = pastExchange }, selectedAccount) { IsBold = true }; Transactions.Insert(0, detailValue); } } Summaries.Add(new AccountSummaryData(Resources.GrandTotal, Transactions.Sum(x => x.Debit), Transactions.Sum(x => x.Credit))); for (var i = 0; i < Transactions.Count; i++) { Transactions[i].Balance = (Transactions[i].Debit - Transactions[i].Credit); if (i > 0) { (Transactions[i].Balance) += (Transactions[i - 1].Balance); } } }
public void Update(Account selectedAccount, DateTime?start, DateTime?end) { Start = start; End = end; var transactions = Dao.Query(GetCurrentRange(start, end, x => x.AccountId == selectedAccount.Id)).OrderBy(x => x.Date); Transactions = transactions.Select(x => new AccountDetailData(x, selectedAccount)).ToList(); if (start.HasValue) { var pastDebit = Dao.Sum(x => x.Debit, GetPastRange(start, x => x.AccountId == selectedAccount.Id)); var pastCredit = Dao.Sum(x => x.Credit, GetPastRange(start, x => x.AccountId == selectedAccount.Id)); var pastExchange = Dao.Sum(x => x.Exchange, GetPastRange(start, x => x.AccountId == selectedAccount.Id)); if (pastCredit > 0 || pastDebit > 0) { Summaries.Add(new AccountSummaryData(Resources.TransactionTotal, Transactions.Sum(x => x.Debit), Transactions.Sum(x => x.Credit))); var detailValue = new AccountDetailData( new AccountTransactionValue { Date = start.GetValueOrDefault(), Name = Resources.BalanceBroughtForward, Credit = pastCredit, Debit = pastDebit, Exchange = pastExchange }, selectedAccount) { IsBold = true }; Transactions.Insert(0, detailValue); } } if (end.HasValue && end != start) { var futureDebit = Dao.Sum(x => x.Debit, GetFutureRange(end, x => x.AccountId == selectedAccount.Id)); var futureCredit = Dao.Sum(x => x.Credit, GetFutureRange(end, x => x.AccountId == selectedAccount.Id)); var futureExchange = Dao.Sum(x => x.Exchange, GetFutureRange(end, x => x.AccountId == selectedAccount.Id)); if (futureCredit > 0 || futureDebit > 0) { Summaries.Add(new AccountSummaryData(Resources.DateRangeTotal, Transactions.Sum(x => x.Debit), Transactions.Sum(x => x.Credit))); var detailValue = new AccountDetailData( new AccountTransactionValue { Date = end.GetValueOrDefault(), Name = Resources.BalanceAfterDate, Credit = futureCredit, Debit = futureDebit, Exchange = futureExchange }, selectedAccount) { IsBold = true }; Transactions.Add(detailValue); } } Summaries.Add(new AccountSummaryData(Resources.GrandTotal, Transactions.Sum(x => x.Debit), Transactions.Sum(x => x.Credit))); for (var i = 0; i < Transactions.Count; i++) { Transactions[i].Balance = (Transactions[i].Debit - Transactions[i].Credit); if (i > 0) { (Transactions[i].Balance) += (Transactions[i - 1].Balance); } } }