ledger / ledger

Double-entry accounting system with a command-line reporting interface
https://www.ledger-cli.org
Other
5.39k stars 503 forks source link

Dated balance assertions not working (BZ#847) #847

Open tbm opened 12 years ago

tbm commented 12 years ago

Note: the issue was created automatically with bugzilla2github

Bugzilla bug ID: BZ#847 From: John Wiegley (@jwiegley) CC: @eliptus, unknown user, @thdox

tbm commented 8 years ago

Comment author: Kael Shipman

Just wanted to confirm that this is still an issue and can have very undesired consequences.

This correctly reports success (silently, i.e., it doesn't report an error):


2015.01.01 Starting Balance Assets:Cash $1000.00 Equity:Opening Balances

2015.01.02 Shopping Expenses:Food $20.00 Assets:Cash

2015.01.03 More Shopping Expenses:Food $40.00 Assets:Cash

2015.01.04 Balance confirmation Assets:Cash $0.00 = $940

However, changing the date of the balance confirmation transaction to 2015.01.02 incorrectly reports success. Similarly, leaving the date the same and moving the transaction above the "More Shopping" transaction incorrectly reports an error.

It appears as though by design the program calculates current balances based on where the transaction appears in the file, not when the transaction occurs. This seems like it would carry some very important consequences, e.g., retroactively entering transactions at the end of your register for a past date, in which case the verification transactions would continue to report success even given the new (and potentially incorrect) transactions entered.

(Thanks for the great software! I'm enjoying learning to use it.)

tbm commented 12 years ago

Comment author: John Wiegley (@jwiegley)

I want to be able to check the (real) balance of my account and enter that number (with the date) as an assertion check. So I would know if something doesn't match up or if I missed some transactions.

Ledger 3.0 seems to have a "verification" method described in the manual: http://www.ledger-cli.org/3.0/doc/ledger3.html#Balance-verification

I tried this method and put the check at the end of my ledger. But when I put it at the end it doesn't seem to work properly.

I used the following test ledger:

2010-01-01 * Starting Balance
 Assets:Bank:Checking       1000.00 EUR
 Equity:Opening-Balances

2010-01-02 * Shopping
 Expenses:shopping          10 EUR
 Assets:Bank:Checking

2010-01-03 * Some more shopping
 Expenses:shopping          5 EUR
 Assets:Bank:Checking

; verify balance
2010-01-02 * Balance Check
 Assets:Bank:Checking       -0.0 EUR    = 990.00 EUR
tbm commented 6 years ago

@thdox thinks this is related to issue #1005

porridge commented 4 years ago

A workaround might be to sort your transactions for example with sorttrans-cli.