D directives are now fully equivalent to commodity directives for setting a commodity's display style. (Previously it was equivalent to a posting amount, so it couldn't limit the number of decimal places.) When both kinds of directive exist, commodity directives take precedence. When there are multiple D directives in the journal, only the last one affects display style.
		
			
				
	
	
		
			90 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			90 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| # a default commodity defined with the D directive will be used for any
 | |
| # subsequent commodity-less posting amounts. The sample amount's display style
 | |
| # is also applied, and the resulting amount may end up setting the canonical
 | |
| # display style for the commodity.
 | |
| 
 | |
| # 1. no default commodity
 | |
| <
 | |
| 2010/1/1
 | |
|   a  1000
 | |
|   b
 | |
| 
 | |
| $ hledger -f- print
 | |
| 2010-01-01
 | |
|     a            1000
 | |
|     b
 | |
| 
 | |
| >=0
 | |
| 
 | |
| # 2. pound, two decimal places, no digit group separator
 | |
| <
 | |
| D £1000.00
 | |
| 2010/1/1
 | |
|   a  1000
 | |
|   b
 | |
| 
 | |
| $ hledger -f- print
 | |
| 2010-01-01
 | |
|     a        £1000.00
 | |
|     b
 | |
| 
 | |
| >=0
 | |
| 
 | |
| # 3. dollar, comma decimal point, three decimal places, no digit group separator
 | |
| <
 | |
| D $1,000
 | |
| 2010/1/1
 | |
|   a  1000
 | |
|   b
 | |
| 
 | |
| $ hledger -f- print
 | |
| 2010-01-01
 | |
|     a       $1000,000
 | |
|     b
 | |
| 
 | |
| >=0
 | |
| 
 | |
| # 4. dollar, three digit group separator, one decimal place
 | |
| <
 | |
| D $1,000.0
 | |
| 2010/1/1
 | |
|   (a)  1000000
 | |
| 
 | |
| $ hledger -f- print
 | |
| 2010-01-01
 | |
|     (a)    $1,000,000.0
 | |
| 
 | |
| >=0
 | |
| 
 | |
| # 5. A D directive affects all aspects of display style, 
 | |
| # including limiting the display precision, like a commodity directive (#1187).
 | |
| <
 | |
| D 1,000.0 A
 | |
| 1/1
 | |
|   (a)  1000.123
 | |
| 
 | |
| $ hledger -f- print
 | |
| 2020-01-01
 | |
|     (a)       1,000.1 A
 | |
| 
 | |
| >=0
 | |
| 
 | |
| # 6. A default commodity should not affect parsing of 
 | |
| # automated posting multiplier amounts.
 | |
| <
 | |
| D $1000.
 | |
| 
 | |
| = a
 | |
|   (b)  *2
 | |
| 
 | |
| 2018/1/1
 | |
|   (a)  €1
 | |
| 
 | |
| $ hledger -f- print --auto
 | |
| 2018-01-01  ; modified:
 | |
|     (a)              €1
 | |
|     (b)              €2  ; generated-posting: = a
 | |
| 
 | |
| >=0
 | |
| 
 |