166 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			166 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
# Amounts, commodity symbols, commodity directives, amount styles.. 
 | 
						|
 | 
						|
# 1. decimal point/digit grouping chars are autodetected, 
 | 
						|
# separately for each commodity, which can be surprising. TODO
 | 
						|
# So hledger parses 1 XAU at 1000 USD here:
 | 
						|
<
 | 
						|
1/1
 | 
						|
    assets:gold  1,000 XAU @ 1,000.00 USD
 | 
						|
    equity 
 | 
						|
$ hledger -f - bal --flat --no-total -B
 | 
						|
        1,000.00 USD  assets:gold
 | 
						|
       -1,000.00 USD  equity
 | 
						|
 | 
						|
# while ledger parses 1000 XAU at 1000 USD each:
 | 
						|
# $ ledger bal --flat --no-total -B
 | 
						|
#           USD1000000  assets:gold
 | 
						|
#          USD-1000000  equity)
 | 
						|
 | 
						|
# a commodity may contain/end with numbers, if double quoted
 | 
						|
# 2. without quotes, fail. XXX parse error should be clearer here
 | 
						|
<
 | 
						|
2010-04-05 x
 | 
						|
   a   10 DE0002635307
 | 
						|
   b
 | 
						|
$ hledger -f- print
 | 
						|
>2 /unexpected/
 | 
						|
>= 1
 | 
						|
 | 
						|
# 3. with quotes, ok; quotes appear in print output
 | 
						|
<
 | 
						|
2010-04-05 x
 | 
						|
   a   10 "DE 0002 635307"
 | 
						|
   b
 | 
						|
$ hledger -f- print --explicit
 | 
						|
2010-04-05 x
 | 
						|
    a     10 "DE 0002 635307"
 | 
						|
    b    -10 "DE 0002 635307"
 | 
						|
 | 
						|
>=
 | 
						|
 | 
						|
# 4. and in other reports too, I guess
 | 
						|
$ hledger -f- balance
 | 
						|
 10 "DE 0002 635307"  a
 | 
						|
-10 "DE 0002 635307"  b
 | 
						|
--------------------
 | 
						|
                   0
 | 
						|
 | 
						|
# 5. autobalance with prices
 | 
						|
<
 | 
						|
2016/1/1
 | 
						|
    saving-card  $-105
 | 
						|
    snacks  95 EUR @@ $100
 | 
						|
    Equity:Unbalanced
 | 
						|
 | 
						|
$ hledger -f- print -x
 | 
						|
2016-01-01
 | 
						|
    saving-card                   $-105
 | 
						|
    snacks               95 EUR @@ $100
 | 
						|
    Equity:Unbalanced                $5
 | 
						|
 | 
						|
>=
 | 
						|
 | 
						|
# 6. The four decimal places of the market price should not alter the
 | 
						|
# canonical style of two decimal places in a's converted-to-B balance
 | 
						|
# (#295), but it turns out they do with -V. This can be fixed with a
 | 
						|
# commodity directive.
 | 
						|
<
 | 
						|
; use a commodity directive to ensure B is displayed with two decimal
 | 
						|
; places, or the price directive plus -V would make it four
 | 
						|
commodity 1.00 B
 | 
						|
 | 
						|
P 2015/1/1 A 1.0001 B
 | 
						|
 | 
						|
2015/1/1
 | 
						|
    (a)  1.00 A
 | 
						|
    (b)  1.00 B
 | 
						|
$ hledger -f- bal -V -N
 | 
						|
              1.00 B  a
 | 
						|
              1.00 B  b
 | 
						|
 | 
						|
# 7. A multi-line commodity directive also works.
 | 
						|
<
 | 
						|
commodity B
 | 
						|
  format 1.00 B
 | 
						|
 | 
						|
P 2015/1/1 A 1.0001 B
 | 
						|
 | 
						|
2015/1/1
 | 
						|
    (a)  1.00 A
 | 
						|
    (b)  1.00 B
 | 
						|
 | 
						|
$ hledger -f- bal -V -N
 | 
						|
              1.00 B  a
 | 
						|
              1.00 B  b
 | 
						|
 | 
						|
# TODO
 | 
						|
# 8. From the first amount it should detect that decimal point is period, 
 | 
						|
# from the second it should detect that there are comma-separated digit groups of size 3,
 | 
						|
# giving commodity A a canonical style of 1,000.00 A.
 | 
						|
#<
 | 
						|
#2015/1/1
 | 
						|
#    (a)  1000.00 A
 | 
						|
#
 | 
						|
#2015/1/1
 | 
						|
#    (a)    1,000 A
 | 
						|
#
 | 
						|
#$ hledger -f- print
 | 
						|
#2015-01-01
 | 
						|
#    (a)    1,000.00 A
 | 
						|
#
 | 
						|
#2015-01-01
 | 
						|
#    (a)    1,000.00 A
 | 
						|
#
 | 
						|
#>=
 | 
						|
 | 
						|
# TODO #749
 | 
						|
 | 
						|
# 8. Here the amount is parsed as 1. I think (hope) no country uses space 
 | 
						|
# for decimal point, so we should parse this as 1000.
 | 
						|
<
 | 
						|
2018-01-01
 | 
						|
 (a)   USD1 000
 | 
						|
 | 
						|
$ hledger -f- reg amt:1
 | 
						|
 | 
						|
# 9. This commodity directive should complain about a missing decimal separator,
 | 
						|
# which we now require.
 | 
						|
<
 | 
						|
commodity 1 000  USD
 | 
						|
 | 
						|
2018-01-01
 | 
						|
  (a)   USD1 000
 | 
						|
 | 
						|
$ hledger -f- bal
 | 
						|
>2 /decimal point or decimal comma/
 | 
						|
>=1
 | 
						|
 | 
						|
# 10. After a space-grouped amount, a posting comment should parse.
 | 
						|
<
 | 
						|
2018-01-01
 | 
						|
  (a)   USD 1 000  ;comment
 | 
						|
 | 
						|
$ hledger -f- print
 | 
						|
> //    # any stdout, no stderr, 0 exit code
 | 
						|
 | 
						|
# 11. After a space-grouped amount, trailing whitespace should parse.
 | 
						|
<
 | 
						|
2018-01-01
 | 
						|
  (a)   USD 1 000 
 | 
						|
 | 
						|
$ hledger -f- print
 | 
						|
> //    # any stdout, no stderr, 0 exit code
 | 
						|
 | 
						|
# 12. Example of surprising decimal mark parsing behaviour.
 | 
						|
# Without a commodity declaration, these amounts are parsed as 10 and 10000.
 | 
						|
# <
 | 
						|
# 2000/1/1
 | 
						|
#     a                $-10,000
 | 
						|
#     b                 $10,000.00
 | 
						|
#
 | 
						|
# $ hledger -f- print
 | 
						|
# could not balance this transaction (real postings are off by $9,990,000)
 | 
						|
# 2000-01-01
 | 
						|
#     a        $-10,000
 | 
						|
#     b     $10,000,000
 |