hledger balance issue with @@ syntax #69

Closed
simonmichael opened this Issue Apr 8, 2013 · 7 comments

Projects

None yet

1 participant

@simonmichael
Owner

Original author: thierry....@gmail.com (October 09, 2011 21:34:33)

What steps will reproduce the problem?

$ cat hledger_test_13
1998/10/29 * AFS
Actif:Invest:AFS 20 AFS @@ 21690 $
Actif:Invest:AFS

What is the expected output?

$ ledger -f hledger_test_13 bal
$-21690
20 AFS Actif:Invest:AFS

What do you see instead?

$ hledger -f hledger_test_13 bal

               0

What version of the product are you using?

$ hledger --version
hledger-0.16.1

On what operating system?

$ uname -a
Linux rialto 2.6.38-11-generic #50-Ubuntu SMP Mon Sep 12 21:17:25 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux

Please provide any additional information below.

Original issue: http://code.google.com/p/hledger/issues/detail?id=69

@simonmichael
Owner

From simon@joyful.com on October 09, 2011 21:48:10
Thanks!

hledger infers a balancing amount of - 20 AFS @@ 21690 $, cancelling out the first posting exactly.
ledger infers a balancing amount of $-21960, so does not show a zero balance unless you run it with -B.
Why is ledger's behaviour more correct ?

@simonmichael
Owner

From thierry....@gmail.com on October 09, 2011 22:12:44
Sorry, my mistake. The title of the bug must be about "register" command, not balance.

$ hledger -f hledger_test_13 reg
1998/10/29 AFS Actif:Invest:AFS 20 AFS 20 AFS
Actif:Invest:AFS -20 AFS 0

$ ledger -f hledger_test_13 reg
98-Oct-29 AFS Actif:Invest:AFS 20 AFS 20 AFS
Actif:Invest:AFS $-21690 $-21690
20 AFS

hledger output is erronous, as this can not be 0, but "20 AFS" as ledger reports.

@simonmichael
Owner

From simon@joyful.com on October 09, 2011 22:31:32
I think you mean ledger is reporting the final balance as $-21960 + 20 AFS, as we'd expect by default since it used $ in the balancing amount. While hledger used AFS in the balancing amount. Why is ledger's choice better ?

$ hledger -f t.j reg
2011/01/01 a 20 AFS 20 AFS
a -20 AFS 0
$ hledger -f t.j reg -B
2011/01/01 a 21690 $ 21690 $
a -21690 $ 0
$ ledger -f t.j reg
11-Jan-01 a 20 AFS 20 AFS
a $-21690 $-21690
20 AFS
$ ledger -f t.j reg -B
11-Jan-01 a $21690 $21690
a $-21690 0

@simonmichael
Owner

From thierry....@gmail.com on October 10, 2011 19:39:00
I uploaded a new version of file hledger_test_13

$ ledger -f hledger_test_13 bal MyTrader
20 AFS Assets:Invest:MyTrader

The above is correct as I own 20 shares of AFS

$ hledger -f hledger_test_13 bal MyTrader

21690 $ Assets:Invest:MyTrader

         21690 $

The above is not correct, as I own 20 shares of AFS, and that the current price of one share is 1100$ (see file), that is 20*1100=22000$, and hledger is reporting erroneously 21690$

1998/10/29 Buy AFS
Assets:Invest:MyTrader 20 AFS @@ 21690 $
Assets:Invest:MyTrader

The above syntax, in ledger, is equal to below syntax

1998/10/29 Buy AFS
Assets:Invest:MyTrader 20 AFS
Assets:Invest:MyTrader -21690 $

But hledger is not taking into account that both "$" and "AFS" are a currency. Either hledger interprets every currency as "$", or with -B option every currency as "AFS". ledger is currency agnostic. hledger forces me to have a single currency.

I report this bug, because when I run "{,h}ledger bal" I get very different results, and I tried to isolate a more simple use case identifying differences.

@simonmichael
Owner

From simon@joyful.com on October 11, 2011 17:32:03
Google ate my reply, trying again. Thierry thanks for helping me understand this. I am cautious because current hledger handles prices differently from ledger. We handle only fixed prices set at transaction time, supporting -B but not -V/-X. That's why it behaves as you see. But you have just about convinced me that using the cost amount & commodity (specified with @@ or @) in the inferred balancing amount is the right choice for hledger too. I'll try it, unless you send me a patch first.

@simonmichael
Owner

From simon@joyful.com on January 03, 2012 08:26:05
Fixed in darcs: inferred amounts now use the cost commodity if known, like ledger. I think this fixes this issue.

hledger still can only show cost (with -B/--cost), not current value - let's open a separate issue for that if needed.

@simonmichael
Owner

From thierry....@gmail.com on November 10, 2012 10:57:45
Thanks for having implemented that one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment