Ejemplo n.º 1
0
        private bool CheckExpensePayment(Saldo s, RegularPayment payment)
        {
            var paymentArticle = _db.SeekAccount(payment.Article);

            return((from tr in _db.TransWithTags
                    where tr.Timestamp.IsMonthTheSame(s.StartDate) &&
                    tr.Tags != null &&
                    tr.Tags.Contains(paymentArticle)
                    select tr).FirstOrDefault() != null);
        }
        public DiagramData MonthlyIncomesDiagramCtor()
        {
            var categoriesList = new List <Account>
            {
                _db.SeekAccount("Зарплата"),
                _db.SeekAccount("Иррациональные"),
                _db.SeekAccount("Рента"),
                _db.SeekAccount("Подарки"),
            };

            var colors = new List <Brush> {
                Brushes.Green, Brushes.DarkGray, Brushes.Blue, Brushes.DarkOrange
            };
            var colorsEnumerator = colors.GetEnumerator();

            var data = _categoriesDataExtractor.GetGrouppedByMonth(true);

            var dataForDiagram = GroupByCategories(categoriesList, colorsEnumerator, data, 1);

            return(new DiagramData
            {
                Caption = "Ежемесячные доходы (только основные категории)",
                Series = dataForDiagram,
                Mode = DiagramMode.BarVertical,
                TimeInterval = Every.Month
            });
        }
Ejemplo n.º 3
0
        public void AddSelectedDeposit()
        {
            var newSelectedAccount = _accountTreesGardener.AddDeposit(MyForestModel.SelectedAccount);

            if (newSelectedAccount == null)
            {
                return;
            }
            _accountLowLevelOperator.SortDepositAccounts(_db.SeekAccount("Депозиты"));
            MyForestModel.SelectedAccount.IsSelected = false;
            MyForestModel.SelectedAccount            = newSelectedAccount;
            MyForestModel.SelectedAccount.IsSelected = true;
            NotifyOfPropertyChange(() => MyForestModel.MineAccountsRoot);
        }
Ejemplo n.º 4
0
        private void ReactOnUsersAdd()
        {
            var tag = _db.SeekAccount(MyTagPickerVm.TagInWork.Name);

            TranInWork.Tags.Add(tag);

            var associatedTag = _associationFinder.GetAssociation(TranInWork, tag);

            if (associatedTag != null)
            {
                MyTagPickerVm.AssociatedTag = new AccName().PopulateFromAccount(associatedTag, null);
            }

            MyTagPickerVm.TagInWork = null;
        }
        /// <summary>
        /// довольно медленно
        /// может _ratesAsDictionary позволит ускорить?
        /// </summary>
        /// <param name="frequency"></param>
        /// <returns></returns>
        public List <DiagramPoint> GetBalances(Every frequency)
        {
            var root            = _db.SeekAccount("Мои");
            var result          = new List <DiagramPoint>();
            var currentDate     = new DateTime(2001, 12, 31); // считать надо всегда с самого начала, иначе остаток неправильный будет
            var currentMoneyBag = new MoneyBag();

            foreach (var tran in _db.TransWithTags)
            {
                while (currentDate < tran.Timestamp.Date)
                {
                    if (FunctionsWithEvery.IsLastDayOf(currentDate, frequency))
                    {
                        var sum = _rateExtractor.GetUsdEquivalent(currentMoneyBag, tran.Timestamp.Date);
                        if (sum != 0) // если вернулся 0 - это гэпы без курсов в начале времен
                        {
                            result.Add(new DiagramPoint(currentDate, (double)sum));
                        }
                        else
                        {
                            var lastSum = result.Last().CoorYdouble;
                            result.Add(new DiagramPoint(currentDate, lastSum));
                        }
                    }
                    currentDate = currentDate.AddDays(1);
                }
                currentMoneyBag = currentMoneyBag + tran.MoneyBagForAccount(root);
            }
            result.Add(new DiagramPoint(currentDate, (double)_rateExtractor.GetUsdEquivalent(currentMoneyBag, currentDate)));
            return(result);
        }
Ejemplo n.º 6
0
        public List <Account> GetExternalAccounts()
        {
            var result = _db.FlattenAccounts().
                         Where(account => account.Is("Внешние") && account.Children.Count == 0).ToList();

            result.Add(_db.SeekAccount("Банки"));
            return(result);
        }
Ejemplo n.º 7
0
        private void InitializeListForFilterTags()
        {
            // All Tags
            AccNamesForFilterTags = new List <AccName>();
            var list = new List <string>()
            {
                "Внешние", "Все доходы", "Все расходы"
            };

            foreach (var element in list)
            {
                var root = new AccName().PopulateFromAccount(_db.SeekAccount(element), null);
                AccNamesForFilterTags.Add(root);
            }
        }
Ejemplo n.º 8
0
 private void ValidateTranInWorkFieldsWithNewOperationType()
 {
     TranInWork.Tags.Clear();
     if (TranInWork.MySecondAccount == null && TranInWork.Operation == OperationType.Перенос)
     {
         TranInWork.MySecondAccount = _db.SeekAccount("Юлин кошелек");
     }
     if (TranInWork.CurrencyInReturn == null)
     {
         TranInWork.CurrencyInReturn = (TranInWork.Currency == CurrencyCodes.BYN) ? CurrencyCodes.USD : CurrencyCodes.BYN;
     }
 }
Ejemplo n.º 9
0
        public ExtendedBalance GetExtendedBalanceBeforeDate(DateTime someDate)
        {
            var period = new Period(new DateTime(1, 1, 1), someDate.AddMinutes(-1));

            var allMine         = _db.SeekAccount("Мои");
            var allMineBalance  = _db.TransWithTags.Sum(t => t.MoneyBagForAccount(allMine, period));
            var cards           = _db.SeekAccount("Карточки");
            var cardsBalance    = _db.TransWithTags.Sum(t => t.MoneyBagForAccount(cards, period));
            var deposits        = _db.SeekAccount("Депозиты");
            var depositsBalance = _db.TransWithTags.Sum(t => t.MoneyBagForAccount(deposits, period));


            var result = new ExtendedBalance();

            result.Common.MoneyBag       = allMineBalance;
            result.Common.TotalInUsd     = _rateExtractor.GetUsdEquivalent(allMineBalance, someDate);
            result.OnDeposits.MoneyBag   = cardsBalance + depositsBalance;
            result.OnDeposits.TotalInUsd = _rateExtractor.GetUsdEquivalent(result.OnDeposits.MoneyBag, someDate);
            result.OnHands.MoneyBag      = allMineBalance - result.OnDeposits.MoneyBag;
            result.OnHands.TotalInUsd    = _rateExtractor.GetUsdEquivalent(result.OnHands.MoneyBag, someDate);
            return(result);
        }
Ejemplo n.º 10
0
 public FilterModel(KeeperDb db, AccNameSelectionControlInitializer accNameSelectionControlInitializer)
 {
     AvailableAccNames = new List <AccName>
     {
         new AccName().PopulateFromAccount(db.SeekAccount("Мои"), new List <string>())
     };
     IsAccNamePosition12  = true;
     AmountEqualTo        = true;
     IsCurrencyPosition12 = true;
     MyTagPickerVm        = new TagPickerVm {
         TagSelectorVm = accNameSelectionControlInitializer.ForFilter(), Tags = MyTags
     };
     IsTagsJoinedByAnd = true;
     CleanAll();
     MyTags.CollectionChanged += MyTags_CollectionChanged;
 }