summaryrefslogtreecommitdiff
path: root/doc/ledger.1
blob: 879c4f17e41bd65d56eb321b97388b7fbbfe0b58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
.Dd February 25, 2009
.Dt ledger 1
.Sh NAME
.Nm ledger
.Nd Command-line, double-entry account reporting tool
.Sh SYNOPSIS
ledger
.Op Ar command
.Op Ar options
.Op Ar arguments
.Sh DESCRIPTION
Ledger is a command-line accounting tool providing the user access to the
power of double-entry accounting.  It is only a reporting tool, which means it
never modifies your data files, nor can it be used to create or remove data.
.Pp
.Sh COMMANDS
Ledger accepts several top-level commands, each of which is used to generate a
different report.  Most of them accept a
.Ar report-query
argument, in order to determine what to report.  To understand what is
accepted by
.Ar report-query ,
see the section on
.Sx QUERIES .
In its most basic form, simply specifying one or more strings will produce a
report for all accounts containing those strings.
.Pp
If no command at all is given, Ledger enters a
.Tn REPL ,
or command loop, allowing several commands to be executed against the same
dataset without reparsing.
.Pp
The following is a summary of all the reporting commands accepted by Ledger:
.Pp
.Bl -tag -width foo
.It Nm balance Oo Ar query Oc
Produce a balance report showing subtotals for matching leaf accounts, and
aggregate totals for all the parents of those accounts.  The most common
options with this command are:
.Pp
.Bl -tag -compact -width "--collapse (-n)"
.It Fl \-collapse Pq Fl n
Only show totals in the top-most accounts.
.It Fl \-empty Pq Fl E
Show matching accounts whose total happens to be zero.
.It Fl \-flat
Rather than displaying a hierarchical tree, flatten it to show only subtotals
for accounts directly matching the query.
.It Fl \-no\-total
Suppress the final total usually shown at the bottom of the report.
.El
.Pp
The synonyms
.Nm bal
and
.Nm b
are also accepted.
.It Nm csv Oo Ar query Oc
.It Nm emacs Oo Ar query Oc
The synonym
.Nm lisp
is also accepted.
.It Nm equity Oo Ar query Oc
.It Nm prices Oo Ar query Oc
.It Nm pricesdb Oo Ar query Oc
.It Nm print Oo Ar query Oc
.It Nm register Oo Ar query Oc
The synonyms
.Nm reg
and
.Nm r
are also accepted.
.It Nm reload
Used solely by the
.It Nm xact Oo Ar date Oc
The synonym
.Nm entry
is also accepted.
.Tn REPL ,
and causes an immediate reloading of all journal files in the session.
.It Nm stats Oo Ar query Oc
.El
.Pp
.Sh OPTIONS
.Pp
.Bl -tag -width -indent
.It Fl \-abbrev-len Ar INT
.It Fl \-account Ar STR
.It Fl \-account-amount Ar EXPR
.It Fl \-account-width Ar INT
.It Fl \-actual Pq Fl L
.It Fl \-add-budget
.It Fl \-amount Ar EXPR Pq Fl t
.It Fl \-amount-data Pq Fl j
.It Fl \-amount-width Ar INT
.It Fl \-anon
.It Fl \-args-only
.It Fl \-average Pq Fl A
.It Fl \-balance-format Ar FMT
.It Fl \-base
.It Fl \-basis Pq Fl B
.It Fl \-begin Ar DATE Pq Fl b
.It Fl \-budget
.It Fl \-by-payee Pq Fl P
.It Fl \-cleared Pq Fl C
.It Fl \-code-as-account
.It Fl \-code-as-payee
.It Fl \-collapse Pq Fl n
.It Fl \-collapse-if-zero
.It Fl \-color
.It Fl \-columns Ar INT
.It Fl \-commodity-as-account
(Also \fB\-\-comm\-as\-account\fR).
.It Fl \-commodity-as-payee Pq Fl x
(Also \fB\-\-comm\-as\-payee\fR).
.It Fl \-cost
See \fB\-\-basis\fR.
.It Fl \-csv-format Ar FMT
.It Fl \-current Pq Fl c
.It Fl \-daily
.It Fl \-date-format Ar DATEFMT Pq Fl y
.It Fl \-date-width Ar INT
.It Fl \-debug Ar STR
.It Fl \-depth Ar INT
.It Fl \-deviation Pq Fl D
.It Fl \-display Ar EXPR Pq Fl d
.It Fl \-display-amount Ar EXPR
.It Fl \-display-total Ar EXPR
.It Fl \-dow
.It Fl \-download
.It Fl \-effective
.It Fl \-empty Pq Fl E
.It Fl \-end Pq Fl e
.It Fl \-equity
.It Fl \-exact
.It Fl \-exchange Ar COMM Oo , COMM, ... Oc Pq Fl x
.It Fl \-file Ar FILE
.It Fl \-first Ar INT
See \fB\-\-head\fR.
.It Fl \-flat
.It Fl \-forecast-while Ar EXPR
(Also \fB\-\-forecast\fR).
.It Fl \-format Ar FMT Pq Fl F
.It Fl \-gain Pq Fl G
.It Fl \-head Ar INT
.It Fl \-init-file Ar FILE
.It Fl \-input-date-format Ar DATEFMT
.It Fl \-invert
.It Fl \-last Ar INT
See \fB\-\-tail\fR.
.It Fl \-leeway Ar INT Pq Fl Z
.It Fl \-limit Ar EXPR Pq Fl l
.It Fl \-lot-dates
.It Fl \-lot-prices
.It Fl \-lot-tags
.It Fl \-lots
.It Fl \-market Pq Fl V
.It Fl \-monthly Pq Fl M
.It Fl \-only Ar EXPR
.It Fl \-output Ar FILE Pq Fl o
.It Fl \-pager Ar STR
.It Fl \-payee-as-account
.It Fl \-payee-width Ar INT
.It Fl \-pending
.It Fl \-percentage Pq Fl \%
.It Fl \-period Ar PERIOD Pq Fl p
.It Fl \-period-sort
.It Fl \-plot-amount-format Ar FMT
.It Fl \-plot-total-format Ar FMT
.It Fl \-price Pq Fl I
.It Fl \-price-db Ar FILE
.It Fl \-price-exp Ar STR
See \fB\-\-leeway\fR.
.It Fl \-prices-format Ar FMT
.It Fl \-pricesdb-format Ar FMT
.It Fl \-print-format Ar FMT
.It Fl \-quantity Pq Fl O
.It Fl \-quarterly
.It Fl \-raw
For use only with the
.Nm print
command, it causes Ledger to print out matching entries exactly as they
appeared in the original journal file.
.It Fl \-real Pq Fl R
.It Fl \-register-format Ar FMT
.It Fl \-related Pq Fl r
.It Fl \-related-all
.It Fl \-revalued
.It Fl \-revalued-only
.It Fl \-revalued-total Ar EXPR
.It Fl \-script
.It Fl \-set-account Ar EXPR
.It Fl \-set-payee Ar EXPR
.It Fl \-set-price Ar EXPR
.It Fl \-sort Ar EXPR Pq Fl S
.It Fl \-sort-all
.It Fl \-sort-xacts
.It Fl \-start-of-week Ar STR
.It Fl \-strict
.It Fl \-subtotal Pq Fl s
.It Fl \-tail Ar INT
.It Fl \-total Ar EXPR
.It Fl \-total-data Pq Fl J
.It Fl \-total-width Ar INT
.It Fl \-trace Ar INT
.It Fl \-truncate
.It Fl \-unbudgeted
.It Fl \-uncleared Pq Fl U
.It Fl \-verbose
.It Fl \-verify
.It Fl \-version
.It Fl \-weekly Pq Fl W
.It Fl \-wide Pq Fl w
.It Fl \-yearly Pq Fl Y
.El
.Pp
.Sh PRECOMMANDS
.Pp
.Bl -tag -width -indent
.It \fBargs\fR
.It \fBeval\fR
.It \fBformat\fR
.It \fBparse\fR
.It \fBperiod\fR
.It \fBtemplate\fR
.El
.Pp
.Sh QUERIES
The syntax for reporting queries can get somewhat complex.  It is a series of
query terms with an implicit OR operator between them.  The following terms
are accepted:
.Bl -tag foo -width "term and term"
.It Ar regex
A bare string is taken as a regular expression matching the full account name.
Thus, to report the current balance for all assets and liabilities, you would
use:
.Pp
.Dl ledger bal asset liab
.It Nm payee Ar regex Pq \&@ Ns Ar regex
Query on the payee, rather than the account.
.It Nm tag Ar regex Pq \&% Ns Ar regex
.It Nm note Ar regex Pq \&= Ns Ar regex
Query on anything found in an item's note.
.It Nm code Ar regex Pq \&# Ns Ar regex
Query on the xact's optional code (which can be any string the user wishes).
.It Ar term Nm and Ar term
Query terms are joined by an implicit OR operator.  You can change this to AND
by using that keyword.  For example, to show food expenditures occurring at
Shakee's Pizza, you could say:
.Pp
.Dl ledger reg food and @Shakee
.It Ar term Nm or Ar term
When you wish to be more explicit, use the OR operator.
.It Nm not Ar term
Reverse the logical meaning of the following term.  This can be used with
parentheses to great effect:
.Pp
.Dl ledger reg food and @Shakee and not dining
.It \&( Ar term No \&)
If you wish to mix OR and AND operators, it is often helpful to surround
logical units with parentheses.  \fBNOTE\fR: Because of the way some shells
interpret parentheses, you should always escape them:
.Pp
.Dl ledger bal \e\\\&( assets or liab \e\\\&) and not food
.El
.Pp
.Sh EXPRESSIONS
.Bl -tag foo -width "partial_account"
.It Nm account
.It Nm account_base
.It Nm actual
.It Nm amount
.It Nm amount_expr
.It Fn ansify_if value color bool
Render the given
.Ar value
as a string, applying the proper ANSI escape codes to display it in the given
.Ar color
if
.Ar bool
is true.  It typically checks the value of the option
.Nm Fl \-color ,
for example:
.Dl ansify_if(amount, "blue", options.color)
.It Nm beg_line
.It Nm beg_pos
.It Nm calculated
.It Nm cleared
.It Nm code
.It Nm comment
.It Nm commodity
.It Nm cost
.It Nm count
.It Nm date
.It Nm depth
.It Nm depth_spacer
.It Nm display_amount
.It Nm display_total
.It Nm end_line
.It Nm end_pos
.It Nm filename
.It Nm format_date
.It Nm get_at
.It Nm has_meta
.It Nm has_tag
.It Nm is_seq
.It Nm join
.It Nm market
.It Nm meta
.It Nm note
.It Nm options
.It Nm partial_account
.It Nm payee
.It Nm pending
.It Nm post
.It Nm print
.It Nm quantity
.It Nm quoted
.It Nm real
.It Nm rounded
.It Nm scrub
.It Nm status
.It Nm strip
.It Nm subcount
.It Nm tag
.It Nm today
.It Nm total
.It Nm total_expr
.It Nm truncate
.It Nm uncleared
.It Nm virtual
.It Nm xact
.El
.Pp
.Sh SEE ALSO
.Xr beancount 1,
.Xr hledger 1
.Sh AUTHORS
.An "John Wiegley" Aq johnw@newartisans.com
.\" .Sh BUGS              \" Document known, unremedied bugs
.\" .Sh HISTORY           \" Document history if command behaves in a unique manner