Hi, Everyone!

Going on 2.5 years using ledger and loving it. I ran into a strange problem 
that I worked out, but I'm wondering why this was an issue.

I have things split into multiple files, e.g.:

journal.ledger
investments.ledger
accounts.ldg
etc...

So I run ledger with several -f options. I have a number of aliases for 
different things to simplify running it from the command line.

I have a little validation script I run before committing to git. (It just 
runs a dummy ledger command with my usual options and checks for an error 
and reports how things turned out.) On a recent commit it was happy with a 
small update where I added two entries, one of which in journal.ledger was:

2015/05/13 some place
    e: misc
    e: sundry                          ($2.539 * 1.8)
    l: credit card: big bank       $-30.25

But when I subsequently ran a reg report, I got this:

> 2014/12/19 investments-r-us
>     a: abc: investment banana        5.7424  ba @ $24.38
>     a: abc: investment bread         2.6954  br @ $22.26
>     a: abc: cash                     $-200
Unbalanced remainder is:
            $ -0.001
Amount to balance against:
        $ 199.999316
Error: Transaction does not balance

You can see that entry is from last year and it's long been settled and not 
causing any issues. (This entry is in investments.ledger, unsurprisingly.)

The first thing I found was that changing the sundry entry to $4.57 made 
the problem go away. But I'm wondering how a rounding problem in that entry 
could cause an issue with the completely unrelated investment entry. (Also 
wondering why that would cause a rounding error.)

Then: why was the file was passing my validation script? I noticed that in 
the val script I had a different order for two files:

$ldg_dir/investments.ledger -f $ldg_dir/journal.ledger

And in my aliases for actually running ledger commands I was specifying 
journal.ledger first. So I switched them and now my "reg" command runs 
successfully, even when using * 1.8 for sundry.

So what do you guys think? Is this a rounding bug in ledger? Or is there 
some reason I should run my investments file first? Or is there somewhere 
I'm not specifying the right format for things?

It seems like $199.999316 should match $200.

I have $ set like so:

commodity $
    format $ 1,000.00

Thank you!

Scott

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to