Beispiel #1
0
        public static IEnumerable <Entry> ConvertToEntries(this IEnumerable <QIFTransaction> transactions)
        {
            var contentTypes = QIFContentType.GetAll().ToList();

            foreach (var transaction in transactions)
            {
                var entry = new Entry
                {
                    IsHeader        = transaction.Records.Any(x => x.RecordType.IsHeader),
                    IsAccountHeader = transaction.Records.Any(x => x.RecordType == QIFRecordType.AccountHeader)
                };

                foreach (var record in transaction.Records.Where(x => x.RecordType == QIFRecordType.Content))
                {
                    var record1     = record;
                    var contentType = contentTypes.FirstOrDefault(x => x.IsMatch(entry, record1));
                    if (contentType == null)
                    {
                        throw new ArgumentException("Don't know how to handle: " + record1.Data);
                    }
                    try
                    {
                        contentType.Update(entry, record1);
                    }
                    catch (Exception e)
                    {
                        throw new ArgumentException("Unable to convert the following to a value on Entry: " + record1.Data, e);
                    }
                }
                yield return(entry);
            }
        }
Beispiel #2
0
                public void Before_first_test()
                {
                    _record = new QIFRecord(QIFRecordType.Content, Input);

                    _entry       = new Entry();
                    _contentType = QIFContentType.Amount;
                }
Beispiel #3
0
 public void Before_first_test()
 {
     _record = new QIFRecord(QIFRecordType.Content, Input);
     _entry  = new Entry
     {
         IsAccountHeader = true
     };
     _contentType = QIFContentType.AccountName;
 }
Beispiel #4
0
 public void Before_first_test()
 {
     _record = new QIFRecord(QIFRecordType.Content, Input);
     _entry  = new Entry
     {
         IsAccountHeader = false
     };
     _contentType = QIFContentType.ItemDescription;
 }
 public void Before_first_test()
 {
     _record = new QIFRecord(QIFRecordType.Content, Input);
     _entry = new Entry
         {
             IsAccountHeader = true
         };
     _contentType = QIFContentType.AccountName;
 }
                public void Before_first_test()
                {
                    _record = new QIFRecord(QIFRecordType.Content, Input);

                    _entry = new Entry();
                    _contentType = QIFContentType.TransferAmount;
                }
                public void Before_first_test()
                {
                    _record = new QIFRecord(QIFRecordType.Content, Input);

                    _entry = new Entry();
                    _contentType = QIFContentType.Quantity;
                }
 public void Before_first_test()
 {
     _record = new QIFRecord(QIFRecordType.Content, Input);
     _entry = new Entry
         {
             IsAccountHeader = false
         };
     _contentType = QIFContentType.ItemDescription;
 }
                public void Before_first_test()
                {
                    _record = new QIFRecord(QIFRecordType.Content, Input);

                    _entry = new Entry();
                    _contentType = QIFContentType.ClearedStatus;
                }