示例#1
0
        void ExecuteLoadIncomesCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Incomes.Clear();
                var incomes = DataStore.Get(true).OrderByDescending(x => x.Date);
                foreach (var item in incomes)
                {
                    item.BackgroundColor = Color.FromRgb(104, 222, 45);
                    Incomes.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
        /// <summary>
        /// Добавить доход.
        /// </summary>
        /// <param name="spendingName">Название дохода.</param>
        /// <param name="amount">Объем дохода.</param>
        /// <param name="category">Категория дохода.</param>
        /// <param name="comment">Комментарий к доходу.</param>
        public void AddIncome(string incomeName, double amount, string category, string comment)
        {
            var income = new Income(incomeName, amount, category, comment);

            Incomes.Add(income);
            this.CurrentAccount.AccountBalance += amount;
            SaveData(income);
        }
示例#3
0
    public void AddIncome(int[] ids, double[] valuesOnEachPurse, string title, double value, char curency)
    {
        incomes.Add(ids, valuesOnEachPurse, title, value, curency);
        amountControl.Add("Income", curency, value, true);
        int index = incomes.Titles.Count - 1;

        incomeControl.Render(ids, valuesOnEachPurse, title, value, curency, DateTime.Parse(incomes.CreateDates[index]), index);
        StartCoroutine(incomeControl.UpdateContentHeight());
    }
        private void OnAddNewIncomeExecute()
        {
            Dirty = true;
            var newIncome = new Income {
                Bucket = new IncomeBudgetBucket(string.Empty, string.Empty), Amount = 0
            };

            Incomes.Add(newIncome);
            newIncome.PropertyChanged += OnIncomeAmountPropertyChanged;
        }
示例#5
0
        public void Add(Income incomeName, double amount)
        {
            var cost = Incomes.Keys.FirstOrDefault(c => c.Name.Equals(incomeName));

            if (cost == null)
            {
                Incomes.Add(incomeName, amount);
            }
            else
            {
                Incomes[cost] += amount;
            }
        }
示例#6
0
        public HoldingPeriodReturn(IEnumerable <Tuple <DateTime, DateTime> > periods, IEnumerable <Tuple <decimal, DateTime> > incomes)
        {
            foreach (var period in periods)
            {
                var addedPeriod = ReturnCalculationPeriod.Build(period.Item1, period.Item2, Id);
                Periods.Add(addedPeriod);
            }

            foreach (var income in incomes)
            {
                var addedIncome = ReturnIncome.Build(income.Item1, income.Item2, Id);
                Incomes.Add(addedIncome);
            }
        }
示例#7
0
        /// <summary>
        /// Метод добавления строки доходов.
        /// </summary>
        private void Add(object param)
        {
            CurrentIncomeExpenses = new IncomeExpenses();

            var MaxId = Incomes.Count;

            CurrentIncomeExpenses.Title = "NewTitle" + (MaxId + 1);

            Incomes.Add(CurrentIncomeExpenses);

            Save(CURRENT_PATH_INCOME, Incomes);

            Refresh();
        }
        public void Add(Income income, double amount)
        {
            var costs = Incomes.SingleOrDefault(c => c.Name == income.Name);

            if (costs == null)
            {
                Incomes.Add(income);
            }
            IncomeList.Add(income, amount);
            Save(Incomes);
            Save(new List <IncomeList>()
            {
                IncomeList
            });
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="periods"></param>
        /// <param name="incomes"></param>
        public HoldingPeriodReturn(IEnumerable <Tuple <DateTime, DateTime> > periods, IEnumerable <Tuple <decimal, DateTime> > incomes)
        {
            foreach (var period in periods)
            {
                Periods.Add(new ReturnCalculationPeriod {
                    DateFrom = period.Item1, DateTo = period.Item2, ReturnId = this.Id
                });
            }

            foreach (var income in incomes)
            {
                Incomes.Add(new ReturnIncome {
                    Amount = income.Item1, Timestamp = income.Item2, ReturnId = this.Id
                });
            }
        }
示例#10
0
        protected override void When(object @event)
        {
            Income      income;
            Outgo       outgo;
            Snapshot    snapshot;
            Expenditure expenditure;

            switch (@event)
            {
            case Events.DailyBudgetCreated e:
                Id       = new DailyBudgetId(e.Id);
                Name     = new BudgetName(e.Name);
                snapshot = new Snapshot(Apply);
                ApplyToEntity(snapshot, e);
                Snapshot = snapshot;
                break;

            case Events.IncomeAddedToDailyBudget e:
                income = new Income(Apply);
                ApplyToEntity(income, e);
                Incomes.Add(income);
                e.TotalIncome = TotalIncome();
                ApplyToEntity(Snapshot, e);
                break;

            case Events.IncomeAmountChanged e:
                income = Incomes.FirstOrDefault(i => i.Id == e.IncomeId);
                if (income == null)
                {
                    throw new InvalidOperationException($"Income with id {e.IncomeId} not found");
                }
                ApplyToEntity(income, e);
                e.TotalIncome = TotalIncome();
                ApplyToEntity(Snapshot, e);
                break;

            case Events.IncomeDescriptionChanged e:
                income = Incomes.FirstOrDefault(i => i.Id == e.IncomeId);
                if (income == null)
                {
                    throw new InvalidOperationException($"Income with id {e.IncomeId} not found");
                }
                ApplyToEntity(income, e);
                break;

            case Events.IncomeRemoved e:
                income = Incomes.FirstOrDefault(i => i.Id == e.IncomeId);
                if (income == null)
                {
                    throw new InvalidOperationException($"Income with id {e.IncomeId} not found");
                }
                Incomes.Remove(income);
                e.TotalIncome = TotalIncome();
                ApplyToEntity(Snapshot, e);
                break;

            case Events.OutgoAddedToDailyBudget e:
                outgo = new Outgo(Apply);
                ApplyToEntity(outgo, e);
                Outgos.Add(outgo);
                e.TotalOutgo = TotalOutgo();
                ApplyToEntity(Snapshot, e);
                break;

            case Events.OutgoAmountChanged e:
                outgo = Outgos.FirstOrDefault(i => i.Id == e.OutgoId);
                if (outgo == null)
                {
                    throw new InvalidOperationException($"Outgo with id {e.OutgoId} not found");
                }
                ApplyToEntity(outgo, e);
                e.TotalOutgo = TotalOutgo();
                ApplyToEntity(Snapshot, e);
                break;

            case Events.OutgoDescriptionChanged e:
                outgo = Outgos.FirstOrDefault(i => i.Id == e.OutgoId);
                if (outgo == null)
                {
                    throw new InvalidOperationException($"Outgo with id {e.OutgoId} not found");
                }
                ApplyToEntity(outgo, e);
                break;

            case Events.OutgoRemoved e:
                outgo = Outgos.FirstOrDefault(o => o.Id == e.OutgoId);
                if (outgo == null)
                {
                    throw new InvalidOperationException($"Outgo with id {e.OutgoId} not found");
                }
                Outgos.Remove(outgo);
                e.TotalOutgo = TotalOutgo();
                ApplyToEntity(Snapshot, e);
                break;

            case Events.ExpenditureAdded e:
                expenditure = new Expenditure(Apply);
                ApplyToEntity(expenditure, e);
                Expenditures.Add(expenditure);
                e.TotalExpenditure = TotalExpenditure();
                ApplyToEntity(Snapshot, e);
                break;

            case Events.ExpenditureAmountChanged e:
                expenditure = Expenditures.FirstOrDefault(exp => exp.Id == e.ExpenditureId);
                if (expenditure == null)
                {
                    throw new InvalidOperationException($"Expenditure with id {e.ExpenditureId} not found");
                }
                ApplyToEntity(expenditure, e);
                e.TotalExpenditure = TotalExpenditure();
                ApplyToEntity(Snapshot, e);
                break;

            case Events.PeriodAddedToDailyBudget e:
                if (Period != null)
                {
                    throw new InvalidOperationException($"Period has already been set. Update start or end");
                }
                Period = Period.Create(e.Start, e.End);
                ApplyToEntity(Snapshot, e);
                break;

            case Events.PeriodStartChanged e:
                Period = Period.Create(e.Start, Period.ToB);
                ApplyToEntity(Snapshot, e);
                break;

            case Events.PeriodEndChanged e:
                Period = Period.Create(Period.FromA, e.End);
                ApplyToEntity(Snapshot, e);
                break;
            }
        }
 public void AddIncome(Income income)
 {
     Incomes.Add(income);
 }
示例#12
0
 private void Apply(IncomeRegistered evt)
 {
     Incomes.Add(new Income(evt.Value, evt.Description));
     Balance = evt.Balance;
 }
示例#13
0
        private void SetStat()
        {
            var fromTxt = dpFrom.Text;
            var toTxt   = dpTo.Text;

            if (fromTxt == "")
            {
                fromTxt = "1200-01-01";
            }

            if (toTxt == "")
            {
                toTxt = "3000-01-01";
            }

            var from = Convert.ToDateTime(fromTxt);
            var to   = Convert.ToDateTime(toTxt);

            var inc = Database.GetIncomes(from, to);
            var exp = Database.GetExpenses(from, to);

            Incomes.Clear();
            Expenses.Clear();

            decimal expenses = 0;
            decimal incomes  = 0;

            foreach (var el in exp)
            {
                Expenses.Add(el);
                expenses += el.Amount;
            }
            foreach (var el in inc)
            {
                Incomes.Add(el);
                incomes += el.Amount;
            }

            decimal profit = incomes - expenses;

            tblockIncome.Text       = incomes.ToString();
            tblockIncome.Foreground = Brushes.Green;

            tblockExpense.Text       = expenses.ToString();
            tblockExpense.Foreground = Brushes.Red;

            tbProfit.Text       = profit.ToString();
            tbProfit.Foreground = Brushes.Black;

            if (profit > 0)
            {
                tbProfit.Foreground = Brushes.Green;
                tbProfitName.Text   = "Прибыль";
            }

            if (profit < 0)
            {
                tbProfitName.Text   = "Убыток";
                tbProfit.Foreground = Brushes.Red;
            }
            if (profit == 0)
            {
                tbProfitName.Text   = "В ноль";
                tbProfit.Foreground = Brushes.Black;
            }
        }