To reduce confusion, multiperiod balance reports using -H/--historical or --cumulative, which show end balances, no longer show a Totals column since summing end balances generally doesn't make sense. Also the underlying MultiBalanceReport now returns zero for those totals when in cumulative or historical mode.
558 lines
17 KiB
Plaintext
558 lines
17 KiB
Plaintext
# http://hledger.org/journal.html#market-prices
|
|
# http://hledger.org/hledger.html#market-value
|
|
|
|
# 1. Market prices are ignored by -B.
|
|
<
|
|
P 2011/01/01 € $1.35
|
|
|
|
2011/01/01
|
|
expenses:foreign €100
|
|
assets
|
|
|
|
$ hledger -f- bal -NB
|
|
€-100 assets
|
|
€100 expenses:foreign
|
|
|
|
|
|
# 2. Market prices are used by bal -V.
|
|
# Market prices for other commodities are not used.
|
|
# Nor are transaction prices.
|
|
<
|
|
P 2011/01/01 € $1.35
|
|
P 2011/01/01 GBP $1.35
|
|
|
|
2011/01/01
|
|
(expenses:foreign) €100 @ $1.20
|
|
|
|
$ hledger -f- bal -N -V
|
|
$135.00 expenses:foreign
|
|
|
|
|
|
# 3. The location of price directives does not matter.
|
|
# If multiple directives have the same date, the last parsed is used.
|
|
<
|
|
3000/01/01
|
|
(a) $100
|
|
|
|
P 2000/1/1 $ €1.35
|
|
|
|
3000/03/03
|
|
(b) $100
|
|
|
|
P 2000/1/1 $ €1.30
|
|
|
|
$ hledger -f- bal -N -V a
|
|
€130.00 a
|
|
|
|
|
|
# 4. Market prices in the future (later than today's date) are ignored by default. #453, #683
|
|
<
|
|
P 2000/1/1 $ €1.20
|
|
P 3000/1/1 $ €1.30
|
|
|
|
3000/01/01
|
|
(a) $100
|
|
|
|
$ hledger -f- bal -N -V
|
|
€120.00 a
|
|
|
|
|
|
# 5. Market prices in the future are still ignored by default even
|
|
# with an explicit future report end date, unlike hledger 1.14-.
|
|
<
|
|
P 3000/1/1 $ €1.10
|
|
|
|
3000/01/01
|
|
(a) $100
|
|
|
|
$ hledger -f- bal -N -V -e 3000/2
|
|
$100 a
|
|
|
|
|
|
# 6. Market prices interact with D directives and with amount style canonicalisation. #131
|
|
<
|
|
|
|
D 1000.00 H ; declare a default commodity named H
|
|
|
|
P 2015/08/14 EEEE 41.66 ; default commodity H is used for these market prices
|
|
P 2015/08/14 FFFF 74.62
|
|
P 2015/08/14 GGGG 32.39
|
|
|
|
2015/08/15
|
|
a 2.4120 EEEE @@ 100 ; default commodity H is used for these transaction prices
|
|
a 0.3350 FFFF @@ 25
|
|
a 0.7718 GGGG @@ 25
|
|
b ; implicit balancing amount is in the cost commodity, H
|
|
|
|
$ hledger -f- balance -V
|
|
150.48 H a
|
|
-150.00 H b
|
|
--------------------
|
|
0.48 H
|
|
|
|
|
|
# 7. register -V affects posting amounts and total.
|
|
<
|
|
P 2000/1/1 $ €1.20
|
|
2000/1/1
|
|
(a) $100
|
|
|
|
$ hledger -f- reg -V
|
|
2000/01/01 (a) €120.00 €120.00
|
|
|
|
|
|
# 8. print -V affects posting amounts but not balance assertions.
|
|
<
|
|
P 2000/1/1 $ €1.20
|
|
2000/1/1
|
|
(a) $100 = $100
|
|
|
|
$ hledger -f- print -V
|
|
2000/01/01
|
|
(a) €120.00 = $100
|
|
|
|
>=0
|
|
|
|
# --value-at tests
|
|
|
|
<
|
|
P 2000/01/01 A 1 B
|
|
P 2000/01/15 A 5 B
|
|
P 2000/02/01 A 2 B
|
|
P 2000/03/01 A 3 B
|
|
P 2000/04/01 A 4 B
|
|
|
|
2000/01/01
|
|
(a) 1 A
|
|
|
|
2000/02/01
|
|
(a) 1 A
|
|
|
|
2000/03/01
|
|
(a) 1 A
|
|
|
|
# print
|
|
|
|
# 9. print value using prices on transaction (posting) dates
|
|
$ hledger -f- print --value-at=transaction
|
|
2000/01/01
|
|
(a) 1 B
|
|
|
|
2000/02/01
|
|
(a) 2 B
|
|
|
|
2000/03/01
|
|
(a) 3 B
|
|
|
|
>=0
|
|
|
|
# 10. print value using prices on last day of report period (2000-02-29)
|
|
$ hledger -f- print --value-at=period date:2000/01-2000/03
|
|
2000/01/01
|
|
(a) 2 B
|
|
|
|
2000/02/01
|
|
(a) 2 B
|
|
|
|
>=0
|
|
|
|
# 11. print value using prices on last day of report period (no period specified)
|
|
# specified - uses last day of journal (2000-03-01)
|
|
$ hledger -f- print --value-at=period
|
|
2000/01/01
|
|
(a) 3 B
|
|
|
|
2000/02/01
|
|
(a) 3 B
|
|
|
|
2000/03/01
|
|
(a) 3 B
|
|
|
|
>=0
|
|
|
|
# 12. print value using prices on a specified date
|
|
$ hledger -f- print --value-at=2000-01-15
|
|
2000/01/01
|
|
(a) 5 B
|
|
|
|
2000/02/01
|
|
(a) 5 B
|
|
|
|
2000/03/01
|
|
(a) 5 B
|
|
|
|
>=0
|
|
|
|
# 13. print value using prices today
|
|
# (assuming today's date is >= 2000-04-01)
|
|
$ hledger -f- print --value-at=now
|
|
2000/01/01
|
|
(a) 4 B
|
|
|
|
2000/02/01
|
|
(a) 4 B
|
|
|
|
2000/03/01
|
|
(a) 4 B
|
|
|
|
>=0
|
|
|
|
# register
|
|
|
|
# 14. register report valued at transaction.
|
|
# Shows the running total of the posting amount values (not the values
|
|
# of the running total).
|
|
$ hledger -f- reg --value-at=transaction
|
|
2000/01/01 (a) 1 B 1 B
|
|
2000/02/01 (a) 2 B 3 B
|
|
2000/03/01 (a) 3 B 6 B
|
|
|
|
# 15. register report valued at period end
|
|
$ hledger -f- reg --value-at=period
|
|
2000/01/01 (a) 3 B 3 B
|
|
2000/02/01 (a) 3 B 6 B
|
|
2000/03/01 (a) 3 B 9 B
|
|
|
|
# 16. register report valued at specified date
|
|
$ hledger -f- reg --value-at=2000-01-15
|
|
2000/01/01 (a) 5 B 5 B
|
|
2000/02/01 (a) 5 B 10 B
|
|
2000/03/01 (a) 5 B 15 B
|
|
|
|
# 17. register report valued today
|
|
$ hledger -f- reg --value-at=now
|
|
2000/01/01 (a) 4 B 4 B
|
|
2000/02/01 (a) 4 B 8 B
|
|
2000/03/01 (a) 4 B 12 B
|
|
|
|
# 18. register report valued at default date (same as above)
|
|
$ hledger -f- reg -V
|
|
2000/01/01 (a) 4 B 4 B
|
|
2000/02/01 (a) 4 B 8 B
|
|
2000/03/01 (a) 4 B 12 B
|
|
|
|
# register with -H (starting balance)
|
|
|
|
# 19. register with starting balance, valued at transaction.
|
|
# Shows the running total of the posting amount values (not the values of the running total).
|
|
# The starting balance is 1 A, valued at 2000/1/31 (day before report start), which is 5 B.
|
|
$ hledger -f- reg --value-at=transaction -b 200002 -H
|
|
2000/02/01 (a) 2 B 7 B
|
|
2000/03/01 (a) 3 B 10 B
|
|
|
|
# 20. register with starting balance, valued at period end.
|
|
# That is unspecified so the last posting date is used, ie 2000/3/1, so the price is 3 B.
|
|
# Starting balance is 5 B as above.
|
|
$ hledger -f- reg --value-at=period -b 200002 -H
|
|
2000/02/01 (a) 3 B 8 B
|
|
2000/03/01 (a) 3 B 11 B
|
|
|
|
# 21. register with starting balance, valued at specified date (when the price is 5 B).
|
|
# Starting balance is 5 B as above.
|
|
$ hledger -f- reg --value-at=2000-01-15 -b 200002 -H
|
|
2000/02/01 (a) 5 B 10 B
|
|
2000/03/01 (a) 5 B 15 B
|
|
|
|
# register, periodic
|
|
|
|
# 22. periodic register report valued at transaction.
|
|
# The total for january is 6 B (1 A valued at 1/1, price 1 B, and 1 A
|
|
# valued at 1/20, price 5 B).
|
|
# Need an extra transaction for this test:
|
|
<
|
|
P 2000/01/01 A 1 B
|
|
P 2000/01/15 A 5 B
|
|
P 2000/02/01 A 2 B
|
|
P 2000/03/01 A 3 B
|
|
P 2000/04/01 A 4 B
|
|
|
|
2000/01/01
|
|
(a) 1 A
|
|
|
|
2000/01/20
|
|
(a) 1 A
|
|
|
|
2000/02/01
|
|
(a) 1 A
|
|
|
|
2000/03/01
|
|
(a) 1 A
|
|
|
|
$ hledger -f- reg --value-at=transaction -M
|
|
2000/01 a 6 B 6 B
|
|
2000/02 a 2 B 8 B
|
|
2000/03 a 3 B 11 B
|
|
|
|
# back to the original test journal:
|
|
<
|
|
P 2000/01/01 A 1 B
|
|
P 2000/01/15 A 5 B
|
|
P 2000/02/01 A 2 B
|
|
P 2000/03/01 A 3 B
|
|
P 2000/04/01 A 4 B
|
|
|
|
2000/01/01
|
|
(a) 1 A
|
|
|
|
2000/02/01
|
|
(a) 1 A
|
|
|
|
2000/03/01
|
|
(a) 1 A
|
|
|
|
# 23. periodic register report valued at period end
|
|
$ hledger -f- reg --value-at=period -M
|
|
2000/01 a 5 B 5 B
|
|
2000/02 a 2 B 7 B
|
|
2000/03 a 3 B 10 B
|
|
|
|
# 24. periodic register report valued at specified date
|
|
$ hledger -f- reg --value-at=2000-01-15 -M
|
|
2000/01 a 5 B 5 B
|
|
2000/02 a 5 B 10 B
|
|
2000/03 a 5 B 15 B
|
|
|
|
# 25. periodic register report valued today
|
|
$ hledger -f- reg --value-at=now -M
|
|
2000/01 a 4 B 4 B
|
|
2000/02 a 4 B 8 B
|
|
2000/03 a 4 B 12 B
|
|
|
|
# 26. periodic register report valued at default date (same as above)
|
|
$ hledger -f- reg -V -M
|
|
2000/01 a 4 B 4 B
|
|
2000/02 a 4 B 8 B
|
|
2000/03 a 4 B 12 B
|
|
|
|
# balance
|
|
|
|
# 27. single column balance report valued at transaction
|
|
$ hledger -f- bal --value-at=transaction
|
|
6 B a
|
|
--------------------
|
|
6 B
|
|
|
|
# 28. single column balance report valued at period end
|
|
$ hledger -f- bal --value-at=period
|
|
9 B a
|
|
--------------------
|
|
9 B
|
|
|
|
# 29. single column balance report valued at specified date
|
|
$ hledger -f- bal --value-at=2000-01-15
|
|
15 B a
|
|
--------------------
|
|
15 B
|
|
|
|
# 30. single column balance report valued today
|
|
$ hledger -f- bal --value-at=now
|
|
12 B a
|
|
--------------------
|
|
12 B
|
|
|
|
# 31. single column balance report valued at default date (same as above)
|
|
$ hledger -f- bal -V
|
|
12 B a
|
|
--------------------
|
|
12 B
|
|
|
|
# balance, periodic
|
|
|
|
# 32. multicolumn balance report valued at transaction
|
|
$ hledger -f- bal -MTA --value-at=transaction
|
|
Balance changes in 2000q1, valued at transaction dates:
|
|
|
|
|| Jan Feb Mar Total Average
|
|
===++=================================
|
|
a || 1 B 2 B 3 B 6 B 2 B
|
|
---++---------------------------------
|
|
|| 1 B 2 B 3 B 6 B 2 B
|
|
|
|
# 33. multicolumn balance report valued at period end
|
|
$ hledger -f- bal -M --value-at=period
|
|
Balance changes in 2000q1, valued at period ends:
|
|
|
|
|| Jan Feb Mar
|
|
===++===============
|
|
a || 5 B 2 B 3 B
|
|
---++---------------
|
|
|| 5 B 2 B 3 B
|
|
|
|
# 34. multicolumn balance report valued at period end with -T or -A
|
|
$ hledger -f- bal -M --value-at=period -TA
|
|
Balance changes in 2000q1, valued at period ends:
|
|
|
|
|| Jan Feb Mar Total Average
|
|
===++=================================
|
|
a || 5 B 2 B 3 B 9 B 3 B
|
|
---++---------------------------------
|
|
|| 5 B 2 B 3 B 9 B 3 B
|
|
|
|
# 35. multicolumn balance report valued at other date
|
|
$ hledger -f- bal -MTA --value-at=2000-01-15
|
|
Balance changes in 2000q1, valued at 2000/01/15:
|
|
|
|
|| Jan Feb Mar Total Average
|
|
===++=================================
|
|
a || 5 B 5 B 5 B 15 B 5 B
|
|
---++---------------------------------
|
|
|| 5 B 5 B 5 B 15 B 5 B
|
|
|
|
# 36. multicolumn balance report valued today (with today >= 2000-04-01)
|
|
$ hledger -f- bal -M --value-at=now
|
|
Balance changes in 2000q1, current value:
|
|
|
|
|| Jan Feb Mar
|
|
===++===============
|
|
a || 4 B 4 B 4 B
|
|
---++---------------
|
|
|| 4 B 4 B 4 B
|
|
|
|
# 37. multicolumn balance report valued at default date (same as above)
|
|
$ hledger -f- bal -M -V
|
|
Balance changes in 2000q1, current value:
|
|
|
|
|| Jan Feb Mar
|
|
===++===============
|
|
a || 4 B 4 B 4 B
|
|
---++---------------
|
|
|| 4 B 4 B 4 B
|
|
|
|
# balance, periodic, with -H (starting balance and accumulating across periods)
|
|
|
|
# 38. multicolumn balance report with -H valued at transaction.
|
|
# The starting balance is 1 B (1 A valued at 2000/1/1, transaction date).
|
|
$ hledger -f- bal -M -H -b 200002 --value-at=transaction
|
|
Ending balances (historical) in 2000/02/01-2000/03/31, valued at transaction dates:
|
|
|
|
|| 2000/02/29 2000/03/31
|
|
===++========================
|
|
a || 3 B 6 B
|
|
---++------------------------
|
|
|| 3 B 6 B
|
|
|
|
# 39. multicolumn balance report with -H valued at period end.
|
|
# The starting balance is 5 B (1 A valued at 2000/1/31, day before report start).. and has no effect here.
|
|
$ hledger -f- bal -M -H -b 200002 --value-at=period
|
|
Ending balances (historical) in 2000/02/01-2000/03/31, valued at period ends:
|
|
|
|
|| 2000/02/29 2000/03/31
|
|
===++========================
|
|
a || 4 B 9 B
|
|
---++------------------------
|
|
|| 4 B 9 B
|
|
|
|
# 40. multicolumn balance report with -H valued at other date.
|
|
# The starting balance is 5 B (1 A valued at 2000/1/15).
|
|
$ hledger -f- bal -M -H -b 200002 --value-at=2000-01-15
|
|
Ending balances (historical) in 2000/02/01-2000/03/31, valued at 2000/01/15:
|
|
|
|
|| 2000/02/29 2000/03/31
|
|
===++========================
|
|
a || 10 B 15 B
|
|
---++------------------------
|
|
|| 10 B 15 B
|
|
|
|
# 41. multicolumn balance report with -H, valuing each period's carried-over balances at transaction date.
|
|
<
|
|
P 2000/01/01 A 1 B
|
|
P 2000/01/15 A 5 B
|
|
P 2000/02/01 A 2 B
|
|
P 2000/03/01 A 3 B
|
|
P 2000/04/01 A 4 B
|
|
|
|
2000/01/01
|
|
(a) 1 A
|
|
|
|
$ hledger -f- bal -ME -H -p200001-200004 --value-at=t
|
|
Ending balances (historical) in 2000q1, valued at transaction dates:
|
|
|
|
|| 2000/01/31 2000/02/29 2000/03/31
|
|
===++====================================
|
|
a || 1 B 1 B 1 B
|
|
---++------------------------------------
|
|
|| 1 B 1 B 1 B
|
|
|
|
# 42. multicolumn balance report with -H, valuing each period's carried-over balances at period end.
|
|
# Unrelated, also -H always disables -T.
|
|
$ hledger -f- bal -META -H -p200001-200004 --value-at=p
|
|
Ending balances (historical) in 2000q1, valued at period ends:
|
|
|
|
|| 2000/01/31 2000/02/29 2000/03/31 Average
|
|
===++=============================================
|
|
a || 5 B 2 B 3 B 3 B
|
|
---++---------------------------------------------
|
|
|| 5 B 2 B 3 B 3 B
|
|
|
|
# 43. multicolumn balance report with -H, valuing each period's carried-over balances at other date.
|
|
$ hledger -f- bal -ME -H -p200001-200004 --value-at=2000-01-15
|
|
Ending balances (historical) in 2000q1, valued at 2000/01/15:
|
|
|
|
|| 2000/01/31 2000/02/29 2000/03/31
|
|
===++====================================
|
|
a || 5 B 5 B 5 B
|
|
---++------------------------------------
|
|
|| 5 B 5 B 5 B
|
|
|
|
# balance --budget. The periodic transactions setting budget amounts
|
|
# are valued in the same way as ordinary transactions.
|
|
|
|
<
|
|
P 2000/01/01 A 1 B
|
|
P 2000/01/15 A 5 B
|
|
P 2000/02/01 A 2 B
|
|
P 2000/03/01 A 3 B
|
|
P 2000/04/01 A 4 B
|
|
|
|
~ monthly
|
|
(a) 2 A
|
|
|
|
2000/01/01
|
|
(a) 1 A
|
|
|
|
2000/02/01
|
|
(a) 1 A
|
|
|
|
2000/03/01
|
|
(a) 1 A
|
|
|
|
# 44. budget report, unvalued (for reference).
|
|
$ hledger -f- bal -M --budget
|
|
Budget performance in 2000q1:
|
|
|
|
|| Jan Feb Mar
|
|
===++============================================================
|
|
a || 1 A [ 50% of 2 A] 1 A [ 50% of 2 A] 1 A [ 50% of 2 A]
|
|
---++------------------------------------------------------------
|
|
|| 1 A [ 50% of 2 A] 1 A [ 50% of 2 A] 1 A [ 50% of 2 A]
|
|
|
|
# 45. budget report, valued at transaction dates.
|
|
$ hledger -f- bal -MTA --budget --value-at=t
|
|
Budget performance in 2000q1, valued at transaction dates:
|
|
|
|
|| Jan Feb Mar Total Average
|
|
===++=====================================================================================================
|
|
a || 1 B [ 50% of 2 B] 2 B [ 50% of 4 B] 3 B [ 50% of 6 B] 6 B [ 50% of 12 B] 2 B [ 50% of 4 B]
|
|
---++-----------------------------------------------------------------------------------------------------
|
|
|| 1 B [ 50% of 2 B] 2 B [ 50% of 4 B] 3 B [ 50% of 6 B] 6 B [ 50% of 12 B] 2 B [ 50% of 4 B]
|
|
|
|
# 46. budget report, valued at period ends.
|
|
$ hledger -f- bal -MTA --budget --value-at=p
|
|
Budget performance in 2000q1, valued at period ends:
|
|
|
|
|| Jan Feb Mar Total Average
|
|
===++=========================================================================================================
|
|
a || 5 B [ 50% of 10 B] 2 B [ 50% of 4 B] 3 B [ 50% of 6 B] 9 B [ 50% of 18 B] 3 B [ 50% of 6 B]
|
|
---++---------------------------------------------------------------------------------------------------------
|
|
|| 5 B [ 50% of 10 B] 2 B [ 50% of 4 B] 3 B [ 50% of 6 B] 9 B [ 50% of 18 B] 3 B [ 50% of 6 B]
|
|
|
|
# 47. budget report, valued at other date.
|
|
$ hledger -f- bal -MTA --budget --value-at=2000-01-15
|
|
Budget performance in 2000q1, valued at 2000/01/15:
|
|
|
|
|| Jan Feb Mar Total Average
|
|
===++==========================================================================================================
|
|
a || 5 B [ 50% of 10 B] 5 B [ 50% of 10 B] 5 B [ 50% of 10 B] 15 B [ 50% of 30 B] 5 B [ 50% of 10 B]
|
|
---++----------------------------------------------------------------------------------------------------------
|
|
|| 5 B [ 50% of 10 B] 5 B [ 50% of 10 B] 5 B [ 50% of 10 B] 15 B [ 50% of 30 B] 5 B [ 50% of 10 B]
|