Exemplo n.º 1
0
        public void TextualParser_ParseXact_CheckingBalanceIntegrationTest()
        {
            string line =
                @"2003/12/01 * Checking balance
  Assets:Checking                   $1,000.00
  Equity:Opening Balances";
            ITextualReader reader = CreateReaderForString(line);
            TextualParser  parser = CreateTextualParser();

            Account account = new Account();
            string  current = reader.ReadLine();
            Xact    xact    = parser.ParseXact(current, reader, account);

            Assert.IsNotNull(xact);
            Assert.AreEqual(new Date(2003, 12, 01), xact.Date);
            Assert.IsNull(xact.DateAux);
            Assert.AreEqual(ItemStateEnum.Cleared, xact.State);
            Assert.AreEqual("Checking balance", xact.Payee);
            Assert.AreEqual(2, xact.Posts.Count);

            Post post1 = xact.Posts.First();

            Assert.AreEqual("Assets:Checking", post1.Account.FullName);
            Assert.AreEqual("$", post1.Amount.Commodity.Symbol);
            Assert.AreEqual(BigInt.Parse("1000", 2), post1.Amount.Quantity);

            Post post2 = xact.Posts.Last();

            Assert.AreEqual("Equity:Opening Balances", post2.Account.FullName);
            Assert.IsNull(post2.Amount);
        }
Exemplo n.º 2
0
        public void TextualParser_ParseXact_BankIntegrationTest()
        {
            string line =
                @"2011/01/25=2011/01/28 Bank
  ; Transfer to cover car purchase
  Assets:Checking                  $ 5,500.00
  Assets:Savings
  ; :nobudget:";
            ITextualReader reader = CreateReaderForString(line);
            TextualParser  parser = CreateTextualParser();

            Account account = new Account();
            string  current = reader.ReadLine();
            Xact    xact    = parser.ParseXact(current, reader, account);

            Assert.IsNotNull(xact);
            Assert.AreEqual(new Date(2011, 01, 25), xact.Date);
            Assert.AreEqual(new Date(2011, 01, 28), xact.DateAux);
            Assert.AreEqual(ItemStateEnum.Uncleared, xact.State);
            Assert.AreEqual("Bank", xact.Payee);
            Assert.AreEqual(" Transfer to cover car purchase", xact.Note); // Notice the trailing space.
            Assert.IsTrue(xact.Flags.HasFlag(SupportsFlagsEnum.ITEM_NOTE_ON_NEXT_LINE));
            Assert.AreEqual(2, xact.Posts.Count);

            Post post1 = xact.Posts.First();

            Assert.AreEqual("Assets:Checking", post1.Account.FullName);
            Assert.AreEqual("$", post1.Amount.Commodity.Symbol);
            Assert.AreEqual(BigInt.Parse("5500", 2), post1.Amount.Quantity);

            Post post2 = xact.Posts.Last();

            Assert.AreEqual("Assets:Savings", post2.Account.FullName);
            Assert.AreEqual(" :nobudget:", post2.Note);
            Assert.IsTrue(post2.Flags.HasFlag(SupportsFlagsEnum.ITEM_NOTE_ON_NEXT_LINE));
            Assert.IsTrue(post2.HasTag("nobudget"));
            Assert.IsNull(post2.Amount);
        }