From fb180192125956492ce7408a622a45738801c6b1 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 9 May 2019 12:23:51 -0700 Subject: [PATCH] bal: document and test --value-at with --budget (#329) --- hledger/hledger_options.m4.md | 36 +++++++++---------- tests/journal/market-prices.test | 62 ++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 18 deletions(-) diff --git a/hledger/hledger_options.m4.md b/hledger/hledger_options.m4.md index bb0bde58d..dc48b2ec3 100644 --- a/hledger/hledger_options.m4.md +++ b/hledger/hledger_options.m4.md @@ -610,22 +610,22 @@ If you find problems - useless reports, misbehaving reports, or error messages being printed - please report them (with reproducible examples) eg at [#329](https://github.com/simonmichael/hledger/issues/329). -| Report type | `--value-at` `transaction`  | `--value-at` `period`  | `--value-at` `DATE`/`now`  | -|------------------------------------|-----------------------------------------------------------|--------------------------------------------------------------|-------------------------------------------| -|
**print** | | | | -| posting amounts | value at posting date | value at report end | value at DATE | -| balance assertions/assignments | show unvalued | show unvalued | show unvalued | -|
**register** | | | | -| starting balance with -H | value at day before report start | value at day before report start | value at DATE | -| posting amounts | value at posting date | value at report end | value at DATE | -| posting amounts, multiperiod | value each posting at posting date then summarise | value each summary posting at period end | value each summary posting at DATE | -| running total/average | sum/average of the displayed values | sum/average of the displayed values | sum/average of the displayed values | -|
**balance (bs, cf, is..)** | | | | -| starting balances with -H | sum of values of previous postings at their posting dates | value at day before report start of sum of previous postings | value at DATE of sum of previous postings | -| balances, simple balance report | sum of values of each posting at posting date | value at period end of sum of postings | value at DATE of sum of postings | -| balances, multiperiod report | sum of values of each posting at posting date | value at period end of sum of postings | value at DATE of sum of postings | -| column/row/grand totals/averages | sum/average of the displayed values | value at period end of sum/average of postings | value at DATE of sum/average of postings | -| budget amounts in --budget reports | ? | ? | ? | +| Report type | `--value-at` `transaction`  | `--value-at` `period`  | `--value-at` `DATE`/`now`  | +|------------------------------------|-----------------------------------------------------------|--------------------------------------------------------------|-------------------------------------------------| +|
**print** | | | | +| posting amounts | value at posting date | value at report end | value at DATE | +| balance assertions/assignments | show unvalued | show unvalued | show unvalued | +|
**register** | | | | +| starting balance with -H | value at day before report start | value at day before report start | value at DATE | +| posting amounts | value at posting date | value at report end | value at DATE | +| posting amounts, multiperiod | value each posting at posting date then summarise | value each summary posting at period end | value each summary posting at DATE | +| running total/average | sum/average of the displayed values | sum/average of the displayed values | sum/average of the displayed values | +|
**balance (bs, cf, is..)** | | | | +| starting balances with -H | sum of values of previous postings at their posting dates | value at day before report start of sum of previous postings | value at DATE of sum of previous postings | +| balances, simple balance report | sum of values of each posting at posting date | value at period end of sum of postings | value at DATE of sum of postings | +| balances, multiperiod report | sum of values of each posting at posting date | value at period end of sum of postings | value at DATE of sum of postings | +| column/row/grand totals/averages | sum/average of the displayed values | value at period end of sum/average of postings | value at DATE of sum/average of postings | +| budget amounts in --budget reports | budget-setting periodic txns are valued at posting date | budget-setting periodic txns are valued at period end | budget-setting periodic txns are valued at DATE | ### Some useful value reports @@ -639,8 +639,8 @@ Here are some probably useful reports - please send suggestions if you find out ## Combining -B and -V -Using -B/--cost together with -V/--value or --value-at is allowed. -Let us know if you find a use for this. +Using -B/--cost together with -V/--value or --value-at is allowed, but probably not useful. +(Let us know if you find a use for it.) ## Output destination diff --git a/tests/journal/market-prices.test b/tests/journal/market-prices.test index 71a00cd97..be25ae2c5 100644 --- a/tests/journal/market-prices.test +++ b/tests/journal/market-prices.test @@ -492,3 +492,65 @@ Ending balances (historical) in 2000q1: 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: + + || 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: + + || 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: + + || 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]