public void CanParserItau() { var ofxFile = new FileStream(@"Files/itau.ofx", FileMode.Open); var ofxDocument = parser.Import(ofxFile); ofxDocument.Should().NotBeNull(); ofxDocument.StatementStart.Should().Be(DateTime.Parse("05/12/2013 00:00:00")); ofxDocument.StatementEnd.Should().Be(DateTime.Parse("28/02/2014 00:00:00")); ofxDocument.Account.AccountId.Trim().Should().Be("9999999999"); ofxDocument.Account.BankId.Trim().Should().Be("0341"); ofxDocument.Transactions.Count.Should().Be(3); ofxDocument.Transactions.Sum(x => x.Amount).Should().Be(-644.44M); }
public void CanParserSample2() { var parser = new OFXDocumentParser(); var ofxDocument = parser.Import(new FileStream(@"Sample2.ofx", FileMode.Open)); Assert.IsTrue(ofxDocument.Transactions.Count > 0); }
public void CanParserSantander() { var parser = new OFXDocumentParser(); var ofxDocument = parser.Import(new FileStream(@"santander.ofx", FileMode.Open)); Assert.IsNotNull(ofxDocument); }
public void CanParserItau() { var parser = new OFXDocumentParser(); var ofxDocument = parser.Import(new FileStream(@"itau.ofx", FileMode.Open)); Assert.AreEqual(3, ofxDocument.Transactions.Count); Assert.AreEqual(-666.66M, ofxDocument.Transactions.First().Amount); }
public void CanParserItau() { var parser = new OFXDocumentParser(); var ofxDocument = parser.Import(new FileStream(@"itau.ofx", FileMode.Open)); Assert.AreEqual(ofxDocument.Account.AccountID, "9999 99999-9"); Assert.AreEqual(ofxDocument.Account.BankID, "0341"); Assert.AreEqual(3, ofxDocument.Transactions.Count()); CollectionAssert.AreEqual(ofxDocument.Transactions.Select(x => x.Memo.Trim()).ToList(), new[] { "RSHOP", "REND PAGO APLIC AUT MAIS", "SISDEB" }); }
public void OFXCreditCardText() { string testFile = "creditcard.ofx"; var parser = new OFXDocumentParser(); var ofxDocument = parser.Import(new FileStream(testFile, FileMode.Open)); Assert.NotNull(ofxDocument); var balance = (CreditCardBalance)ofxDocument.Balance; Assert.NotNull(ofxDocument.Account.Transactions); Assert.True(ofxDocument.Account.Transactions.Count > 0); Console.WriteLine("Test finished"); }
public void OFXBankText() { string testFile = "santander.ofx"; var parser = new OFXDocumentParser(); var ofxDocument = parser.Import(new FileStream(testFile, FileMode.Open)); Assert.NotNull(ofxDocument); var balance = (BankBalance)ofxDocument.Balance; Assert.True(balance.LedgerBalance > 0); Assert.NotNull(ofxDocument.Account.Transactions); Assert.True(ofxDocument.Account.Transactions.Count > 0); Console.WriteLine("Test finished"); }
public void OFXInvestmentText() { //string testFile = "investment.ofx"; string testFile = "import.ofx"; var parser = new OFXDocumentParser(); var ofxDocument = parser.Import(new FileStream(testFile, FileMode.Open)); Assert.NotNull(ofxDocument); var balance = (InvestmentBalance)ofxDocument.Balance; Assert.True(balance.AvailableBalance > 0); Assert.NotNull(ofxDocument.Account.Transactions); Assert.True(ofxDocument.Account.Transactions.Count > 0); var account = (InvestmentAccount)ofxDocument.Account; Assert.NotNull(account.StockQuotes); Assert.True(account.StockQuotes.Count > 0); Console.WriteLine("Test finished"); }
public ActionResult Upload(HttpPostedFileBase file) { if (file != null && file.ContentLength > 0) { StreamReader reader = new StreamReader(file.InputStream, Encoding.Default); string strOFX = reader.ReadToEnd(); var parser = new OFXDocumentParser(); var ofxDocument = parser.Import(strOFX); context = new DALContext(); foreach (OFXSharp.Transaction item in ofxDocument.Transactions) { context.Transactions.Create(new Control.Model.Entities.Transaction { TransType = item.TransType.ToString(), Date = item.Date, Amount = item.Amount, TransactionID = item.TransactionID, Name = item.Name, // TransactionInitializationDate = null, // item.TransactionInitializationDate, //FundAvaliabilityDate = null, // item.FundAvaliabilityDate, Memo = item.Memo, IncorrectTransactionID = item.IncorrectTransactionID, TransactionCorrectionAction = item.TransactionCorrectionAction.ToString(), ServerTransactionID = item.ServerTransactionID, CheckNum = item.CheckNum, ReferenceNumber = item.ReferenceNumber, Sic = item.Sic, PayeeID = item.PayeeID, Currency = item.Currency }); } context.SaveChanges(); } return(RedirectToAction("ExtratoBancario")); }
public JsonResult ProcessarArquivo() { var model = new ArquivosBancarios(); if (Request.Files.Count > 0) { var file = Request.Files[0]; if (file != null && file.ContentLength > 0) { try { model.ds_arquivo = file.FileName; string lsArquivomd5 = file.FileName; string lsretornomd5 = CriarMD5.RetornarMD5(lsArquivomd5); var conta = new BaseID(); ArquivoMD5 md5 = DAL.GetObjeto <ArquivoMD5>(string.Format("arquivo_md5='{0}' and id_conta={1}", lsretornomd5, conta.IdConta)) ?? new ArquivoMD5(); if (Path.GetExtension(file.FileName).ToLower().Equals(".ofx")) { var parser = new OFXDocumentParser(); var ofxDocument = parser.Import(file.InputStream); var list = ofxDocument.Transactions.Select(item => new TransacaoBancaria { conta = ofxDocument.Account.AccountID, ds_historico = item.Memo, nr_doc = item.TransactionID, vl_mvto = item.Amount, tp_mvto = item.TransType.ToString(), dt_mvto = item.Date } ).Where(c => (c.tp_mvto.Substring(0, 1) == "C") || // CREDITO (c.tp_mvto.Substring(0, 1) == "O" && // OU OTHER E CONTEM A PALAVRA CARTAO c.ds_historico.Contains("CARTAO")) ).ToList(); model.ArquivoBancario = list; model.datainicio = ofxDocument.StatementStart; model.datafinal = ofxDocument.StatementEnd; } else { var arquivo = new ConciliacaoArquivoManipular(new StreamReader(file.InputStream)); String first_line = arquivo.LerLinha(true); var bancario = new ConciliacaoBancariaDesmontar(arquivo, first_line); model.ArquivoBancario = bancario.GetListTransacaoBancaria(); } if (md5.arquivo_md5.Equals("")) { md5.arquivo_md5 = lsretornomd5; DAL.GravarList(model.ArquivoBancario); DAL.Gravar(md5); } ViewBag.BotaoProcessar = "Gravar"; } catch (Exception ex) { this.AddNotification(ex.Message, NotificationType.Erro); } } } var result = Json(model, JsonRequestBehavior.AllowGet); result.MaxJsonLength = int.MaxValue; return(result); }
public void CanParserBradesco() { var parser = new OFXDocumentParser(); var ofxDocument = parser.Import(new FileStream(@"bradesco.ofx", FileMode.Open)); }
public void CanParserItau() { var parser = new OFXDocumentParser(); var ofxDocument = parser.Import(new FileStream(@"itau.ofx", FileMode.Open)); }