/// <summary> /// Returns a list of accounts associated with a list of collection /// </summary> /// <param name="collectionsIds">The list collections that is being requested</param> /// <param name="count">The number of transactions that is requested</param> /// <returns>A List of Account objects</returns> public List <Account> GetAccountIndex(List <string> collectionsIds, int count) { //get accounts List <Account> accounts = new List <Account>(); //get accountTypes AccountType type = new AccountType(); List <AccountType> accountTypes = type.GetAccountTypes(); foreach (string item in collectionsIds) { accounts.AddRange(GetAccountsEmpty(item)); } if (count > 0) { //get transactions ReportedTransaction reportedTransaction = new ReportedTransaction(); List <ReportedTransaction> transactions = reportedTransaction.GetTransactions(accounts.Select(x => x.Id).ToList(), count, collectionsIds); //assign transactions foreach (Account item in accounts) { item.ReportedTransactions = transactions.Where(x => x.AccountId == item.Id).ToList(); item.AccountType = accountTypes.Where(x => x.AccountTypeId == item.AccountTypeId).FirstOrDefault(); item.AccountType.Accounts = null; } } return(accounts); }
public BudgetTransactionComparison(string collectionsId) { Budget budget = new Budget(); BudgetItem = budget.GetBudget(collectionsId); ReportedTransaction reportedTransaction = new ReportedTransaction(); ReportedTransactions = CleanNonTransactional(reportedTransaction.GetTransactions(BudgetItem)); List <ReportedTransaction> reportedTransactions = CleanNonTransactional(reportedTransaction.GetTransactions(BudgetItem)); List <BudgetTransaction> budgetTransactions = BudgetItem.BudgetTransactions.ToList(); List <TransactionComparison> transactionList = new List <TransactionComparison>(); foreach (BudgetTransaction item in BudgetItem.BudgetTransactions) { item.CFType = new CFType(item.CFTypeId); item.CFClassification = new CFClassification(item.CFClassificationId); double spent = ReportedTransactions .Where(x => x.CFType.Id == item.CFTypeId && x.CFClassification.Id == item.CFClassificationId) .Select(x => x.Amount) .Sum(); ReportedTransaction transaction = reportedTransactions.Where(x => x.CFType.Id == item.CFTypeId && x.CFClassification.Id == item.CFClassificationId).FirstOrDefault(); reportedTransactions.Remove(transaction); double budgeted = budgetTransactions .Where(x => x.CFClassificationId == item.CFClassificationId && x.CFTypeId == item.CFTypeId) .Select(x => x.Amount) .Sum(); transactionList .Add(new TransactionComparison(spent, budgeted, item)); } foreach (ReportedTransaction item in reportedTransactions) { item.CFType = item.CFType; item.CFClassification = item.CFClassification; double spent = ReportedTransactions .Where(x => x.CFType.Id == item.CFType.Id && x.CFClassification.Id == item.CFClassification.Id) .Select(x => x.Amount) .Sum(); transactionList .Add(new TransactionComparison(spent, 0, item)); } TransactionComparisons = transactionList .GroupBy(p => new { p.CFClassificationId, p.CFTypeId }) .Select(g => g.First()) .ToList(); }
/// <summary> /// Amount that has actually been spent under the current period for a given collection /// </summary> /// <param name="collectionsId">Unique Id of a collection</param> /// <returns>The amount that has been spent in the current budgeting period (Total Actual Expenses)</returns> public double GetSpentAmount(string collectionsId) { try { Budget budget = GetBudgetNew(collectionsId); ReportedTransaction transaction = new ReportedTransaction(); //CFType type = new CFType(); //type = type.GetCFList(collectionsId).Where(x => x.Id == "999").FirstOrDefault(); List <ReportedTransaction> transactions = transaction.GetTransactions(budget); return(transactions .Where(x => x.CFClassification.Sign == -1) .Where(x => x.CFType.Id != "999") .Select(x => x.Amount) .Sum()); } catch { return(0); } }
public void GetTransactions() { ReportedTransaction reportedTransaction = new ReportedTransaction(); this.ReportedTransactions = reportedTransaction.GetTransactions(this.Id); }