OSDN Git Service

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