Example #1
0
        protected TransactionLineInfo ExtractTransactionLineInfo(string line)
        {
            LineProcessor processor        = new LineProcessor(line);
            Match         matchAmount      = processor.MatchAndRemove(regexAmount);
            Match         matchDate        = processor.MatchAndRemove(regexDate);
            Match         matchDescription = processor.MatchAndRemove(regexDescription);

            string   description     = matchDescription.Success ? matchDescription.Value : throw new ArgumentException("line.Description");
            decimal  amount          = matchAmount.Success ? decimal.Parse(matchAmount.Value, new CultureInfo("pt-BR")) : throw new ArgumentException("line.Amount");
            DateTime transactionDate = matchDate.Success ? ParseDate(matchDate.Value) : throw new ArgumentException("line.TransactionDate");

            if (IsNegativeAmount(line))
            {
                amount *= -1;
            }

            return(new TransactionLineInfo(transactionDate, amount, description));
        }