예제 #1
0
		public bool isOutLimitBudget (Category Cat) {
			return (getTransactsValuesThisMonth (Cat) > getBudgetValue (Cat)) && (getBudgetByCategoryId (Cat.Id) != null);
		}
예제 #2
0
		public double getBudgetValue(Category Cat) {
			Budget MyBudget = getBudgetByCategoryId (Cat.Id);
			if (MyBudget != null)
				return MyBudget.Value;
			else
				return 0;
		}
예제 #3
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;
		}
예제 #4
0
		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 ("****************************************************");
		}
예제 #5
0
		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 ();
		}
예제 #6
0
		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);
		}
예제 #7
0
		public void UpdateBudget(Category Cat) {
			Console.WriteLine ("Do you want to update the budget for the '"+Cat.Name+"' category ? (y/n)");
			ManageBudget (Cat.Id);
		}
예제 #8
0
		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 !");
		}