Ejemplo n.º 1
0
        public ImportBatch CreateImportBatch(Account account, Stream input)
        {
            if (_fileHandler == null)
            {
                throw new ApplicationException("No file handler in transaction import");
            }

            if (_parser == null)
            {
                throw new ApplicationException("No parser in transaction import");
            }

            if (_matcher == null)
            {
                throw new ApplicationException("No transaction matcher in transaction import");
            }

            var batch = new ImportBatch()
                            {
                                Id = Guid.Empty,
                                DateImported = DateTime.Now,
                                AccountId = account.Id,
                                // Transactions = new List<ImportedTransaction>()
                            };

            try
            {
                batch.Transactions = new List<ImportedTransaction>(
                        _matcher.Match(
                            _parser.Parse(
                                _fileHandler.GetImportRecords(input,
                                    (s) => !MatchSuncorpHeaders(s)
                                )
                            )
                        , account.Transactions)
                    );
            }
            catch (Exception)
            {
                throw;
            }

            return batch;
        }
Ejemplo n.º 2
0
 public bool SetBatch(ImportBatch batch)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 3
0
 public bool SetBatch(ImportBatch batch)
 {
     return ImportBatches.Save(batch, SafeMode.True).Ok;
 }
Ejemplo n.º 4
0
 public bool CreateBatch(ImportBatch batch)
 {
     foreach (var t in batch.Transactions)
     {
         if (t.Id == Guid.Empty)
         {
             t.Id = Guid.NewGuid();
         }
     }
     return ImportBatches.Insert(batch, SafeMode.True).Ok;
 }