Пример #1
0
        public IEnumerable <TraceableExpense> GetMonthlyExpenses()
        {
            List <Expense>          expenses  = ExpenseClass.Instance().ParseExpenses();
            List <TraceableExpense> tExpenses = new List <TraceableExpense>();

            foreach (Expense expense in expenses)
            {
                TraceableExpense tExpense = new TraceableExpense()
                {
                    amount = expense.amount,
                    year   = expense.expenseDate.Year,
                    month  = expense.expenseDate.Month,
                    dateID = (expense.expenseDate.Year * 100) + expense.expenseDate.Month
                };
                tExpenses.Add(tExpense);
            }
            var traceableExpenses = from expense in tExpenses
                                    group expense.amount by expense.dateID into expenseGroup
                                    select new TraceableExpense
            {
                dateID = expenseGroup.Key,
                amount = expenseGroup.Sum(),
                month  = expenseGroup.Key % 100,
                year   = expenseGroup.Key / 100
            };

            return(traceableExpenses.ToList <TraceableExpense>());
        }
Пример #2
0
        public IEnumerable <TraceableBalance> GetMonthlyBalances() //Gets list of every year-month balances
        {
            List <TraceableIncome>  tIncomes  = (List <TraceableIncome>)IncomeClass.Instance().GetMonthlyIncomes();
            List <TraceableExpense> tExpenses = (List <TraceableExpense>)ExpenseClass.Instance().GetMonthlyExpenses();
            List <TraceableBalance> tBalances = new List <TraceableBalance>();

            for (int i = 0; i < tIncomes.Count; i++)
            {
                if (tIncomes[i].dateID == tExpenses[i].dateID)
                {
                    TraceableBalance tBalance = new TraceableBalance()
                    {
                        amount = tIncomes[i].amount - tExpenses[i].amount,
                        year   = tIncomes[i].year,
                        month  = tIncomes[i].month,
                        dateID = tIncomes[i].dateID
                    };
                    tBalances.Add(tBalance);
                }
                else
                {
                    throw new Exception("Balances cannot be calculated because of missing income or expense data, or errors in parsing data");
                }
            }
            return(tBalances);
        }
Пример #3
0
        private string ChartRepresenation(string _write)
        {
            List <ExpenseClass.Expense> _expenses = ExpenseClass.Instance().ParseExpenses();
            List <IncomeClass.Income>   _incomes  = IncomeClass.Instance().ParseIncomes();
            var expenses = Expenses(_expenses);
            var incomes  = Incomes(_incomes);

            if (expenses.Count() == incomes.Count())
            {
                _write = CalculateEqual(expenses, incomes, _write);
            }
            else if (incomes.Count() > expenses.Count())
            {
                _write = CalculateIncomeMore(expenses, incomes, _write);
            }
            else
            {
                _write = CalculateExpenseMore(expenses, incomes, _write);
            }
            return(_write);
        }
Пример #4
0
 public decimal GetMonthlyBalance()
 {
     return(IncomeClass.Instance().MonthlyIncome() - ExpenseClass.Instance().MonthlyExpenses());
 }
Пример #5
0
        /*-----------------------------------------------------------------------------------------
         * Savings Deposit Representation
         * ------------------------------------------------------------------------------------------*/

        public decimal GetMonthlyExpenses()
        {
            return(ExpenseClass.Instance().MonthlyExpenses());
        }