On Friday, June 4, 2021 at 8:23:36 PM UTC+7 [email protected] wrote:

> On Fri, 4 Jun 2021 at 19:47, Perl Ancar <[email protected]> wrote: 
>
> > ledger points out the wrong entry (probably the next entry with multiple 
> commas) when there is a misplaced comma. Example: 
> > 
> > ; -*- Mode: ledger -*- 
> > 
> > 2021/01/06 entry1 
> > assets:cash:savings:bca 200,0000 IDR 
> > assets:cash:dana 
> > 
> > 2021/01/06 entry2 
> > assets:cash:savings:bca 100,000 IDR 
> > assets:cash:dana 
> > 
> > 2021/01/06 entry3 
> > assets:cash:savings:bca 3,050,000 IDR 
> > assets:cash:dana 
> > 
> > As you can see, the error is in entry1 in line 4. The amount should be 
> "200,000 IDR" (extraneous 0) or perhaps 2,000,000 IDR (misplaced commas). 
>
> How do you figure that? 
>
> Ledger is pretty flexible in its input syntax. In particular, it 
> supports both ‘.’ (American convention) and ‘,’ (European convention) 
> as the decimal separator. Absent any explicit indication in your file, 
> it probably interprets entry1 as a transaction for two hundred and 
> zero ten-thousandths, entry2 for one hundred and zero thousandths, and 
> entry3 as “three and fifty thousandths and wait, what? surely a number 
> cannot have two decimal separators”. 
>
> If you change the first occurrence of IDR this way: 
>
> 2021/01/06 entry1 
> assets:cash:savings:bca 200,0000.00 IDR 
>
> then Ledger says: 
>
> While parsing posting: 
> assets:cash:savings:bca 200,0000.00 IDR 
> ^^^^^^^^^^^^^^^ 
> Error: Incorrect use of thousand-mark comma 
>
> I was under the impression that pre-declaring the commodity should 
> also have this effect, but I don’t see that having any effect on 
> Ledger 3.1.2: 
>
> commodity IDR 
> format 1,000.00 IDR 
>
> I also did not find a way to say that the comma is the thousand 
> separator and dot is the decimal separator without setting the default 
> precision to non-zero. 
>

I was completely oblivious to the fact that Ledger is flexible with regards 
to thousand separator and decimal point character. But even after I add a 
non-ambiguous "predeclaration" like this:

2021/01/01 entry0
 assets:cash:savings:bca  0,000,000.00 IDR
 assets:cash:dana

2021/01/06 entry1
 assets:cash:savings:bca  200,0000 IDR
 assets:cash:dana

2021/01/06 entry2
 assets:cash:savings:bca  100,000 IDR
 assets:cash:dana

2021/01/06 entry3
 assets:cash:savings:bca  3,050,000 IDR
 assets:cash:dana

I still can't make Ledger detect the error in entry1. It still ends up 
complaining about entry3. If entry1 is commented out, Ledger now can parse 
the file and correctly use the format specified by entry0:

% ledger -f 2.dat bal
                   0  assets:cash
   -3,150,000.00 IDR    dana
    3,150,000.00 IDR    savings:bca
--------------------

In my own use, I just don’t bother writing the thousand separators; a 
> typical day-to-day transaction in RUB is not large enough to warrant 
> digit grouping. But I see how you might want to, and how you might not 
> want decimals at all. 
>

 With the relatively low monetary value of IDR, it's quite helpful as the 
numbers can easily go into hundreds of millions or billions. Without the 
thousand grouping I would have made even more errors.

Regards,
perlancar

-- 

--- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ledger-cli/be473f51-ba7a-4637-ae04-fb22549bbf01n%40googlegroups.com.

Reply via email to