cheatsheets/hledger.md

182 lines
3.3 KiB
Markdown
Raw Permalink Normal View History

2015-12-04 01:48:43 +00:00
---
title: Hledger
category: Ledger
---
### About
{: .-intro}
- <https://hledger.org>
- <https://hledger.org/quickstart.html>
### Reporting
2015-12-04 01:48:43 +00:00
```
2015-12-09 18:34:55 +00:00
hledger bal {query}
hledger reg {query}
2015-12-04 01:48:43 +00:00
```
2015-12-09 18:23:16 +00:00
## Query
2015-12-09 18:34:55 +00:00
### Queries
2016-08-11 10:26:59 +00:00
Queries are used on all commands (`bal`, `reg`, etc). [(docs)](http://hledger.org/manual.html#queries)
2015-12-04 01:48:43 +00:00
```
2015-12-09 18:20:59 +00:00
Assets # An account (regex)
acct:Assets # same
^Assets # Starting with Assets (eg, not 'Expenses:Assets')
2015-12-04 01:48:43 +00:00
2015-12-09 18:20:59 +00:00
acctonly:A # no subaccounts
2015-12-04 01:48:43 +00:00
2015-12-09 18:20:59 +00:00
amt:2000 # amount (in absolute value)
amt:<200 # amount comparison (in absolute value)
amt:<+200 # amount comparison
# also: <=, >, >=
2015-12-04 01:48:43 +00:00
2016-08-11 10:26:59 +00:00
desc:REGEX # description
code:REGEX # transaction code (check number?)
2015-12-09 18:23:16 +00:00
tag:REGEX
2015-12-04 01:48:43 +00:00
cur:'\$'
2015-12-09 18:23:16 +00:00
2016-08-11 10:26:59 +00:00
real: # real posts
real:0 # virtual posts
2015-12-09 18:20:59 +00:00
depth:N # --depth 2
not:... # eg, not:status:!
2015-12-04 01:48:43 +00:00
```
2015-12-09 18:23:16 +00:00
### Filter by status/type
2015-12-04 01:48:43 +00:00
```
2015-12-09 18:20:59 +00:00
real:1 # -R, --real, no virtuals
status:! # --pending
status:* # -C, --cleared
status: # --uncleared
2015-12-04 01:48:43 +00:00
```
2015-12-09 18:19:43 +00:00
### Periods
2015-12-09 18:34:55 +00:00
For dates and intervals (see above).
2015-12-04 01:48:43 +00:00
```
date:2015/01/01
2015-12-09 18:20:59 +00:00
date:2015/01/01- # -b, --begin
date:-2015/01/01 # -e, --end
2015-12-04 01:48:43 +00:00
date2:PERIODEXPR
```
```
2015-12-09 18:19:43 +00:00
-p, --period=...
2015-12-04 01:48:43 +00:00
-p "2009/01/01"
-p "2009/01/01 to 2009/12/31"
2015-12-09 18:20:59 +00:00
-p "2009/01/01to2009/12/31" # spaces optional
2015-12-04 01:48:43 +00:00
-p "1/1 to 12/31"
-p "to 2009"
2015-12-09 18:34:55 +00:00
-p "weekly" # -W, --weekly
2015-12-04 01:48:43 +00:00
-p "weekly 2009/01/01 to 2009/12/31"
```
2015-12-09 18:34:55 +00:00
### Intervals
Used on all commands (`bal`, `reg`, etc). Displays in multi-column mode. In `ledger-cli`, only `reg` is supported. Can also specified via `-p` (period).
```
-D, --daily
-W, --weekly
-M, --monthly
-Q, --quarterly
-Y, --yearly
```
### Smart dates
Used for `--period`, `--begin` and `--end` (`-p` `-b` `-e`).
```
-p 2015/01/01
-p 2015/01
-p 2015
-p january
-p jan
-p 05/25
```
```
-b today
-b yesterday
-e tomorrow
```
```
-p this week
-p last month
-p this year
```
2015-12-09 18:19:43 +00:00
## Display formats
2015-12-04 01:48:43 +00:00
```
2015-12-09 18:19:43 +00:00
--tree # only in bal
--flat
--depth 2 # collapse those under this depth
--drop 1 # drop top-level accounts
-B, --cost # convert to default currency
-E, --empty # don't strip out $0 accounts
--date2 # use date2 when available
2015-12-04 01:48:43 +00:00
```
2015-12-09 18:19:43 +00:00
## Multi-column mode
When used with intervals (like `--weekly`):
2015-12-04 01:48:43 +00:00
```
2015-12-09 18:19:43 +00:00
-T, --row-total
-N, --no-total
2015-12-04 01:48:43 +00:00
```
2015-12-09 18:19:43 +00:00
Also: (only in `bal`)
2015-12-04 01:48:43 +00:00
```
2015-12-09 18:19:43 +00:00
--cumulative # show ending balance per period
-I, --historical # like --cumulative but only for --begin
-A, --average
2015-12-04 01:48:43 +00:00
```
2015-12-09 18:20:33 +00:00
## Accounts
```
hledger accounts [--tree]
```
2015-12-09 18:34:55 +00:00
## Other commands
```
hledger balancesheet # bs
hledger incomestatement # is
hledger cashflow # cf
hledger print
hledger activity
hledger stats
```
## Examples
```
# Current balance
hledger bal Assets
hledger balancesheet
hledger balancesheet Assets [--cleared --cost --empty -e tomorrow]
# ...discard future stuff; convert foreign currencies
# Monthly changes in assets
hledger bal Assets Liabilities --monthly --tree --historical [--cleared --cost --empty -e tomorrow]
# Weekly expenses
hledger bal Expenses --weekly --average --tree -b 'last month' [--cleared --cost --empty -e tomorrow]
```
2015-12-09 18:19:43 +00:00
## See also
* <http://hledger.org/manual.html>
* <http://ledger-cli.org/3.0/doc/ledger3.html>