2010-11-15 01:44:37 +03:00
|
|
|
# http://code.google.com/p/hledger/issues/detail?id=23
|
|
|
|
#
|
2012-01-03 12:15:48 +04:00
|
|
|
# 1. original test case, this should balance since price precisions do
|
|
|
|
# not affect the canonical display precisions used for display and balancing
|
2015-07-12 21:54:08 +03:00
|
|
|
hledger -f - print
|
2010-11-15 01:44:37 +03:00
|
|
|
<<<
|
2012-01-03 12:15:48 +04:00
|
|
|
2010/1/1 x
|
|
|
|
A 55.3653 C @ 30.92189512 D
|
|
|
|
A -1712 D
|
2010-11-15 01:44:37 +03:00
|
|
|
>>>
|
2012-01-03 12:15:48 +04:00
|
|
|
2010/01/01 x
|
2017-06-05 07:26:18 +03:00
|
|
|
A 55.3653 C @ 30.92189512 D
|
|
|
|
A -1712 D
|
2010-11-15 01:44:37 +03:00
|
|
|
|
2011-03-12 23:55:49 +03:00
|
|
|
>>>=0
|
|
|
|
|
2012-01-03 12:15:48 +04:00
|
|
|
## 1b. here $'s canonical display precision should be 2 not 4
|
|
|
|
## XXX no, because the inferred amount $1.0049 is observed
|
2015-07-12 21:54:08 +03:00
|
|
|
# hledger -f - print --cost
|
2012-01-03 12:15:48 +04:00
|
|
|
# <<<
|
|
|
|
# 2010/1/1
|
|
|
|
# a $0.00
|
|
|
|
# a 1C @ $1.0049
|
|
|
|
# a
|
|
|
|
# >>>
|
|
|
|
# 2010/01/01
|
|
|
|
# a 0
|
|
|
|
# a $1.00
|
|
|
|
# a $-1.00
|
|
|
|
#
|
|
|
|
# >>>=0
|
|
|
|
|
2011-01-20 04:08:14 +03:00
|
|
|
# 2. and here the price should be printed with its original precision, not
|
2010-11-15 02:29:04 +03:00
|
|
|
# the canonical display precision
|
2017-01-13 18:25:44 +03:00
|
|
|
hledger -f - print --explicit
|
2010-11-15 02:29:04 +03:00
|
|
|
<<<
|
|
|
|
2010/1/1
|
|
|
|
a $0.00
|
|
|
|
a 1C @ $1.0049
|
|
|
|
a
|
|
|
|
>>>
|
2011-01-19 21:55:16 +03:00
|
|
|
2010/01/01
|
2017-06-05 07:26:18 +03:00
|
|
|
a 0
|
|
|
|
a 1C @ $1.0049
|
|
|
|
a $-1.0049
|
2010-11-15 02:29:04 +03:00
|
|
|
|
2011-03-12 23:55:49 +03:00
|
|
|
>>>=0
|
|
|
|
|
2011-01-20 04:08:14 +03:00
|
|
|
# 3. with $'s display precision at 3 or more, this txn should not balance.
|
2010-11-15 02:29:04 +03:00
|
|
|
# The error message shows the difference with full precision.
|
2015-07-12 21:54:08 +03:00
|
|
|
hledger -f - balance --no-total --cost --empty
|
2010-11-15 01:44:37 +03:00
|
|
|
<<<
|
|
|
|
2010/1/1
|
|
|
|
a 1C @ $1.0049
|
|
|
|
a $-1.000
|
2010-11-15 02:29:04 +03:00
|
|
|
>>>2 /off by \$0.0049/
|
2010-11-15 01:44:37 +03:00
|
|
|
>>>= 1
|
2011-03-12 23:55:49 +03:00
|
|
|
|
2011-01-20 04:08:14 +03:00
|
|
|
# 4. with $'s display precision at 2 or less, this txn should balance
|
2015-07-12 21:54:08 +03:00
|
|
|
hledger -f - balance --no-total --cost --empty
|
2010-11-15 01:44:37 +03:00
|
|
|
<<<
|
|
|
|
2010/1/1
|
|
|
|
a 1C @ $1.0049
|
|
|
|
a $-1.00
|
|
|
|
>>>
|
2011-04-22 17:50:05 +04:00
|
|
|
0 a
|
2011-03-12 23:55:49 +03:00
|
|
|
>>>=0
|
|
|
|
|
2011-01-20 04:08:14 +03:00
|
|
|
# 5. avamk's 2011/1/19 example
|
2015-07-12 21:54:08 +03:00
|
|
|
hledger -f - balance --cost
|
2011-01-20 04:08:14 +03:00
|
|
|
<<<
|
|
|
|
2001/01/01 * ACME fund
|
|
|
|
assets:investment:ACME 203.890 ACME @ $16.02
|
|
|
|
equity:opening balances
|
|
|
|
>>>
|
2011-01-21 23:52:56 +03:00
|
|
|
$3266.32 assets:investment:ACME
|
|
|
|
$-3266.32 equity:opening balances
|
|
|
|
--------------------
|
2011-04-22 17:50:05 +04:00
|
|
|
0
|
2011-01-21 23:52:56 +03:00
|
|
|
>>>=0
|
2015-05-28 00:21:19 +03:00
|
|
|
|
2011-01-21 23:52:56 +03:00
|
|
|
# hledger 0.14pre: precision=2, presumably from price
|
2011-01-20 04:08:14 +03:00
|
|
|
# $3266.32 assets:investment:ACME
|
|
|
|
# $-3266.32 equity:opening balances
|
|
|
|
#--------------------
|
|
|
|
# $0.00
|
|
|
|
#
|
2011-01-21 23:52:56 +03:00
|
|
|
# ledger "2.6.0.90" with -s: full precision, ignores price
|
2011-01-20 04:08:14 +03:00
|
|
|
# $3266.3178 assets:investment:ACME
|
|
|
|
# $-3266.3178 equity:opening balances
|
|
|
|
#
|
2011-01-21 23:52:56 +03:00
|
|
|
# ledger 3: precision=0, uses default, ignores price
|
2011-01-20 04:08:14 +03:00
|
|
|
# $3266 assets:investment:ACME
|
|
|
|
# $-3266 equity:opening balances
|
|
|
|
#--------------------
|
|
|
|
# 0
|
2011-01-21 23:52:56 +03:00
|
|
|
|
2015-05-28 00:21:19 +03:00
|
|
|
## 6. with a default commodity.. XXX should observe it
|
2015-07-12 21:54:08 +03:00
|
|
|
hledger -f - balance --cost
|
2011-01-21 23:52:56 +03:00
|
|
|
<<<
|
|
|
|
D $1000.0
|
|
|
|
2001/01/01 * ACME fund
|
|
|
|
assets:investment:ACME 203.890 ACME @ $16.02
|
|
|
|
equity:opening balances
|
|
|
|
>>>
|
|
|
|
$3266.32 assets:investment:ACME
|
|
|
|
$-3266.32 equity:opening balances
|
|
|
|
--------------------
|
2011-04-22 17:50:05 +04:00
|
|
|
0
|
2011-01-21 23:52:56 +03:00
|
|
|
>>>=0
|
|
|
|
### hledger 0.14pre: precision=2, presumably from price, ignores D
|
|
|
|
### $3266.32 assets:investment:ACME
|
|
|
|
### $-3266.32 equity:opening balances
|
|
|
|
###--------------------
|
|
|
|
### $0.00
|
|
|
|
###
|
|
|
|
### ledger "2.6.0.90" with -s: full precision, ignores price and D
|
|
|
|
### $3266.3178 assets:investment:ACME
|
|
|
|
### $-3266.3178 equity:opening balances
|
|
|
|
###
|
|
|
|
### ledger 3: precision=1, ignores price, observes D
|
|
|
|
### $3266.3 assets:investment:ACME
|
|
|
|
### $-3266.3 equity:opening balances
|
|
|
|
###--------------------
|
|
|
|
### 0
|
2015-05-28 00:21:19 +03:00
|
|
|
|
|
|
|
#
|
|
|
|
# 7. when there are multiple postings in the commodity being priced,
|
|
|
|
# show the averaged unit price, with precision equal to the sum of
|
|
|
|
# the max precisions of the commodities being converted (#262).
|
|
|
|
# Here the (irrational) price should be displayed with just precision 4
|
|
|
|
# (C's precision 2 + D's precision 2).
|
2017-01-13 18:25:44 +03:00
|
|
|
hledger -f- print --explicit
|
2015-05-28 00:21:19 +03:00
|
|
|
<<<
|
2016-02-20 08:45:39 +03:00
|
|
|
2015/1/1
|
2015-05-28 00:21:19 +03:00
|
|
|
c C 10.00
|
|
|
|
c C 11.00
|
|
|
|
d D -320.00
|
|
|
|
>>>
|
|
|
|
2015/01/01
|
2017-06-05 07:26:18 +03:00
|
|
|
c C 10.00 @ D 15.2381
|
|
|
|
c C 11.00 @ D 15.2381
|
|
|
|
d D -320.00
|
2015-05-28 00:21:19 +03:00
|
|
|
|
|
|
|
>>>=0
|
|
|
|
|
|
|
|
|
|
|
|
## 8. Here the price should be displayed with precision 7
|
|
|
|
# (E's precision 4 + F's precision 3).
|
2017-01-13 18:25:44 +03:00
|
|
|
hledger -f- print --explicit
|
2015-05-28 00:21:19 +03:00
|
|
|
<<<
|
2016-02-20 08:45:39 +03:00
|
|
|
2015/1/1
|
2015-05-28 00:21:19 +03:00
|
|
|
e E 10.0000
|
|
|
|
e E 11
|
|
|
|
f F -320.000
|
|
|
|
>>>
|
|
|
|
2015/01/01
|
2017-06-05 07:26:18 +03:00
|
|
|
e E 10.0000 @ F 15.2380952
|
|
|
|
e E 11.0000 @ F 15.2380952
|
|
|
|
f F -320.000
|
2015-05-28 00:21:19 +03:00
|
|
|
|
|
|
|
>>>=0
|