public void CanImportAccountWithTransactions() { var sample = @"!Clear:AutoSwitch !Option:AutoSwitch !Account NBank Account 1 TBank ^ !Type:Bank D01/1/18 U-400.00 T-400.00 CX NCard PMr Land Lord LRent ^"; QifDom parser = null; using (new CultureContext(new CultureInfo("en-GB"))) using (var reader = new StringReader(sample)) { parser = QifDom.ImportFile(reader); } Assert.Equal(1, parser.AccountListTransactions.Count); Assert.Equal(1, parser.BankTransactions.Count); Assert.Equal("Bank Account 1", parser.BankTransactions[0].AccountName); }
public void CanImportCreditCardTransaction() { var sample = @"!Type:CCard D31/1/18 U-6.25 T-6.25 CX PStarbucks MCoffee & cake LDining ^"; QifDom parser = null; using (new CultureContext(new CultureInfo("en-GB"))) using (var reader = new StringReader(sample)) { parser = QifDom.ImportFile(reader); } var transaction = parser.CreditCardTransactions[0]; Assert.Equal(new DateTime(2018, 1, 31), transaction.Date); Assert.Equal(-6.25M, transaction.Amount); Assert.Equal("X", transaction.ClearedStatus); Assert.Equal("Starbucks", transaction.Payee); Assert.Equal("Coffee & cake", transaction.Memo); Assert.Equal("Dining", transaction.Category); }
public void CanImportCategory() { var sample = @"!Type:Cat NEmployment DEmployment income T I ^"; QifDom parser = null; using (new CultureContext(new CultureInfo("en-GB"))) using (var reader = new StringReader(sample)) { parser = QifDom.ImportFile(reader); } var category = parser.CategoryListTransactions[0]; Assert.Equal("Employment", category.CategoryName); Assert.Equal("Employment income", category.Description); Assert.True(category.IncomeCategory); Assert.False(category.ExpenseCategory); Assert.True(category.TaxRelated); }
public static string ToQifData(this IEnumerable <BasicTransaction> transactions) { var qifDom = new QifDom(QifConfiguration) { BankTransactions = transactions.ToList() }; var tempFileName = Path.GetTempFileName(); try { using (new TemporaryCulture(_englishCulture)) { qifDom.Export(tempFileName); } var qifData = File.ReadAllText(tempFileName); return(qifData); } finally { if (File.Exists(tempFileName)) { try { File.Delete(tempFileName); } catch { /* ignored */ } } } }
private void exportButton_Click(object sender, EventArgs e) { if (saveFileDialog.ShowDialog(this) == DialogResult.OK) { QifDom.ExportFile((QifDom)qifDomPropertyGrid.SelectedObject, saveFileDialog.FileName); MessageBox.Show(this, "The export is complete.", "Complete", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public MainUI() { InitializeComponent(); using (new SpoofCulture("en-US")) { qifDomPropertyGrid.SelectedObject = QifDom.ImportFile(Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + "sample.qif"); } }
public static QifDom ParseQifDom(string qifData) { using (new TemporaryCulture(_englishCulture)) { var ms = new MemoryStream(Encoding.UTF8.GetBytes(qifData)); var qifDom = QifDom.ImportFile(new StreamReader(ms), QifConfiguration); return(qifDom); } }
private void importButton_Click(object sender, EventArgs e) { if (ConfirmOverwrite()) { if (openFileDialog.ShowDialog(this) == DialogResult.OK) { qifDomPropertyGrid.SelectedObject = QifDom.ImportFile(openFileDialog.FileName); } } }
public void Cannot_import_sample_qif_when_current_culture_is_ar_SA() { var sample = File.ReadAllText("sample.qif"); using (new CultureContext(new CultureInfo("ar-SA"))) using (var reader = new StreamReader(new MemoryStream(Encoding.UTF8.GetBytes(sample)))) { Assert.Throws <InvalidCastException>(() => QifDom.ImportFile(reader)); } }
public void Can_import_sample_qif_when_current_culture_is_en_US() { var sample = File.ReadAllText("sample.qif"); using (new CultureContext(new CultureInfo("en-US"))) using (var reader = new StreamReader(new MemoryStream(Encoding.UTF8.GetBytes(sample)))) { var qif = QifDom.ImportFile(reader); Assert.NotEmpty(qif.BankTransactions); } }
public void Can_import_sample_qif_when_current_culture_is_en_CA_with_CustomReadDateFormat() { var sample = File.ReadAllText("sample.qif"); using (new CultureContext(new CultureInfo("en-CA"))) using (var reader = new StreamReader(new MemoryStream(Encoding.UTF8.GetBytes(sample)))) { var qif = QifDom.ImportFile(reader, new Configuration { ReadDateFormatMode = ReadDateFormatMode.Custom, CustomReadDateFormat = "M/d/yyyy", }); Assert.NotEmpty(qif.BankTransactions); } }
public void Cannot_import_sample_qif_when_explicitly_using_ar_SA() { var sample = File.ReadAllText("sample.qif"); using (new CultureContext(new CultureInfo("en-US"))) using (var reader = new StreamReader(new MemoryStream(Encoding.UTF8.GetBytes(sample)))) { Assert.Throws <InvalidCastException>(() => { QifDom.ImportFile(reader, new Configuration { CustomReadCultureInfo = new CultureInfo("ar-SA") }); }); } }
public void Does_not_change_income_category() { var sample = new QifDom(); sample.CategoryListTransactions.Add(new Transactions.CategoryListTransaction() { IncomeCategory = true, }); var file = Path.GetTempFileName(); sample.Export(file); var test = QifDom.ImportFile(file); Assert.AreEqual(sample.CategoryListTransactions.Count, test.CategoryListTransactions.Count); Assert.AreEqual(sample.CategoryListTransactions[0].IncomeCategory, test.CategoryListTransactions[0].IncomeCategory); }
public void Does_not_change_tax_related() { var sample = new QifDom(); sample.CategoryListTransactions.Add(new Transactions.CategoryListTransaction() { TaxRelated = true, }); var file = Path.GetTempFileName(); sample.Export(file); var test = QifDom.ImportFile(file); Assert.AreEqual(sample.CategoryListTransactions.Count, test.CategoryListTransactions.Count); Assert.AreEqual(sample.CategoryListTransactions[0].TaxRelated, test.CategoryListTransactions[0].TaxRelated); }
public void CanImportCreditCardSplit() { var sample = @"!Type:CCard D31/1/18 U-6.25 T-6.25 CX PCaffe Nero LDining SDining ECoffee $-2.75 SDining ECake $-3.50 ^"; QifDom parser = null; using (new CultureContext(new CultureInfo("en-GB"))) using (var reader = new StringReader(sample)) { parser = QifDom.ImportFile(reader); } var transaction = parser.CreditCardTransactions[0]; // Transaction values. Assert.Equal(new DateTime(2018, 1, 31), transaction.Date); Assert.Equal(-6.25M, transaction.Amount); Assert.Equal("X", transaction.ClearedStatus); Assert.Equal("Caffe Nero", transaction.Payee); Assert.Equal("Dining", transaction.Category); // Split 1. Assert.Equal("Dining", transaction.SplitCategories[0]); Assert.Equal("Coffee", transaction.SplitMemos[0]); Assert.Equal(-2.75M, transaction.SplitAmounts[0]); // Split 2. Assert.Equal("Dining", transaction.SplitCategories[1]); Assert.Equal("Cake", transaction.SplitMemos[1]); Assert.Equal(-3.50M, transaction.SplitAmounts[1]); }
public void ExportTransactions(string filename) { var transactions = GetTransactions(); var wrapper = new QifDomComWrapper(); var qd = new QifDom(); foreach (var t in transactions) { // todo: proper conversion var transaction = new BasicTransaction(); transaction.Amount = (decimal)t.Amount; transaction.Date = t.Timestamp; transaction.Payee = t.FromAddress; transaction.Memo = t.ToAddress; qd.CashTransactions.Add(transaction); } qd.Export(filename); }
private void LoadQifFile_Click(object sender, RoutedEventArgs e) { // Create OpenFileDialog Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); // Set filter for file extension and default file extension dlg.DefaultExt = ".qif"; dlg.Filter = "QIF Files (.qif)|*.qif"; // Display OpenFileDialog by calling ShowDialog method Nullable <bool> result = dlg.ShowDialog(); // Get the selected file name and display in a TextBox if (result == true) { // Open document string filename = dlg.FileName; FileNameTextBox.Text = filename; String LoadedMessage = "Loaded"; QifDom Qd = new QifDom(); //Qd.Import("C:\\Users\\Mike\\Documents\\AccountingDatabase\\010544496_20140817.qif"); Qd.Import(filename); LoadMessage.Text = LoadedMessage; Qt = new QifTransaction(Qd); Dt = Qt.GetTransactionCollection(); TransactionGrid.ItemsSource = Dt.DefaultView; } }
public void CanImportClass() { var sample = @"!Type:Class NMyClassName DMyClassDescription ^"; QifDom parser = null; using (new CultureContext(new CultureInfo("en-GB"))) using (var reader = new StringReader(sample)) { parser = QifDom.ImportFile(reader); } var @class = parser.ClassListTransactions[0]; Assert.Equal("MyClassName", @class.ClassName); Assert.Equal("MyClassDescription", @class.Description); }
public QifTransaction(QifDom qd) { QT_Dom = qd; }
public MainUI() { InitializeComponent(); qifDomPropertyGrid.SelectedObject = QifDom.ImportFile(Path.GetDirectoryName(Application.ExecutablePath) + "\\sample.qif"); }