OSDN Git Service

Regular updates
[twpd/master.git] / hledger.md
1 ---
2 title: Hledger
3 category: Ledger
4 ---
5
6 ## Reporting
7
8 ```
9 hledger bal {query}
10 hledger reg {query}
11 ```
12 {:.large.terminal}
13
14 ## Query
15
16 Queries are used on all commands (`bal`, `reg`, etc). [(docs)](http://hledger.org/manual.html#queries)
17
18 ```
19 Assets           # An account (regex)
20 acct:Assets      # same
21 ^Assets          # Starting with Assets (eg, not 'Expenses:Assets')
22
23 acctonly:A       # no subaccounts
24
25 amt:2000         # amount (in absolute value)
26 amt:<200         # amount comparison (in absolute value)
27 amt:<+200        # amount comparison
28                  # also: <=, >, >=
29
30 desc:REGEX      # description
31 code:REGEX      # transaction code (check number?)
32 tag:REGEX
33 cur:'\$'
34
35 real:            # real posts
36 real:0           # virtual posts
37
38 depth:N          # --depth 2
39 not:...          # eg, not:status:!
40 ```
41
42 ### Filter by status/type
43
44 ```
45 real:1           # -R, --real, no virtuals
46 status:!         #     --pending
47 status:*         # -C, --cleared
48 status:          #     --uncleared
49 ```
50
51 ### Periods
52 For dates and intervals (see above).
53
54 ```
55 date:2015/01/01
56 date:2015/01/01-    # -b, --begin
57 date:-2015/01/01    # -e, --end
58 date2:PERIODEXPR
59 ```
60
61 ```
62 -p, --period=...
63   -p "2009/01/01"
64   -p "2009/01/01 to 2009/12/31"
65   -p "2009/01/01to2009/12/31"      # spaces optional
66   -p "1/1 to 12/31"
67   -p "to 2009"
68   -p "weekly"                      # -W, --weekly
69   -p "weekly 2009/01/01 to 2009/12/31"
70 ```
71
72 ### Intervals
73 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).
74
75 ```
76 -D, --daily
77 -W, --weekly
78 -M, --monthly
79 -Q, --quarterly
80 -Y, --yearly
81 ```
82
83 ### Smart dates
84 Used for `--period`, `--begin` and `--end` (`-p` `-b` `-e`).
85
86 ```
87 -p 2015/01/01
88 -p 2015/01
89 -p 2015
90 -p january
91 -p jan
92 -p 05/25
93 ```
94
95 ```
96 -b today
97 -b yesterday
98 -e tomorrow
99 ```
100
101 ```
102 -p this week
103 -p last month
104 -p this year
105 ```
106
107 ## Display formats
108
109 ```
110     --tree          # only in bal
111     --flat
112
113     --depth 2       # collapse those under this depth
114     --drop 1        # drop top-level accounts
115 -B, --cost          # convert to default currency
116 -E, --empty         # don't strip out $0 accounts
117     --date2         # use date2 when available
118 ```
119
120 ## Multi-column mode
121 When used with intervals (like `--weekly`):
122
123 ```
124 -T, --row-total
125 -N, --no-total
126 ```
127
128 Also: (only in `bal`)
129
130 ```
131     --cumulative    # show ending balance per period
132 -I, --historical    # like --cumulative but only for --begin
133 -A, --average
134 ```
135
136
137 ## Accounts
138
139 ```
140 hledger accounts [--tree]
141 ```
142
143 ## Other commands
144
145 ```
146 hledger balancesheet       # bs
147 hledger incomestatement    # is
148 hledger cashflow           # cf
149 hledger print
150 hledger activity
151 hledger stats
152 ```
153
154 ## Examples
155
156 ```
157 # Current balance
158   hledger bal Assets
159   hledger balancesheet
160
161   hledger balancesheet Assets [--cleared --cost --empty -e tomorrow]
162   # ...discard future stuff; convert foreign currencies
163
164 # Monthly changes in assets
165   hledger bal Assets Liabilities --monthly --tree --historical [--cleared --cost --empty -e tomorrow]
166
167 # Weekly expenses
168   hledger bal Expenses --weekly --average --tree -b 'last month' [--cleared --cost --empty -e tomorrow]
169 ```
170
171 ## See also
172
173 * <http://hledger.org/manual.html>
174 * <http://ledger-cli.org/3.0/doc/ledger3.html>