private void UpdateBalances()
 {
     Balances.Clear();
     if (SelectedTicket == null)
     {
         return;
     }
     foreach (var ticketEntity in SelectedTicket.TicketEntities)
     {
         if (ticketEntity.AccountId > 0)
         {
             var entityType = _cacheService.GetEntityTypeById(ticketEntity.EntityTypeId);
             if (_applicationState.GetPaymentScreenPaymentTypes().Any(x => x.AccountTransactionType.TargetAccountTypeId == entityType.AccountTypeId))
             {
                 var balance = _accountDao.GetAccountBalance(ticketEntity.AccountId);
                 balance +=
                     SelectedTicket.Payments.Where(
                         x =>
                         x.Id == 0 &&
                         x.AccountTransaction.AccountTransactionValues.Any(
                             y => y.AccountId == ticketEntity.AccountId)).Sum(x => x.Amount);
                 Balances.Add(ticketEntity.AccountId, balance);
             }
         }
     }
 }
 internal void UpdateData()
 {
     Balances.Clear();
     foreach (var balance in _dbWorker.GetBalances())
     {
         Balances.Add(new BalanceViewModel(balance));
     }
 }
 private void UpdateBalances()
 {
     Balances.Clear();
     foreach (var ticketEntity in SelectedTicket.TicketEntities)
     {
         if (ticketEntity.AccountId > 0)
         {
             var entityType = _cacheService.GetEntityTypeById(ticketEntity.EntityTypeId);
             if (_applicationState.GetPaymentScreenPaymentTypes().Any(x => x.AccountTransactionType.TargetAccountTypeId == entityType.AccountTypeId))
             {
                 var balance = _accountService.GetAccountBalance(ticketEntity.AccountId);
                 Balances.Add(ticketEntity.AccountId, balance);
             }
         }
     }
 }
        public Transaction[] Parse(string input, Stock userStock, Stock externalStock, TransactionType defaultOutcome,
                                   TransactionType defaultIncome, bool generateMissingStocks = false)
        {
            Balances.Clear();
            if (userStock != null)
            {
                Balances[userStock] = new Dictionary <DateTime, decimal>();
            }

            var output = new List <Transaction>();
            var lines  = input.Split(new[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries);

            foreach (string line in lines)
            {
                var elements = ColumnSplitter == null
                                   ? line.Count(x => x == ';') >= (Rules.Any() ? Rules.Max(x => x.Index) : 0)
                                         ? line.Split(';')
                                         : line.Split(new[] { line.Contains("\",\"") ? "\",\"" : "," }, StringSplitOptions.None)
                                   : line.Split(new[] { ColumnSplitter }, StringSplitOptions.None);

                elements = elements.Select(x => x.Replace("\"", string.Empty)).ToArray();
                var transaction = new Transaction
                {
                    ExternalStock = externalStock,
                    UserStock     = userStock
                };
                transaction.Positions.Add(new Position());

                bool match = Rules.Any();
                foreach (var rule in Rules)
                {
                    if (!MatchRule(rule, elements, transaction, defaultIncome, defaultOutcome, userStock, generateMissingStocks))
                    {
                        match = false;
                        break;
                    }
                }

                transaction.RecalculateId();
                if (match)
                {
                    output.Add(transaction);
                }
            }

            return(output.ToArray());
        }
        public Transaction[] Parse(string input, Stock userStock, Stock externalStock,
                                   TransactionType defaultOutcome, TransactionType defaultIncome, bool generateMissingStocks = false)
        {
            Balances.Clear();
            var output = new List <Transaction>();

            var regex = new Regex(RegexValue);

            foreach (Match match in regex.Matches(input))
            {
                output.Add(CreateTransaction(match, userStock, externalStock, defaultOutcome, defaultIncome));
            }

            ParseBalanceHelper.AdjustMissingBalances(output, Balances);

            return(output.ToArray());
        }