Double-entry accounting when on holiday

So I recent went to New York City on holiday a couple of months ago (loved it there!) and I did my long-overdue accounting for December and January today. I use ledger-cli to record my expenditure and income with double-entry accounting to maintain my accounts in a plain file. I’ve found ledger to be incredibly versatile, but accounting for holidays has been a pain.

When it comes to accounting, the primary question is, obviously, how much did I spend overall? This will at least help me budget my next holiday better if nothing else. Another problem that often pops up is splitting bills and costs with friends when I’m holidaying with them; there were six of us in NYC and everyone took turns paying for things. Obviously, different things cost different amounts, so some of us end up owing a few dollars to others at the end of the trip. We used Splitwise to keep track of this stuff, which worked great until I had to account for things in my books after my holiday.

Here’s the best way to solve these, as far as I know.

Estimating Costs After the Trip

A typical trip has dozens of transactions – flights, hotels, meals, public transport tickets, rides and entry fees, and souvenir. Some of these are booked well in advance, some happen during the trip. Nearly all expenses happen during the holiday and they are, by definition, bunched up together.

Ledger has something really cool called tags. You can tag a transaction with an arbitrary name (if you run ledger in strict mode like I do, you’ll need to declare your tags upfront). You can assign an arbitrary value to a tag. You can also apply a tag to a series of contiguous transactions trivially. See where I’m going with this?

The trip began on the 29th of November and ended on the 2nd of December. Let’s say I booked my tickets to NYC way back in August, three months before the trip itself. Here’s how you do it:

 1 # Let's define a tag called Holiday to keep track of all holidays. You can
 2 # assign a unique identifier to each holiday and set that as the value to this
 3 # tag whenever you tag a transaction with it.
 4 tag Holiday
 5 
 6 # In this one-off transaction that happened way before the actual trip, I tag
 7 # the transaction with "Holiday" by using the semicolon notation like so.
 8 15-Aug-2019 Flight from SFO to JFK  ; Holiday: 2019-NYC
 9   Expenses:Travel                                                    178.00 USD
10   Assets:Chequing                                                   -178.00 USD
11 
12 # And then the actual trip happened. Everything from here on will be
13 # automatically tagged with Holiday: 2019-NYC.
14 apply tag Holiday: 2019-NYC
15 
16 # Some random expense during the holiday.
17 29-Nov-2019 Dinner at Lucali
18   Expenses:Restaurant                                                 21.00 USD
19   Assets:Wallet
20 
21 # That concludes our trip. Everything after this shouldn't have a holiday tag.
22 end apply tag

Later, when I want to query how much the trip cost, I can generate a categorised total trivially:

$ ledger register                        \
    --strict                             \
    --file /path/to/ledger/file            \
    --subtotal                           \
    '%Holiday=2019-NYC' and '^Expenses:'

Splitting Costs

Let’s say I paid for the tickets for all six of us to go to the top of the Rockefeller Centre (which is beautiful at night, by the way), costing $240 in total. But someone else paid for the ice skating boots rental, which cost $120 in total. So I’m owed $200 for the Rock, but I also owe $20 for the boots. Splitwise does a great job at recording these during the holiday and at the end of the trip, everybody settles the balance amounts.

Essentially, what I’ve done is paid for the boots with a credit called Splitwise. And credit is a liability. Once I realised this, everything became obvious in hindsight. This is how you do it:

 1 # 240.00 USD got debited from my account, but 200.00 of it got "credited" in my
 2 # Splitwise account. Similarly, the next transaction will use this "credit"
 3 # from my Splitwise account to pay for the ice skating.
 4 30-Nov-2019 Rockefeller Centre
 5   Liabilities:Splitwise                                              200.00 USD
 6   Assets:Chequing                                                   -240.00 USD
 7   Expenses:Entertainment                                              40.00 USD
 8 
 9 # A friend paid for this.
10 30-Nov-2019 Ice skating
11   Liabilities:Splitwise                                               20.00 USD
12   Expenses:Entertainment                                             -20.00 USD
13 
14 # Once the trip is over, Splitwise will tell me I'm owed 180.00 USD, which
15 # will go into my bank account. If you use Splitwise's simplification feature,
16 # you'll be owed different amounts from different people, but that doesn't
17 # really matter to our books; any money you receive as settlement from your
18 # friend will be counted as money debited from Splitwise and credited into
19 # your chequing account.
20 30-Nov-2019 Splitwise settlement
21   Liabilities:Splitwise                                             -180.00 USD
22   Assets:Chequing                                                    180.00 USD