Example #1
0
        public void CanSupportCategoryWithNoSubCategory()
        {
            var category = new BudgetCategory(BudgetType.Utilities);

            Assert.That(category.MainCategory, Is.EqualTo("Utilities"));
            Assert.That(category.SubCategory, Is.EqualTo(""));
        }
Example #2
0
 public BudgetEntry(double amount, string label, BudgetType budgetType)
 {
     Amount        = amount;
     this.Label    = label;
     BudgetType    = budgetType;
     this.Category = BudgetCategoryFactory.GetBudgetCategory(budgetType);
 }
Example #3
0
        public void CanCreateSimpleBudgetCategory()
        {
            var category = new BudgetCategory(BudgetType.Utilities_Gas);

            Assert.That(category.MainCategory, Is.EqualTo("Utilities"));
            Assert.That(category.SubCategory, Is.EqualTo("Gas"));
        }
Example #4
0
 public void AddEntry(BudgetEntry budgetEntry)
 {
     BudgetEntries.Add(budgetEntry);
     for (int ii = 1; ii <= 12; ++ii)
     {
         var monthlyEntry = budgetEntry.GetMonthEntry(ii);
         if (BudgetCategory.IsIncome(budgetEntry.BudgetType))
         {
             _monthlyIncome[ii] += monthlyEntry;
             TotalIncome        += monthlyEntry;
         }
         else
         {
             _monthlyExpenses[ii] += monthlyEntry;
             TotalExpenses        += monthlyEntry;
         }
     }
 }
Example #5
0
        public Dictionary <string, double> GetReport(bool incomeDetails = true)
        {
            var report = new Dictionary <string, double>();

            foreach (var kvp in Entries)
            {
                var amount         = kvp.Value;
                var budgetCategory = new BudgetCategory(kvp.Key);

                if (budgetCategory.MainCategory == "Income" && incomeDetails)
                {
                    UpdateReport(report, amount, budgetCategory.MainCategory, budgetCategory.SubCategory);
                }
                else
                {
                    UpdateReport(report, amount, budgetCategory.MainCategory);
                }
            }
            return(report);
        }
Example #6
0
        internal void AddExpenditure(BudgetType type, double amount)
        {
            if (BudgetCategory.IsIncome(type))
            {
                Income += amount;
            }
            else
            {
                Expenses += amount;
            }

            if (Entries.ContainsKey(type))
            {
                Entries[type] += amount;
            }
            else
            {
                Entries.Add(type, amount);
            }
        }
Example #7
0
 public void IsIncomeWorks()
 {
     Assert.That(BudgetCategory.IsIncome(BudgetType.Income_Misc), Is.True);
     Assert.That(BudgetCategory.IsIncome(BudgetType.Auto_Gas), Is.False);
 }
Example #8
0
 public BudgetEntryDto(BudgetEntry budgetEntry)
 {
     Amount   = budgetEntry.Amount;
     Label    = budgetEntry.Label;
     Category = budgetEntry.Category;
 }