public void ShouldReadTransactionFile() { var importer = new TransactionImporter(); var transactions = importer.Read("InputFiles\\Transactions.txt").ToArray(); transactions.Length.ShouldEqual(3); transactions[0].Type.ShouldEqual(TransactionType.Deposit); transactions[0].Timestamp.ShouldEqual(new DateTime(2012, 2, 1, 13, 14, 25)); transactions[0].Account.ShouldEqual("123456789"); transactions[0].Amount.ShouldEqual(150m); transactions[0].Description.ShouldEqual("Paycheck"); transactions[1].Type.ShouldEqual(TransactionType.Deposit); transactions[1].Timestamp.ShouldEqual(new DateTime(2013, 3, 2, 9, 12, 32)); transactions[1].Account.ShouldEqual("987654321"); transactions[1].Amount.ShouldEqual(15m); transactions[1].Description.ShouldEqual("Birthday checks from Grandma, Grandpa, and Uncle Bob"); transactions[2].Type.ShouldEqual(TransactionType.Withdrawal); transactions[2].Timestamp.ShouldEqual(new DateTime(2013, 3, 3, 8, 22, 33)); transactions[2].Account.ShouldEqual("987654321"); transactions[2].Amount.ShouldEqual(123m); transactions[2].Description.ShouldEqual("Car Payment"); }
public void ImportCsvWithCommaInFieldTest() { string expectedDate = "4/29/2020"; string expectedDescription = "Treats Unleashed Inc."; string expectedOriginalDescription = "TREATS UNLEASHED SAINT PETERS MO"; double expectedAmount = 30.19; //TODO: Add enum string expectedTransactionType = "debit"; //TODO: Add enum string expectedCategory = "Restaurants"; string expectedAccountName = "Discover"; string expectedLabels = ""; string expectedNotes = ""; Transaction expectedTransaction = new Transaction { AccountName = expectedAccountName, Amount = expectedAmount, Category = expectedCategory, Date = expectedDate, Description = expectedDescription, Labels = expectedLabels, Notes = expectedNotes, OriginalDescription = expectedOriginalDescription, TransactionType = expectedTransactionType }; string sampleTransactionFile = sampleFileLocation + @"sample_transactions - comma in row.csv"; //Load sample csv and make sure each item loaded as expected var results = TransactionImporter.LoadCsvToArray <Transaction>(sampleTransactionFile); Assert.AreEqual(expectedTransaction, results[0]); }
public void ImportCsvTest() { string expectedDate = "6/6/2020"; string expectedDescription = "Old Navy"; string expectedOriginalDescription = "OLD NAVY US 6715"; double expectedAmount = 33.94; //TODO: Add enum string expectedTransactionType = "debit"; //TODO: Add enum string expectedCategory = "Clothing"; string expectedAccountName = "CREDIT CARD"; string expectedLabels = ""; string expectedNotes = ""; Transaction expectedTransaction = new Transaction { AccountName = expectedAccountName, Amount = expectedAmount, Category = expectedCategory, Date = expectedDate, Description = expectedDescription, Labels = expectedLabels, Notes = expectedNotes, OriginalDescription = expectedOriginalDescription, TransactionType = expectedTransactionType }; string sampleTransactionFile = sampleFileLocation + @"sample_transactions.csv"; //Load sample csv and make sure each item loaded as expected var results = TransactionImporter.LoadCsvToArray <Transaction>(sampleTransactionFile); Assert.AreEqual(expectedTransaction, results[0]); }
public void ImportCsvTestNotEnoughCommasOnLine() { string sampleTransactionFile = sampleFileLocation + @"sample_transactions - not enough commas in line.csv"; //Load sample csv and make sure each item loaded as expected var results = TransactionImporter.LoadCsvToArray <Transaction>(sampleTransactionFile); //Can't figure out how to completely skip, seems like the engine loads a null transaction if it's told to skip //Assert.AreEqual(0,results.Length); }
public MainWindow() { transactions = TransactionImporter.LoadCsvToArray <Transaction>(Constants.TransactionFile); InitializeComponent(); foreach (Transaction result in transactions) { data.Add(result); } transactionsGrid.ItemsSource = data; }
public async Task <Unit> Handle(ImportStockQuotes request, CancellationToken cancellationToken) { var importer = new TransactionImporter(); var transactions = importer.LoadTransactions(request.Stream); var portfolio = await _repo.Get(request.PortfolioId); portfolio.AddTransactions(transactions); await _repo.Save(portfolio); return(Unit.Value); }
public void CanLoadFile() { var file = "Confirmation Number,Order Number,Trade Date,Buy/ Sell,Security,Units,Average Price ($),Brokerage (inc GST.),Net Proceeds ($),Settlement Date,Confirmation Status,\n" + "80415128,N95343577,6/11/2017,B,WLE,862,1.160,10.00,1009.92,8/11/2017,Confirmed,"; using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(file))) { var importer = new TransactionImporter(); var transactions = importer.LoadTransactions(stream); Assert.AreEqual(1, transactions.Count()); var txn = transactions.First(); Assert.AreEqual("WLE", txn.Code); Assert.AreEqual(new DateTime(2017, 11, 6), txn.Date); Assert.AreEqual(TransactionTypes.Buy, txn.Type); Assert.AreEqual(862, txn.Units); Assert.AreEqual(1009.92M, txn.Total); Assert.AreEqual(10M, txn.Fees); } }
public static void Main(string[] args) { TransactionImporter transactionImporter = new TransactionImporter(); List <Network> aggregatedNetworkList = transactionImporter.aggrigateTransactionsFromCSV("../../../../loans.csv"); if (aggregatedNetworkList.Count > 0) { CSVSerializer csvSerializer = new CSVSerializer(); csvSerializer.exportAggrigatedList(aggregatedNetworkList, "../../../../output.csv"); } else { Core.Context.log.i("no aggrigated transactions, file not being written."); } Console.ReadLine(); while (true) { Thread.Sleep(1000); } }
private void UpdateTransactionsButton_click(object sender, RoutedEventArgs e) { transactions = TransactionImporter.LoadCsvToArray <Transaction>(Constants.TransactionFile); }