Hi,
while learning Ledger, I have collected a few commands that I frequently
use into a Rakefile, which I have just made public, thinking that it may
be interesting to other newbies like me:
https://gist.github.com/4009128
Note that I have tested the commands against a fairly recent development
snapshot of Ledger 3.0.0. Some of them (e.g., budget reports) may not
work with other releases.
These are the tasks currently defined:
# Balance report (with and without virtual transactions, with optional
conversion to a given currency).
# Budget expense report for the current year.
# Monthly average for an account during the current year.
# Monthly expenses, sorted by amount, for a specified period.
# Monthly net worth.
# Weekly average for an account during the current year.
# Weekly expenses, sorted by amount, for a specified period.
# Weekly net worth.
# Total income and expenses for a specified period, with savings
percentage.
To use the Rakefile, cd into the directory where you have saved it (I
suggest that you keep it along with your ledger file), and type
rake -T
to get a list of the available tasks. The default task (a balance
report) can be invoked by simply typing
rake
For tasks that take optional arguments, such arguments can be specified
in square brackets or as <parameter name>=<value>. For example,
rake tot['last week']
and
rake tot period='last week'
produce exactly the same report, which might look like this (and I
wished mine looked like this!):
1.572,33 USD Expenses
-2.478,91 USD Income
--------------------
-906,58 USD
36,57 % Savings rate
If you run rake with -v, the executed command will also be shown. This
may be useful both for debugging and for learning.
Do not forget to take a look at the constants defined at the top of the
source code, and adjust their values to your needs.
It would be nice if the commands for generating the above reports, and
possibly others, could be collected in a single place. I was thinking to
edit the Examples section in the Github wiki. Do you think it's a good
idea?
Life