Hledger helps with travel

In this week's blog, I look at

  • Why an item purchased during travel wasn't a travel expense
  • Sorting expenses by amount
  • Upgrading hledger

And I tie them together with a reference to a recent trip.

Read more at https://hledgerfan.com/hledger-and-travel-expenses/.

1 Like

Thanks for your post.

Have you considered keeping all your transactions as you typically would but use tags?

for example, this is how i would record a non-travel transaction:

2025-06-20 Target
    expenses:home:clothing:shirts          $12.99
    expenses:taxes:ca:sales                 $1.12
    assets:bank:checking                  $-14.11

and the only difference if i had purchased it on a travel trip would be to add a tag:

2025-06-20 Target
    expenses:home:clothing:shirts          $12.99 ;sandiego_summer2025:
    expenses:taxes:ca:sales                 $1.12
    assets:bank:checking                  $-14.11

With this, i can see how much (or little) i spent on a trip with a given tag:

$ hledger bal tag:sandiego_2025
         $12.9900000  expenses:home:clothing:shirts
--------------------
         $12.9900000

I tag all expenses related to toe travel/vacation with tags - airfare, taxi, clothing, food, tips, lodging, fuel, etc.

With a generic travel category, how do you determine how much you spent on your San Diego trip vs. Santa Barbara trip?

info on tags:

Actually I should tag the account, so that it will get everything and not just the category:

2025-06-20 Target ;sandiego_2025:
    expenses:home:clothing:shirts          $12.99
    expenses:taxes:ca:sales                 $1.12
    assets:bank:checking                  $-14.11
$ hledger bal tag:sandiego_2025
        $-14.1100000  assets:bank:checking
         $12.9900000  expenses:home:clothing:shirts
          $1.1200000  expenses:taxes:ca:sales
--------------------
                   0
1 Like

Yes, tags can be a great help. I used to combine tags with a travel category. That is, any travel would be under my travel category. Then, there would be a tag to identify the individual trip.

This worked well, except that I found that I wasn't using the information about individual trips. That is, I wasn't running reports to see how much an individual trip cost. So, I stopped adding tags to denote the specific trip.

However, I can easily imagine situations where someone would find identifying separate trips quite useful!

1 Like

I have been debating whether to categorize shopping under travel expenses or general expenses. This post has helped me decide that it should not be a travel expense. :slight_smile:

Additionally, I do something similar with my travel expenses. Except my tag looks like trip:2025_03_japan. This allows me to pivot on the trip tag to get an automatic breakdown by trip.

Example:

2025-05-27 Hotel  ; trip:2025_03_japan
    liabilities:credit_card             $-87.00
    expenses:travel:hotel            $87.00

2025-05-27 Airfare  ; trip:2025_02_spain
    liabilities:credit_card             $-125.00
    expenses:travel:hotel            $125.00

Then running the command

$ hledger bal expenses:travel --pivot=trip

             $125.00  2025_02_spain
              $87.00  2025_03_japan
--------------------
             $212.00  

And if I want a breakdown of expenses for a specific trip, I can do that easily too.

$ hledger bal tag:"trip=2025_03_japan"

Good example, sld!

I do this to! My tag format is a bit different but essentially the same: YYYYMMdestination (as in 202502barcelona or 202503japan for examples).

I love how useful and easy it is to see the total cost of a trip. I can also quickly see how much I have spent on a given category (such as restaurants) for any given trips.

I seem to do both:

  • I use a trip: tag, but with colon-separated values which lets me summarise by year or place: trip: 2024:ireland:galway
    hledger bal --pivot trip -2
  • I also have an expenses:travel account, with about a dozen subcategories. For me those trip expenses are enough of a different category that I want to see them broken out in reports.
1 Like

Okay I'm convinced and I'll use a travel category and tags...now I just need to go on a trip to make use of all this.

1 Like

Recording the geo location of expenses is also fun application of PTA travel journals (pun intended).

2019-05-01 'Ice cream at Helsinki's market square
  # location: geo:60.167,24.955,5
  Expenses:Ice_cream  2.50 €
  Assets:Cash

On #1, Very interesting about being able to report per year within the tag. My journal is for 2025 so far so I do not yet (!) have that "problem". Something to think about.

About #2, I do this too but have been thinking about my actual setup and perhaps changing how I record my transactions. Here is what I do today:

Regular transaction (ie not travelling) I record using "regular" accounts, for example:
expenses:food:groceries
expenses:food:diningout
expenses:personalcare

When I travel tag everything with "trip" (as describe above) and I use accounts which are part of "expenses:travel", something like this:
expenses:travel:transport:air
expenses:travel:food:groceries
expenses:travel:food:diningout

I have now been re-thinking about this thought I should perhaps simply use one set of accounts (the "regular" ones), for example
expenses:food:groceries
expenses:transport:air

This way I would simplify my account structures (less accounts). I can still report expenses either by: all, on a trip (tag:trip, can look at per trip because of tag value), or not on a trip (not:tag:trip).

My reason for rethinking this is that if I want to know how much I spend on groceries for example I need to query for 2 accounts as opposed to one. Everything can be done and is perhaps just a matter of preference. Thoughts?