2018-08-17 11:37:55 +03:00
|
|
|
# Test generation of periodic transactions with --forecast.
|
|
|
|
# Note periodic transaction tests should include a regular transaction
|
|
|
|
# to pin the start date of forecasted transactions.
|
|
|
|
|
2018-06-12 01:30:12 +03:00
|
|
|
# 1. A balance report with forecasted transactions.
|
2017-11-18 03:40:10 +03:00
|
|
|
hledger bal -M -b 2016-11 -e 2017-02 -f - --forecast
|
|
|
|
<<<
|
|
|
|
2016/12/31
|
|
|
|
expenses:housing $600
|
|
|
|
assets:cash
|
|
|
|
|
|
|
|
~ monthly from 2016/1
|
|
|
|
income $-1000
|
|
|
|
expenses:food $20
|
|
|
|
expenses:leisure $15
|
|
|
|
expenses:grocery $30
|
|
|
|
assets:cash
|
|
|
|
>>>
|
2020-01-06 20:55:52 +03:00
|
|
|
Balance changes in 2016-12-01-2017-01-31:
|
2017-11-18 03:40:10 +03:00
|
|
|
|
2018-03-29 16:54:36 +03:00
|
|
|
|| Dec Jan
|
|
|
|
==================++===============
|
|
|
|
assets:cash || $-600 $935
|
|
|
|
expenses:food || 0 $20
|
|
|
|
expenses:grocery || 0 $30
|
|
|
|
expenses:housing || $600 0
|
|
|
|
expenses:leisure || 0 $15
|
|
|
|
income || 0 $-1000
|
|
|
|
------------------++---------------
|
|
|
|
|| 0 0
|
2017-11-18 03:40:10 +03:00
|
|
|
>>>2
|
|
|
|
>>>=0
|
|
|
|
|
|
|
|
|
2018-06-12 01:30:12 +03:00
|
|
|
# 2. print forecasted transactions, with status and description.
|
2017-11-18 03:40:10 +03:00
|
|
|
hledger print -b 2016-11 -e 2017-02 -f - --forecast
|
|
|
|
<<<
|
|
|
|
2016/12/31
|
|
|
|
expenses:housing $600
|
|
|
|
assets:cash
|
|
|
|
|
2018-06-09 17:30:49 +03:00
|
|
|
~ monthly from 2016/1 * marked cleared, and with a description
|
2017-11-18 03:40:10 +03:00
|
|
|
income $-1000
|
|
|
|
expenses:food $20
|
|
|
|
expenses:leisure $15
|
|
|
|
expenses:grocery $30
|
|
|
|
assets:cash
|
|
|
|
>>>
|
2019-12-30 08:19:50 +03:00
|
|
|
2016-12-31
|
2017-11-18 03:40:10 +03:00
|
|
|
expenses:housing $600
|
|
|
|
assets:cash
|
|
|
|
|
2019-12-30 08:19:50 +03:00
|
|
|
2017-01-01 * marked cleared, and with a description
|
2019-10-02 09:30:31 +03:00
|
|
|
; generated-transaction: ~ monthly from 2016/1
|
2017-11-18 03:40:10 +03:00
|
|
|
income $-1000
|
|
|
|
expenses:food $20
|
|
|
|
expenses:leisure $15
|
|
|
|
expenses:grocery $30
|
|
|
|
assets:cash
|
|
|
|
|
|
|
|
>>>2
|
|
|
|
>>>=0
|
|
|
|
|
|
|
|
|
2018-06-12 01:30:12 +03:00
|
|
|
# 3. A register with forecasted transactions, with a comment and tag.
|
2018-06-09 17:30:49 +03:00
|
|
|
hledger register -b 2016-11 -e 2017-02 -f - --forecast tag:a
|
2017-11-18 03:40:10 +03:00
|
|
|
<<<
|
|
|
|
2016/12/31
|
|
|
|
expenses:housing $600
|
|
|
|
assets:cash
|
|
|
|
|
2018-06-09 17:30:49 +03:00
|
|
|
~ monthly from 2016/1 ; or a comment, maybe with a:tag
|
2017-11-18 03:40:10 +03:00
|
|
|
income $-1000
|
|
|
|
expenses:food $20
|
|
|
|
expenses:leisure $15
|
|
|
|
expenses:grocery $30
|
|
|
|
assets:cash
|
|
|
|
>>>
|
2019-12-30 08:19:50 +03:00
|
|
|
2017-01-01 income $-1000 $-1000
|
2017-11-18 03:40:10 +03:00
|
|
|
expenses:food $20 $-980
|
|
|
|
expenses:leisure $15 $-965
|
|
|
|
expenses:grocery $30 $-935
|
|
|
|
assets:cash $935 0
|
|
|
|
>>>2
|
|
|
|
>>>=0
|
|
|
|
|
2018-06-12 01:30:12 +03:00
|
|
|
# 4. Check that --forecast generates transactions only after last transaction date in journal.
|
2017-11-18 03:40:10 +03:00
|
|
|
hledger register -b 2015-12 -e 2017-02 -f - assets:cash --forecast
|
|
|
|
<<<
|
|
|
|
2016/01/01
|
|
|
|
expenses:fun $10 ; more fireworks
|
|
|
|
assets:cash
|
|
|
|
|
|
|
|
2016/12/02
|
|
|
|
expenses:housing $600
|
|
|
|
assets:cash
|
|
|
|
|
|
|
|
~ yearly from 2016
|
|
|
|
income $-10000 ; bonus
|
|
|
|
assets:cash
|
|
|
|
>>>
|
2019-12-30 08:19:50 +03:00
|
|
|
2016-01-01 assets:cash $-10 $-10
|
|
|
|
2016-12-02 assets:cash $-600 $-610
|
|
|
|
2017-01-01 assets:cash $10000 $9390
|
2017-11-18 03:40:10 +03:00
|
|
|
>>>2
|
|
|
|
>>>=0
|
2018-10-09 18:17:16 +03:00
|
|
|
|
2018-10-09 21:54:40 +03:00
|
|
|
# 5. Y affects M/D partial dates in periodic transactions.
|
|
|
|
# The recur tag shows the original period expression and is not modified.
|
|
|
|
hledger -f - print --forecast desc:forecast
|
|
|
|
<<<
|
|
|
|
Y 2000
|
|
|
|
|
2018-11-14 05:14:54 +03:00
|
|
|
~ 2/1 forecast
|
2018-10-09 21:54:40 +03:00
|
|
|
|
|
|
|
; a real transaction to set the start of the forecast window
|
|
|
|
2000/1/1 real
|
|
|
|
|
|
|
|
>>>
|
2019-12-30 08:19:50 +03:00
|
|
|
2000-02-01 forecast
|
2019-10-02 09:30:31 +03:00
|
|
|
; generated-transaction: ~ 2/1
|
2018-10-09 21:54:40 +03:00
|
|
|
|
|
|
|
>>>2
|
|
|
|
>>>=0
|
|
|
|
|
|
|
|
# 6. Y also sets the month to 1, affecting D dates:
|
|
|
|
hledger -f - print --forecast desc:forecast
|
|
|
|
<<<
|
|
|
|
Y 2000
|
|
|
|
|
2018-11-14 05:14:54 +03:00
|
|
|
~ 15 forecast
|
2018-10-09 21:54:40 +03:00
|
|
|
|
|
|
|
; a real transaction to set the start of the forecast window
|
|
|
|
2000/1/1 real
|
|
|
|
|
|
|
|
>>>
|
2019-12-30 08:19:50 +03:00
|
|
|
2000-01-15 forecast
|
2019-10-02 09:30:31 +03:00
|
|
|
; generated-transaction: ~ 15
|
2018-10-09 21:54:40 +03:00
|
|
|
|
|
|
|
>>>2
|
|
|
|
>>>=0
|
|
|
|
|
|
|
|
# 7. Y also sets the day to 1, affecting relative dates:
|
|
|
|
hledger -f - print --forecast desc:forecast
|
|
|
|
<<<
|
|
|
|
Y 2000
|
|
|
|
|
2018-11-14 05:14:54 +03:00
|
|
|
~ next month forecast
|
2018-10-09 21:54:40 +03:00
|
|
|
|
|
|
|
; a real transaction to set the start of the forecast window
|
|
|
|
2000/1/1 real
|
|
|
|
|
|
|
|
>>>
|
2019-12-30 08:19:50 +03:00
|
|
|
2000-02-01 forecast
|
2019-10-02 09:30:31 +03:00
|
|
|
; generated-transaction: ~ next month
|
2018-10-09 21:54:40 +03:00
|
|
|
|
|
|
|
>>>2
|
|
|
|
>>>=0
|