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

            Assert.That(category.MainCategory, Is.EqualTo("Utilities"));
            Assert.That(category.SubCategory, Is.EqualTo(""));
        }
Esempio n. 2
0
 public BudgetEntry(double amount, string label, BudgetType budgetType)
 {
     Amount        = amount;
     this.Label    = label;
     BudgetType    = budgetType;
     this.Category = BudgetCategoryFactory.GetBudgetCategory(budgetType);
 }
Esempio n. 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"));
        }
Esempio n. 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;
         }
     }
 }
Esempio n. 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);
        }
Esempio n. 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);
            }
        }
Esempio n. 7
0
 public void IsIncomeWorks()
 {
     Assert.That(BudgetCategory.IsIncome(BudgetType.Income_Misc), Is.True);
     Assert.That(BudgetCategory.IsIncome(BudgetType.Auto_Gas), Is.False);
 }
Esempio n. 8
0
 public BudgetEntryDto(BudgetEntry budgetEntry)
 {
     Amount   = budgetEntry.Amount;
     Label    = budgetEntry.Label;
     Category = budgetEntry.Category;
 }