Previous: Some typical queries, Up: Running Ledger


2.9 Budgeting and forecasting

2.9.1 Budgeting

Keeping a budget allows you to pay closer attention to your income and expenses, by reporting how far your actual financial activity is from your expectations.

To start keeping a budget, put some period entries at the top of your ledger file. A period entry is almost identical to a regular entry, except that it begins with a tilde and has a period expression in place of a payee. For example:

     ~ Monthly
       Expenses:Rent               $500.00
       Expenses:Food               $450.00
       Expenses:Auto:Gas           $120.00
       Expenses:Insurance          $150.00
       Expenses:Phone              $125.00
       Expenses:Utilities          $100.00
       Expenses:Movies              $50.00
       Expenses                    $200.00  ; all other expenses
       Assets
     
     ~ Yearly
       Expenses:Auto:Repair        $500.00
       Assets

These two period entries give the usual monthly expenses, as well as one typical yearly expense. For help on finding out what your average monthly expense is for any category, use a command like:

     ledger -p "this year" -MAs bal ^expenses

The reported totals are the current year's average for each account.

Once these period entries are defined, creating a budget report is as easy as adding --budget to the command-line. For example, a typical monthly expense report would be:

     ledger -M reg ^exp

To see the same report balanced against your budget, use:

     ledger --budget -M reg ^exp

A budget report includes only those accounts that appear in the budget. To see all expenses balanced against the budget, use --add-budget. You can even see only the unbudgeted expenses using --unbudgeted:

     ledger --unbudgeted -M reg ^exp

You can also use these flags with the balance command.

2.9.2 Forecasting

Sometimes it's useful to know what your finances will look like in the future, such as determining when an account will reach zero. Ledger makes this easy to do, using the same period entries as are used for budgeting. An example forecast report can be generated with:

     ledger --forecast "T>{\$-500.00}" register ^assets ^liabilities

This report continues outputting transactions until the running total is greater than $-500.00. A final transaction is always output, to show you what the total afterwards would be.

Forecasting can also be used with the balance report, but by date only, and not against the running total:

     ledger --forecast "d<[2010]" bal ^assets ^liabilities