When trying to budget or understand regular baseline spending, special events like travel or large one-off purchases can distort the picture. Fortunately, ledger's tagging system allows us to report on these transactions separately, giving us better insight both into everyday expenses and the real cost of unusual events.
(This post is part of a series describing how I use the Ledger accounting system. For an introduction to ledger and this series, or to see all the entries, have a look at the first post).
Ledger allows transactions to be annotated with tags. These tags
can stand alone, or they can be in a “key: value” format that can be
queried more precisely by asking for only certain values instead of all
instances of the tag. Tags are added by appending a comment to the transaction
in either the “; :Tag:
” or the “; Key: Value
” form.
The way I use this is I have defined a few tags, such as “Event” and “OneOff”. All transactions associated with a particular event, whether flights, hotels, or restaurant meals, can then be tagged, like so:
A Liabilities:CreditCard
2017-04-01 A Run-Down Tin Shack
Expenses:Hotels $20.00
; Event: PyCon-2017
2017-04-02 Bob's Used Cars
Expenses:Car $10,000.00
; :OneOff:
2017-04-03 Regular Grocery Store Inc.
Expenses:Groceries $30.00
Now, when reviewing spending for the month, I can look at any of three numbers: actual spending; regular non-special spending; and spending on the conference specifically; using the following queries:
$ ledger balance
$10,050.00 Expenses
$10,000.00 Car
$30.00 Groceries
$20.00 Hotels
$-10,050.00 Liabilities:CreditCard
--------------------
0
$ ledger balance Expenses and not tag Event and not tag OneOff
$30.00 Expenses:Groceries
$ ledger balance tag Event=PyCon-2017
$20.00 Expenses:Hotels
Or, I can use ledger register
to see the specific
transactions.