hledger/hledger/test/register/intervals.test

250 lines
9.3 KiB
Plaintext

# * register command with report intervals
# ** 1. monthly reporting interval, no end dates, shows just the intervals with data:
<
2011/2/1
(a) 1
(a:b) 1
$ hledger -f- register --period 'monthly'
2011-02 a 1 1
a:b 1 2
# ** 2. or with a query pattern, just the intervals with matched data:
<
2011/1/1
(a) 1
2011/2/1
(b) 1
$ hledger -f- register --period 'monthly' b
2011-02 b 1 1
<
2011/1/1
(a) 1
2011/2/1
(b) 1
2011/3/1
(c) 1
# ** 3. with --empty, show all intervals spanned by the journal
# (unlike current ledger, but more useful)
$ hledger -f- register --period 'monthly' b --empty
2011-01 0 0
2011-02 b 1 1
2011-03 0 1
# ** 4. any specified begin/end dates limit the intervals reported
$ hledger -f- register --period 'monthly to 2011/3/1' b --empty
2011-01 0 0
2011-02 b 1 1
# ** 5. --date2 should work with intervals
<
2014/1/1
(a) 1
2014/2/1=2014/1/31
(b) 1
$ hledger -f- register --monthly --date2
2014-01 a 1 1
b 1 2
#
<
2014/1/5
(before report period) 1
2014/2/1
(explicit report period) 10
2014/2/25
(expanded report period) 100
2014/3/12
(after report period) 1000
# ** 6. Here, the report interval is monthly (interval size is one month)
# but the explicitly-specified start date causes report periods to start there.
# And the end date is expanded to make a whole month-long last period.
$ hledger -f- register -p 'monthly 2014/1/10-2014/2/20'
2014-01-10..2014-02-09 explicit report period 10 10
2014-02-10..2014-03-09 expanded report period 100 110
# ** 7. Here no definite start date has been specifed so it is inferred from the journal
# (2014/1/5), but it is specified to be a tuesday, so that is adjusted to
# the nearest previous tuesday (2013/12/31).
# No end date has been specified so it is inferred from the journal (2014/3/11),
# but that is adjusted to make a whole week-long last period (2014/3/18).
# -E is required here to see the empty weeks.
$ hledger -f- register -p 'every tue' -E
2013-12-31..2014-01-06 before report period 1 1
2014-01-07..2014-01-13 0 1
2014-01-14..2014-01-20 0 1
2014-01-21..2014-01-27 0 1
2014-01-28..2014-02-03 explicit report period 10 11
2014-02-04..2014-02-10 0 11
2014-02-11..2014-02-17 0 11
2014-02-18..2014-02-24 0 11
2014-02-25..2014-03-03 expanded report period 100 111
2014-03-04..2014-03-10 0 111
2014-03-11..2014-03-17 after report period 1000 1111
# ** 8. "in 2014-02" is considered to explicitly specify a start date of 2014/2/1
# (a saturday), forcing the periods to start there.
$ hledger -f- register -p 'weekly in 2014-02' -E
2014-02-01..2014-02-07 explicit report period 10 10
2014-02-08..2014-02-14 0 10
2014-02-15..2014-02-21 0 10
2014-02-22..2014-02-28 expanded report period 100 110
# ** 9. So to see simple monday-based week periods here, you must specify a start date
# that is a monday.
$ hledger -f- register -p 'weekly from 2014-01-27 to 2014-03' -E
2014-W05 explicit report period 10 10
2014-W06 0 10
2014-W07 0 10
2014-W08 0 10
2014-W09 expanded report period 100 110
# ** 10. The last report interval option takes precedence.
# Also, here the -p option specifies an explicit start date which is used,
# and the end date is adjusted to contain a whole number of report intervals,
# overriding the specified end date.
<
2019-01-01
(a) 2
2019-02-01
(a) 1
$ hledger -f- register -p 'weekly from 2019/2/1 to 2019/6/1' --monthly --yearly
2019-02-01..2020-01-31 a 1 1
# --monthly and -p 'monthly ...' are equivalent (#1008):
# ** 11. --monthly
$ hledger -f- register --monthly
2019-01 a 2 2
2019-02 a 1 3
# ** 12. -p 'monthly'
$ hledger -f- register -p monthly
2019-01 a 2 2
2019-02 a 1 3
# ** Date adjustment/clipping, with various intervals, of periodic reports and periodic transactions.
# With periodic reports generally:
# Start dates should be within the specified report period.
# If start date is unspecifed, it should be the inferred start date adjusted to a natural boundary.
# The end date should be adjusted so that the last period has equal length.
# With periodic transactions generally:
# All occurrences should be within the specified report period.
# If start date is unspecifed, it should be the inferred start date adjusted to a natural boundary.
# The end date should be adjusted so that the gap before last occurrence has equal length. (?)
# ** 13. every Nth day of month from DATE.
<
2024-01-02
(monthly1/02) 1
2024-01-10
(monthly1/10) 1
2024-02-20
(monthly2/20) 1
2024-02-24
(monthly2/24) 1
$ hledger -f- reg monthly -p 'every 5th day of month from 2024/1/5 to 2024/2/14'
2024-01-05..2024-02-04 monthly1/10 1 1
2024-02-05..2024-03-04 monthly2/20 1 2
monthly2/24 1 3
# ** 14. every Nth day of month from DATE, periodic transactions. #2218, fixed in 1.40.
<
~ every 31st day from 2024-07 to 2024-09
(a) 1
$ hledger -f- reg --forecast=2024
2024-07-31 (a) 1 1
2024-08-31 (a) 1 2
# ** 15. every M/D from DATE. Fixed in 1.40.
<
2023-01-10
(yearly2023/1/10) 1
2024-01-10
(yearly2024/1/10) 1
2025-01-10
(yearly2025/1/10) 1
2026-01-10
(yearly2026/1/10) 1
$ hledger -f- reg yearly -p 'every 1/20 from 2024 to 2026'
2024-01-20..2025-01-19 yearly2025/1/10 1 1
2025-01-20..2026-01-19 yearly2026/1/10 1 2
# ** 16. every M/D from DATE, periodic transactions. Fixed in 1.40.
<
~ every 14th February from 2024 to 2026
(yearly) 1
$ hledger -f- reg yearly --forecast=2022-2027
2024-02-14 (yearly) 1 1
2025-02-14 (yearly) 1 2
# ** 17. every Nth WEEKDAY, inferred start date.
# The start date is adjusted to 2023/12/11, encompassing the 2024/1/1 posting.
<
2024-01-01
(mondays2024/01/01) 1
2024-01-08
(mondays2024/01/08) 1
2024-01-15
(mondays2024/01/15) 1
2024-02-05
(mondays2024/02/05) 1
2024-02-12
(mondays2024/02/12) 1
2024-02-19
(mondays2024/02/19) 1
$ hledger -f- reg mondays -p 'every 2nd monday'
2023-12-11..2024-01-07 mondays2024/01/01 1 1
2024-01-08..2024-02-11 mondays2024/01/08 1 2
mondays2024/01/15 1 3
mondays2024/02/05 1 4
2024-02-12..2024-03-10 mondays2024/02/12 1 5
mondays2024/02/19 1 6
# ** 18. every Nth WEEKDAY from DATE. Fixed in 1.40.
$ hledger -f- reg mondays -p 'every 2nd monday from 2024/1/5 to 2024/2'
2024-01-08..2024-02-11 mondays2024/01/08 1 1
mondays2024/01/15 1 2
mondays2024/02/05 1 3
# ** 19. every Nth WEEKDAY from DATE, periodic transactions.
<
~ every 2nd monday from 2024/1/5 to 2024/3
(mondays) 1
$ hledger -f- reg mondays --forecast=2024
2024-01-08 (mondays) 1 1
2024-02-12 (mondays) 1 2