public bool isOutLimitBudget (Category Cat) { return (getTransactsValuesThisMonth (Cat) > getBudgetValue (Cat)) && (getBudgetByCategoryId (Cat.Id) != null); }
public double getBudgetValue(Category Cat) { Budget MyBudget = getBudgetByCategoryId (Cat.Id); if (MyBudget != null) return MyBudget.Value; else return 0; }
public double getTransactsValuesThisMonth(Category Cat) { List<Transact> transacts = getAllExpensesBySubCategoryThisMonth (Cat.Id); double total = 0; foreach (Transact t in transacts) { total += t.Amount; } return total; }
public void PrintBudget(Category Cat) { Budget MyBudget = getBudgetByCategoryId (Cat.Id); Console.WriteLine ("****************************************************"); if (MyBudget != null) { Console.WriteLine ("** Budget for '" + Cat.Name + "' category : " + MyBudget.Value * Currency.ValueCAN + " " + Currency.Symbole); Console.WriteLine ("** Total expenses for this category this month : " + getTransactsValuesThisMonth (Cat) * Currency.ValueCAN + " " + Currency.Symbole + " (" + Math.Round (100 * getTransactsValuesThisMonth (Cat) / MyBudget.Value, MidpointRounding.AwayFromZero) + "% of the budget)"); if (isOutLimitBudget (Cat)) Console.WriteLine ("** You exceed the limits for this category !"); } else Console.WriteLine ("** No budget."); Console.WriteLine ("****************************************************"); }
public void RemoveSubCategory(Category Cat) { List<string> listSubCategoriesnew = new List<string> (SubCategories.Split (new char[] { '-' })); listSubCategoriesnew.Remove (Cat.Id.ToString()); SubCategories = string.Join("-", listSubCategoriesnew); removeBudgetBySubCategoryId (Cat.Id); Synchronize (); }
public void AddSubCategory(Category Cat) { if (SubCategories.Length <= 0) { SubCategories = Cat.Id.ToString (); } else { SubCategories = SubCategories + "-" + Cat.Id.ToString (); } Synchronize (); Console.WriteLine ("Do you want to create a budget for the '"+Cat.Name+"' category ? (y/n)"); ManageBudget (Cat.Id); }
public void UpdateBudget(Category Cat) { Console.WriteLine ("Do you want to update the budget for the '"+Cat.Name+"' category ? (y/n)"); ManageBudget (Cat.Id); }
public void AddTransact(Category subCategoryT,string descriptionT,DateTime dateT,double amountT, bool expenseT) { new Transact (subCategoryT.Id,descriptionT,dateT,amountT/Currency.ValueCAN,Id,expenseT); if (isOutLimitBudget()) Console.WriteLine("You exceed the limits for the month !"); if (isOutLimitBudget(subCategoryT)) Console.WriteLine("You exceed the limits for the '"+subCategoryT.Name+"' category !"); }