An expense line in a budget. Created by the user to represent an expense line in a budget with an amount and bucket classification.
Inheritance: BudgetItem, IModelValidate
        /// <summary>
        ///     Prepares the expense graph data.
        /// </summary>
        public IDictionary<string, decimal> PrepareExpenseGraphData([NotNull] BudgetModel budget)
        {
            if (budget == null)
            {
                throw new ArgumentNullException(nameof(budget));
            }

            var surplus = new Expense { Amount = budget.Surplus, Bucket = this.budgetBucketRepository.SurplusBucket };
            List<KeyValuePair<string, decimal>> interim =
                budget.Expenses.Select(expense => new KeyValuePair<string, decimal>(expense.Bucket.Code, expense.Amount))
                    .ToList();
            interim.Add(new KeyValuePair<string, decimal>(surplus.Bucket.Code, surplus.Amount));
            return interim.OrderByDescending(x => x.Value).ToDictionary(e => e.Key, e => e.Value);
        }
Exemplo n.º 2
0
        public void Load([NotNull] BudgetModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            this.surplus = this.budgetPieService.SurplusExpense(model);
            this.budgetModel = model;
            ExpensePieChartValues = this.budgetPieService.PrepareExpenseGraphData(model);
            IncomePieChartValues = this.budgetPieService.PrepareIncomeGraphData(model);

            Shown = true;
            RaisePropertyChanged(() => ExpensePieChartValues);
            RaisePropertyChanged(() => IncomePieChartValues);
        }
Exemplo n.º 3
0
 public void Close()
 {
     Shown = false;
     this.budgetModel = null;
     CurrentExpense = null;
     CurrentIncome = null;
     this.surplus = null;
     ExpensePieChartValues = null;
     IncomePieChartValues = null;
 }
        public void Load([NotNull] BudgetModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            this.budgetModel = model;
            this.surplus = new Expense { Amount = model.Surplus, Bucket = this.budgetBucketRepository.SurplusBucket };
            List<KeyValuePair<string, decimal>> list =
                model.Expenses.Select(expense => new KeyValuePair<string, decimal>(expense.Bucket.Code, expense.Amount))
                    .ToList();
            list.Add(new KeyValuePair<string, decimal>(this.budgetBucketRepository.SurplusBucket.Code, model.Surplus));
            ExpensePieChartValues = list.OrderByDescending(x => x.Value).ToList();

            list =
                model.Incomes.Select(income => new KeyValuePair<string, decimal>(income.Bucket.Code, income.Amount))
                    .ToList();
            IncomePieChartValues = list.OrderByDescending(x => x.Value).ToList();

            Shown = true;
            RaisePropertyChanged(() => ExpensePieChartValues);
            RaisePropertyChanged(() => IncomePieChartValues);
        }