Beispiel #1
0
        private void AddCategoryTotalAmount(Dictionary <FinanceCategory, decimal> CategoryTotalAmount)
        {
            foreach (FinanceCategory financeCategory in CategoryTotalAmount.Keys)
            {
                CombinedCategoryTotalAmount[financeCategory] += CategoryTotalAmount[financeCategory];

                List <BudgetItem> searchResults = BudgetItemList.Where(budgetItem => budgetItem.Category == financeCategory).ToList();

                if (searchResults.Count > 0)
                {
                    BudgetItem budgetItem = null;
                    if (financeCategory == FinanceCategory.NoMatch)
                    {
                        List <BudgetItem> removeHeaders = searchResults.Where(searchResult => searchResult.Header == String.Empty).ToList();

                        if (removeHeaders.Count > 0)
                        {
                            budgetItem = removeHeaders[0];
                        }
                    }
                    else
                    {
                        budgetItem = searchResults[0];
                    }

                    if (budgetItem != null)
                    {
                        budgetItem.SpentAmount += CategoryTotalAmount[financeCategory];
                    }
                }
            }
        }
Beispiel #2
0
 public Budget(int id, string name, DateTime startDate, double startAmount, BudgetItemList budgetItems)
 {
     ID = id;
     Name = name;
     StartDate = startDate;
     StartAmount = startAmount;
     BudgetItems = budgetItems;
 }
Beispiel #3
0
        public static BudgetList GetBudgets()
        {
            // Retrieve the Budget records from the data store
            List<BudgetDetails> details = SiteProvider.Accounts.GetBudgets();
            BudgetList list = new BudgetList();

            // Copy from the Budget records to the Budget objects
            foreach (BudgetDetails bd in details)
            {
                if (bd != null)
                {
                    // Create the new Budget object from the Budget Details retrieved
                    // from the database.
                    Budget b = new Budget(bd);

                    // Retrieve the list of Budget Items for the specified Budget.
                    List<BudgetItemDetails> itemDetails = SiteProvider.Accounts.GetBudgetItems(bd.ID);
                    BudgetItemList items = new BudgetItemList();
                    foreach (BudgetItemDetails bid in itemDetails)
                    {
                        if (bid != null)
                        {
                            BudgetItem bi = new BudgetItem(bid);
                            bi.Budget = b;
                            if (bid.TagID != -1)
                                bi.Tag = KapitalManager.Instance.Tags.FindByID(bid.TagID);

                            // Add the Budget Item to the list of BudgetItems.
                            items.Add(bi);
                        }
                    }

                    // Attach the list of items to the current Budget
                    b.BudgetItems = items;
                    list.Add(b);
                }
            }

            return list;
        }
Beispiel #4
0
        public static BudgetItemList GetBudgetItems(int budgetID)
        {
            if (budgetID < 0)
                return null;

            List<BudgetItemDetails> details = SiteProvider.Accounts.GetBudgetItems(budgetID);
            if (details == null || details.Count == 0)
            {
                return null;
            }

            BudgetItemList budgetItems = new BudgetItemList();
            foreach (BudgetItemDetails bid in details)
            {
                if (bid == null)
                    continue;

                BudgetItem bi = new BudgetItem(bid);

                if (bid.TagID > 0)
                    bi.Tag = KapitalManager.Instance.Tags.FindByID(bid.TagID);

                bi.Budget = null;

                budgetItems.Add(bi);
            }

            return budgetItems;
        }