Re: Wrong entry pointed out in "Too many commas in amount" error message

2021-06-15 Thread Martin Michlmayr
* Perl Ancar  [2021-06-07 04:34]:
> > 2021/01/06 entry4 
> > assets:cash:savings:bca 1 IDR 
> > assets:cash:dana 
> 
> What command do you use to show how Ledger parses a file, like the above?

I'm not sure.  What I meant is to run "ledger reg" on the example I
provided.  It would have shown how it's processed.

-- 
Martin Michlmayr
https://www.cyrius.com/

-- 

--- 
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 ledger-cli+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ledger-cli/YMhZHPQCKuos7AqZ%40jirafa.cyrius.com.


Re: Wrong entry pointed out in "Too many commas in amount" error message

2021-06-07 Thread Perl Ancar
On Friday, June 4, 2021 at 8:37:08 PM UTC+7 Martin Michlmayr wrote:

> * Perl Ancar  [2021-06-04 05:47]: 
> > ledger points out the wrong entry (probably the next entry with 
> > multiple commas) when there is a misplaced comma. Example: 
>
> Ledger uses the first entry to figure out the format, so if the first 
> entry is wrong you don't have a guarantee where an error will occur. 
>
> Look at the ledger output for these to see how ledger interprets your 
> format: 
>
> 2021/01/06 entry1 
> assets:cash:savings:bca 200, IDR 
> assets:cash:dana 
>
> 2021/01/06 entry2 
> assets:cash:savings:bca 100,000 IDR 
> assets:cash:dana 
>
> 2021/01/06 entry4 
> assets:cash:savings:bca 1 IDR 
> assets:cash:dana 
>

Hi Martin,

What command do you use to show how Ledger parses a file, like the above?

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 ledger-cli+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ledger-cli/6161434e-7c0f-41d2-aa68-91e4b984ac40n%40googlegroups.com.


Re: Wrong entry pointed out in "Too many commas in amount" error message

2021-06-07 Thread Perl Ancar
On Friday, June 4, 2021 at 8:23:36 PM UTC+7 yuri...@gmail.com wrote:

> On Fri, 4 Jun 2021 at 19:47, Perl Ancar  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, 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,.00 IDR 
>
> then Ledger says: 
>
> While parsing posting: 
> assets:cash:savings:bca 200,.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, 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 IDRdana
3,150,000.00 IDRsavings: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 ledger-cli+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ledger-cli/be473f51-ba7a-4637-ae04-fb22549bbf01n%40googlegroups.com.


Re: Wrong entry pointed out in "Too many commas in amount" error message

2021-06-04 Thread Martin Michlmayr
* Perl Ancar  [2021-06-04 05:47]:
> ledger points out the wrong entry (probably the next entry with
> multiple commas) when there is a misplaced comma. Example:

Ledger uses the first entry to figure out the format, so if the first
entry is wrong you don't have a guarantee where an error will occur.

Look at the ledger output for these to see how ledger interprets your
format:

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

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

2021/01/06 entry4
 assets:cash:savings:bca  1 IDR
 assets:cash:dana

-- 
Martin Michlmayr
https://www.cyrius.com/

-- 

--- 
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 ledger-cli+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ledger-cli/YLosfeoZQ5rbzSg5%40jirafa.cyrius.com.


Re: Wrong entry pointed out in "Too many commas in amount" error message

2021-06-04 Thread Yuri Khan
On Fri, 4 Jun 2021 at 19:47, Perl Ancar  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, 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,.00 IDR

then Ledger says:

While parsing posting:
  assets:cash:savings:bca  200,.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.

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.

-- 

--- 
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 ledger-cli+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ledger-cli/CAP_d_8VS_qA_8-XDMrp8CcUA3uZsEcsQBNyax2Dw3D9D0d8YJA%40mail.gmail.com.


Wrong entry pointed out in "Too many commas in amount" error message

2021-06-04 Thread Perl Ancar
Hi everyone,

First of all, sorry I haven't updated ledger to the latest when testing 
this bug. I'm using 3.1.3-20190331 which comes with Ubuntu 20.04.2 LTS on 
my laptop. So perhaps this bug no longer exists.

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, 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). 
But when run through ledger, it complains as follow:

While parsing file "/home/u1/tmp/1.dat", line 12:
While parsing posting:
  assets:cash:savings:bca  3,050,000 IDR
   ^
Error: Too many commas in amount

Regards,

-- 

--- 
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 ledger-cli+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ledger-cli/5861dd32-dae4-45e9-8a91-646bea3ede0an%40googlegroups.com.