# Set Beancount budgets and track them in Fava

This guide explains how to set up, manage, and visualize per-account budgets using Beancount's `custom` directives and [the Fava web interface](https://beancount.io/docs/Tips/ui-features). For a rollover model that assigns every dollar a job, copy the [live envelope-budget ledger](https://beancount.io/docs/examples).

## How to Set a Budget

Budgets are defined using a `custom "budget"` directive in your Beancount file. The syntax is straightforward:

```bean
YYYY-MM-DD custom "budget" AccountName "interval" Amount CURRENCY
```

- **`AccountName`**: The specific expense or income account you want to budget for.
- **`interval`**: The budget period. Must be one of `daily`, `weekly`, `monthly`, `quarterly`, or `yearly`.
- **`Amount`**: The target amount for the interval.

**How it Works:**

- A budget directive remains in effect from its date until another budget directive for the same account overrides it.
- Beancount and Fava break down all budgets into a daily equivalent, allowing them to calculate the total budgeted amount for [any given date range](https://beancount.io/docs/Tips/filtering-and-searching).

**Example:**

```bean
; Set a daily budget for coffee
2024-01-01 custom "budget" Expenses:Food:Coffee       "daily"      5.00 USD

; Set a monthly budget for groceries
2024-01-01 custom "budget" Expenses:Food:Groceries    "monthly"  600.00 USD

; Set a yearly budget for vacations
2024-01-01 custom "budget" Expenses:Travel:Vacation   "yearly"  3000.00 USD
```

To adjust a budget, simply add a new directive with a later date. For example, to increase the grocery budget starting in March:

```bean
2024-03-01 custom "budget" Expenses:Food:Groceries    "monthly"  650.00 USD
```

## Visualizing Budgets in Fava

Fava, the web interface for Beancount, automatically detects and displays your budgets in several key reports, allowing you to compare your actual spending to your targets:

- **Income Statement:** The **Net Profit** and **Expenses** charts will show budgeted vs. actual values.
- **Changes (monthly):** Shows the budgeted amount for each month.
- **Balances (monthly):** Shows the cumulative budgeted amount over time.

## Advanced Budgeting Techniques

### Budget Rollover

The default budget system resets each period. To implement a ["rollover"](/blog/2026/07/26/firefly-iii-vs-actual-budget-self-hosted-open-source-budgeting-guide) where unspent funds carry over, use a dedicated asset account to hold budgeted funds.

1. **Fund the budget account at the start of the period:**

   ```bean
   2024-02-01 * "Fund monthly entertainment budget"
     Assets:Checking                  -200.00 USD
     Assets:Budget:Entertainment       200.00 USD
   ```

2. **Spend directly from this budget account:**

   ```bean
   2024-02-15 * "Movie night"
     Expenses:Entertainment:Movies      30.00 USD
     Assets:Budget:Entertainment       -30.00 USD
   ```

   The remaining balance in `Assets:Budget:Entertainment` is your rollover amount.

### Tracking Income Goals

You can also set targets for your income accounts by using a **negative** budget amount. This allows Fava to track your earnings against your goals.

```bean
; Set monthly income targets
2024-01-01 custom "budget" Income:Salary      "monthly" -5000.00 USD
2024-01-01 custom "budget" Income:Freelance   "monthly" -1000.00 USD
```

## Troubleshooting

If your budgets are not appearing in Fava, check the following:

1. **Date Format:** Ensure dates are in `YYYY-MM-DD` format.
2. **Account Names:** The account name in the directive must exactly match the account name in your transactions.
3. **Interval Spelling:** The interval must be one of the five valid options and in lowercase (e.g., `"monthly"`).
4. **Restart Fava:** If you've recently added the directives, a restart of the Fava server may be needed to pick up the changes.
