Some weird behaviour using 'dot' instead of 'comma' #196

thdox opened this Issue Jun 22, 2014 · 7 comments


None yet

2 participants

thdox commented Jun 22, 2014

See below

  • example file
  • ledger is behaving correctly (all figures have commas)
  • hledger do not output correct results (some figures have a dot as decimal separator)

$ cat hledger_test_17a

2010/11/15 * OLD
    Actif:Invest:Sg                             10 OLD  ; @ 18,03 €
    Revenu:Salaire:Prime                   -181,15 €

2013/07/30 OLD  ; ESOP OLD available 1/7/2018
    Actif:Invest:Peg                       20,0067 OLD @@ 885,30 €  ; @ 44,25 €
    Actif:Remboursement:OLD                -420,20 €
    Revenu:Salaire:Prime  ; FIXME

2013/11/15 OLD  ; Free stock
    Actif:Invest:Sg                             10 OLD  ; @ 52,50 €
    * Revenu:Salaire:Prime                 -525,00 €

2014/01/02 New Group  ; rebranding
    Actif:Invest:Sg                            -20 OLD @ 56,04 €
    Actif:Invest:Sg                             20 New_Group @ 56,04 €

2014/01/02 New Group  ; rebranding
    Actif:Invest:Peg                      -20,0067 OLD @ 56,04 €
    Actif:Invest:Peg                       20,0067 New_Group @ 56,04 €

$ ledger --args-only --no-pager --decimal-comma -f hledger_test_17a bal

   40,0067 New_Group
           -420,20 €  Actif
   40,0067 New_Group    Invest
   20,0067 New_Group      Peg
   20,0000 New_Group      Sg
           -420,20 €    Remboursement:OLD
          -1171,25 €  Revenu:Salaire:Prime
   40,0067 New_Group
          -1591,45 €`

$ hledger -f hledger_test_17a bal

   40.0067 New_Group  
           -420,20 €  Actif
   40.0067 New_Group    Invest
   20.0067 New_Group      Peg
   20.0000 New_Group      Sg
           -420,20 €    Remboursement:OLD
          -1171,25 €  Revenu:Salaire:Prime
   40.0067 New_Group
          -1591,45 €

Thanks. I guess it's assuming the default . decimal point for New_Group when it sees "20 New_Group". It probably should keep looking through the commodity amounts until it finds one which actually has a decimal point. Likewise for thousands separators/digit groups.


PS I welcome a patch, and of course a quick workaround is to make sure each commodity's first amount includes a decimal point, eg write the 1/2 amount as 20,0 New_Group @ 56,04 €.

thdox commented Jun 22, 2014

The workaround "write the amount as 20,0 New_Group @ 56,04 €" works. Workaround exists, I will use that until a fix.

As you said "(it) should keep looking through the commodity amounts until it finds one which actually has a decimal point".

I still believe this is a (minor) bug:

  • as this breaks the least surprise principle when coming from c++ ledger,
  • as it makes things more complicated, by using "20,0" instead of "20", latter looks more natural/human readable.
  • as it breaks bullet 2 of : "The amount of data required by Ledger is minimal. It figures out from looking at your data what you mean by it and how you want it reported back to you. Accounts are created as they appear; currencies are created as they’re referenced. Anywhere that a value can be calculated, you can leave it out." Here we can see that hledger is not able to "figure out from look at your data what you mean".

Unfortunately, I have absolutely zero competence in Haskell to contribute a patch.

@simonmichael simonmichael added a commit that closed this issue Jul 3, 2014
@simonmichael look harder for decimal point & digit groups (fixes #196)
Amount display styles have been reworked a bit; they are now calculated
after journal parsing, not during it. This allows the fix for #196:
we now search through the amounts until a decimal point is detected,
instead of just looking at the first one; likewise for digit groups.
Digit groups are now implemented with a better type.

Digit group size detection has been improved a little:
1000,000 now gives group sizes [3,4,4,...], not [3,3,...], and
10,000 gives groups sizes [3,3,...] not [3,2,2,..].
(To get [3,2,2,...] you'd use eg 00,00,000.)

There are still some old (or new ?) issues; I don't think we handle
inconsistent decimal points & digit groups too well. But for now all
tests pass.

This is fixed. Hopefully the autodetection of decimal point and digit group separator is at least as robust as before; I think it should always work as long as you use them consistently, but it may fail to give an error if you don't.

thdox commented Nov 2, 2014

Hi Simon, I tested this today, and unfortunately this is not fixed (I have the exact same result with dot instead of comma). I did "cabal update && cabal install hledger" and got release 23.3, that is two months ago. Maybe I should try latest from github ?


Yes that patch seems to be only in HEAD, sorry about that. I should probably wait until release time to close issues.

@simonmichael simonmichael reopened this Nov 3, 2014
thdox commented Jan 10, 2015

Hi Simon, I've tested this against hledger 0.24, and this works correctly ! Thank you very much !

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