Hi, John --

On Tue, 20 Mar 2012, John Wiegley wrote:
> Can you send me a small test case which demonstrates this behavior?  It sounds
> buggish to me...

Start with this simple file, testfile.dat:

--8<---------------cut here---------------start------------->8---
2005/01/03 * Pay Credit card
    Liabilities:CredCard    $1,000.00  ; Electronic/ACH Debit
    Assets:Current:Checking  ; Electronic/ACH Debit
    (Virtualaccount)        $1,000.00

2006/01/03 Gift shop
    Expenses:Gifts                          $46.50   
    * Liabilities:CredCard

2006/01/03 Bike shop
    Expenses:Misc               $199.00
    * Liabilities:CredCard
    (testvirtual)                          $184.72

2006/01/04 Store
    Expenses:Misc                           $49.95
    * Liabilities:CredCard

--8<---------------cut here---------------end--------------->8---

ledger -f testfile.dat bal yields:

--8<---------------cut here---------------start------------->8---
          $-1,000.00  Assets:Current:Checking
             $295.45  Expenses
              $46.50    Gifts
             $248.95    Misc
             $704.55  Liabilities:CredCard
           $1,000.00  Virtualaccount
             $184.72  testvirtual
--------------------
           $1,184.72

--8<---------------cut here---------------end--------------->8---

ledger -f testfile.dat bal -R yields:

--8<---------------cut here---------------start------------->8---
          $-1,000.00  Assets:Current:Checking
             $295.45  Expenses
              $46.50    Gifts
             $248.95    Misc
             $704.55  Liabilities:CredCard
--------------------
                   0

ledger -f testfile.dat equity -e 2006 > testequity.dat

Contents of testequity.dat:

--8<---------------cut here---------------start------------->8---
2005/01/03 Opening Balances
    Assets:Current:Checking               $-1,000.00
    Liabilities:CredCard                   $1,000.00
    (Virtualaccount)                       $1,000.00
    Equity:Opening Balances               $-1,000.00

--8<---------------cut here---------------end--------------->8---

Now insert !include testequity.dat at the top of testfile.dat and delete
the 2005 entry:

--8<---------------cut here---------------start------------->8---
!include ~/testequity.dat

2006/01/03 Gift shop
    Expenses:Gifts                          $46.50   
    * Liabilities:CredCard

2006/01/03 Bike shop
    Expenses:Misc               $199.00
    * Liabilities:CredCard
    (testvirtual)                          $184.72

2006/01/04 Store
    Expenses:Misc                           $49.95
    * Liabilities:CredCard

--8<---------------cut here---------------end--------------->8---

Now ledger -f testfile.dat bal [with or without -R] yields:

--8<---------------cut here---------------start------------->8---
In file included from "testfile.dat", line 3: 
While parsing file "testequity.dat", line 5: 
While balancing transaction from "testequity.dat", lines 1-5:
> 2005/01/03 Opening Balances
>     Assets:Current:Checking               $-1,000.00
>     Liabilities:CredCard                   $1,000.00
>     (Virtualaccount)                       $1,000.00
>     Equity:Opening Balances               $-1,000.00
Unbalanced remainder is:
          $-1,000.00
Amount to balance against:
           $2,000.00
Error: Transaction does not balance

--8<---------------cut here---------------end--------------->8---

If I remove the "$1,000.00" from the last line of testequity.dat, then the
bal command works

ledger -f testfile.dat bal:

--8<---------------cut here---------------start------------->8---
          $-1,000.00  Assets:Current:Checking
             $295.45  Expenses
              $46.50    Gifts
             $248.95    Misc
             $704.55  Liabilities:CredCard
           $1,000.00  Virtualaccount
             $184.72  testvirtual
--------------------
           $1,184.72

--8<---------------cut here---------------end--------------->8---

and ledger -f testfile.dat bal -R:

--8<---------------cut here---------------start------------->8---
          $-1,000.00  Assets:Current:Checking
             $295.45  Expenses
              $46.50    Gifts
             $248.95    Misc
             $704.55  Liabilities:CredCard
--------------------
                   0

--8<---------------cut here---------------end--------------->8---

It appears to me that when parsing the included file, ledger expects even
postings with (virtual accounts) to balance, but that it *doesn't* expect
(virtual accounts) in the file itself (in the example above, testfile.dat)
to balance.

--John
-- 
John Rakestraw

Reply via email to