コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
 public MainUI()
 {
     InitializeComponent();
     using (new SpoofCulture("en-US"))
     {
         qifDomPropertyGrid.SelectedObject = QifDom.ImportFile(Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + "sample.qif");
     }
 }
コード例 #5
0
ファイル: QifMapper.cs プロジェクト: blaise-braye/my-accounts
 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);
     }
 }
コード例 #6
0
ファイル: MainUI.cs プロジェクト: kaytame/qif
 private void importButton_Click(object sender, EventArgs e)
 {
     if (ConfirmOverwrite())
     {
         if (openFileDialog.ShowDialog(this) == DialogResult.OK)
         {
             qifDomPropertyGrid.SelectedObject = QifDom.ImportFile(openFileDialog.FileName);
         }
     }
 }
コード例 #7
0
ファイル: ImportTests.cs プロジェクト: georgbuehler/qif
        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));
                }
        }
コード例 #8
0
ファイル: ImportTests.cs プロジェクト: georgbuehler/qif
        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);
                }
        }
コード例 #9
0
ファイル: ImportTests.cs プロジェクト: georgbuehler/qif
        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);
                }
        }
コード例 #10
0
ファイル: ImportTests.cs プロジェクト: georgbuehler/qif
        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")
                        });
                    });
                }
        }
コード例 #11
0
        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);
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        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]);
        }
コード例 #14
0
        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);
        }
コード例 #15
0
ファイル: MainUI.cs プロジェクト: tolbxela/qif
 public MainUI()
 {
     InitializeComponent();
     qifDomPropertyGrid.SelectedObject = QifDom.ImportFile(Path.GetDirectoryName(Application.ExecutablePath) + "\\sample.qif");
 }