Exemplo n.º 1
0
 private void InitializeListsForCombobox()
 {
     CurrencyList  = Enum.GetValues(typeof(CurrencyCodes)).OfType <CurrencyCodes>().ToList();
     BankAccounts  = _db.FlattenAccounts().Where(a => a.Is("Банки") && a.Children.Count == 0).ToList();
     MyFolders     = _db.FlattenAccounts().Where(a => a.Is("Мои") && a.IsFolder).ToList();
     DepositOffers = _db.BankDepositOffers.ToList();
 }
Exemplo n.º 2
0
 private void InitializeListsForCombobox()
 {
     CurrencyList = Enum.GetValues(typeof(CurrencyCodes)).OfType <CurrencyCodes>().ToList();
     BankAccounts =
         (_db.FlattenAccounts().Where(
              account => account.Is("Банки") && account.Children.Count == 0)).ToList();
 }
Exemplo n.º 3
0
        public RegularPaymentsViewModel(RegularPaymentsProvider provider, KeeperDb db)
        {
            _provider = provider;
            _db       = db;

            CurrencyList = Enum.GetValues(typeof(CurrencyCodes)).OfType <CurrencyCodes>().ToList();
            ArticleList  = new List <string>();
            var accounts = _db.FlattenAccounts().Where(a => a.Is("Все доходы") || a.Is("Все расходы")).ToList();

            foreach (var account in accounts)
            {
                ArticleList.Add(account.Name);
            }
        }
Exemplo n.º 4
0
        public DbLoadResult LoadDbFromTxt(string path)
        {
            var db = new KeeperDb {
                Accounts = LoadAccounts(path)
            };
//            var accountsPlaneList = _accountTreeStraightener.Flatten(db.Accounts).ToList();
            var accountsPlaneList = db.FlattenAccounts().ToList();

            db.BankDepositOffers = LoadFrom(path, "BankDepositOffers.txt",
                                            _dbClassesInstanceParser.BankDepositOfferFromString, accountsPlaneList);
            if (Result != null)
            {
                return(Result);
            }
            LoadDepositOffersRates(path, db.BankDepositOffers.ToList());
            LoadDeposits(path, accountsPlaneList, db.BankDepositOffers.ToList());
            if (Result != null)
            {
                return(Result);
            }
            db.TransWithTags = LoadFrom(path, "TransWithTags.txt",
                                        _dbClassesInstanceParser.TranWithTagsFromString, accountsPlaneList);
            if (Result != null)
            {
                return(Result);
            }
            db.ArticlesAssociations = LoadFrom(path, "ArticlesAssociations.txt",
                                               _dbClassesInstanceParser.ArticleAssociationFromStringWithNames, accountsPlaneList);
            if (Result != null)
            {
                return(Result);
            }
            db.CurrencyRates = LoadFrom(path, "CurrencyRates.txt",
                                        _dbClassesInstanceParser.CurrencyRateFromString, accountsPlaneList);
            if (Result != null)
            {
                return(Result);
            }
            db.OfficialRates = LoadFrom(path, "OfficialRates.txt",
                                        _dbClassesInstanceParser.OfficialRateFromString, accountsPlaneList);
            if (Result != null)
            {
                return(Result);
            }
            return(new DbLoadResult(db));
        }
Exemplo n.º 5
0
        public DepositsViewModel(KeeperDb db, RateExtractor rateExtractor,
                                 DepositCalculationAggregator depositCalculatorAggregator,
                                 OldRatesDiagramDataExtractor oldRatesDiagramDataExtractor)
        {
            var sw = new Stopwatch();

            Console.WriteLine("DepositViewModel ctor starts {0}", sw.Elapsed);
            sw.Start();

            _db            = db;
            _rateExtractor = rateExtractor;
            _depositCalculatorAggregator  = depositCalculatorAggregator;
            _oldRatesDiagramDataExtractor = oldRatesDiagramDataExtractor;

            MyTitleStyle = new Style();

            DepositList = new List <Deposit>();
            foreach (var account in _db.FlattenAccounts())
            {
                if (!account.Is("Депозиты") || account.Children.Count != 0 || !account.IsDeposit())
                {
                    continue;
                }
                _depositCalculatorAggregator.FillinFieldsForOneDepositReport(account.Deposit);
                DepositList.Add(account.Deposit);
            }
            SelectedDeposit = DepositList[0];

            UpperRow    = new GridLength(1, GridUnitType.Star);
            LowerRow    = new GridLength(1, GridUnitType.Star);
            LeftColumn  = new GridLength(1, GridUnitType.Star);
            RightColumn = new GridLength(1, GridUnitType.Star);

            DepoCurrenciesProportionChartCtor();
            Console.WriteLine("DepositViewModel ctor 1 {0}", sw.Elapsed);
            YearsProfitCtor();
            Console.WriteLine("DepositViewModel ctor 2 {0}", sw.Elapsed);
            TotalBalancesCtor();
            Console.WriteLine("DepositViewModel ctor 3 {0}", sw.Elapsed);
//            CashDepoProportionChartCtor();

            sw.Stop();
            Console.WriteLine("DepositViewModel ctor takes {0}", sw.Elapsed);
        }
Exemplo n.º 6
0
 public List <Account> GetExpenseArticles()
 {
     return(_db.FlattenAccounts().
            Where(account => account.Is("Все расходы") && account.Children.Count == 0).ToList());
 }
Exemplo n.º 7
0
 public static Account SeekAccount(this KeeperDb db, string name)
 {
     return(db.FlattenAccounts().FirstOrDefault(a => a.Name == name));
 }
Exemplo n.º 8
0
 public int GenerateAccountId()
 {
     return((from account in _db.FlattenAccounts()
             select account.Id).Max() + 1);
 }