Felix Crux

Technology & Miscellanea

Tags: ,

One complex scenario that can cause accounting headaches is when you need to track money movements across a group of accounts that are divided between different parties, and need to be reported on both jointly and separately (for example, members of a household, or partners in a small business). Ideally, tricky things like joint accounts and inter-party transfers would be reported clearly and correctly.

Naturally, there’s a way to make this work in Ledger, but it requires a bit of setup!

(This post is part of a series describing how I use the Ledger accounting system. For an introduction to Ledger and this series, or to see all the entries, have a look at the first post).

The first difficult bit comes up when there are transfers between parties: they need to be reported as expenses or income when looking at each set of books individually, but they should just be counted as internal transfers when reporting on the group jointly (that is, the group as a whole has neither lost nor gained money). Consider for example a group of students living in shared rental housing: They might all pay a share of rent to one of them, who is then responsible for paying the full rent to their landlord. Those internal payments should count as rent payments when looking at each person’s accounts, but just as transfers between asset accounts when looking at the entire household, with only the final full payment counting as a rent expense.

The second tricky case is joint (shared ownership) accounts: Both parties need to have them in their books, but they shouldn’t be double counted when looking at all accounts in aggregate.

Demonstration Setup

To model these scenarios, let’s say we’re tracking accounts belonging to two people, Alice and Bob, and create a couple of test journals for them. First, an account for Alice, in alice-chequing.journal:


A Assets:The Bank:Alice's Chequing

2018-11-01 Alice's Employer
  Income:Salary  $-1,000.00

2018-11-02 Tim Hortons
  Expenses:Food:Restaurants  $30.00

2018-11-03 Bob
  Expenses:Household common expenses  $200.00

2018-11-04 Bob
  Expenses:Transfer to Bob  $100.00

And a “main” journal for Alice, from which all her accounts would be included (there isn’t much to do here right now given she only has one account), which we’ll put in alice.journal:


include alice-chequing.journal

And let’s set up an account for Bob, in bob-chequing.journal:


A Assets:The Bank:Bob's Chequing

2018-11-01 Bob's Employer
  Income:Salary  $-500.00

2018-11-03 Transfer from Alice
  Expenses:Household common expenses  $-200.00

2018-11-04 Transfer from Alice
  Income:Transfer from Alice  $-100.00

2018-11-05 Landlord
  Expenses:Household common expenses  $400.00

…and Bob’s main file, bob.journal:


include bob-chequing.journal

Transfers Between Parties

At this point, it’s still easy enough to report on these accounts individually:


$ ledger bal --file alice.journal
             $670.00  Assets:The Bank:Alice's Chequing
             $330.00  Expenses
              $30.00    Food:Restaurants
             $200.00    Household common expenses
             $100.00    Transfer to Bob
          $-1,000.00  Income:Salary
--------------------
                   0

$ ledger bal --file bob.journal
             $400.00  Assets:The Bank:Bob's Chequing
             $200.00  Expenses:Household common expenses
            $-600.00  Income
            $-500.00    Salary
            $-100.00    Transfer from Alice
--------------------
                   0

Now, so far, the only thing we had to keep in mind was that there may be two different kinds of transfers between Alice and Bob: ones that are specifically for paying a share of a common expense, and general ones that just represent money moving between accounts without being earmarked for a specific purpose. These two kinds of payments have to be tracked separately. Note that Alice made two transfers to Bob, under two different “Expenses” categories. Likewise, when Bob received them, they were tracked differently there too. The earmarked transfer was counted as a credit against an expense, while the regular movement was counted as income.

Let’s try reporting on them jointly. To do so, we’ll create a new journal that aggregates the two accounts, in joint.journal:


include alice-chequing.journal
include bob-chequing.journal

…but trying to run a report on it breaks down on the non-earmarked transfers between Alice and Bob:


$ ledger bal --file joint.journal
           $1,070.00  Assets:The Bank
             $670.00    Alice's Chequing
             $400.00    Bob's Chequing
             $530.00  Expenses
              $30.00    Food:Restaurants
             $400.00    Household common expenses
             $100.00    Transfer to Bob
          $-1,600.00  Income
          $-1,500.00    Salary
            $-100.00    Transfer from Alice
--------------------
                   0

The Expenses and Income are incorrect, because they’re counting “internal” transfers that should just move money between different Assets accounts.

To fix this, we’ll have to make use of Ledger’s “alias” feature, which allows us to “rename” accounts on the fly. We’ll use this to make the two copies of the transaction “cancel out” when read in twice, so it doesn’t show up at all. Let’s modify our joint.journal file so it reads as follows:


alias Expenses:Transfer to Bob=Income:Transfer from Alice

include alice-chequing.journal
include bob-chequing.journal

Now, we can see that Alice and Bob’s Assets are still reported correctly — like they were when counted individually — and their Expenses don’t include transfers between them and are not being double-counted:


$ ledger bal --file joint.journal
           $1,070.00  Assets:The Bank
             $670.00    Alice's Chequing
             $400.00    Bob's Chequing
             $430.00  Expenses
              $30.00    Food:Restaurants
             $400.00    Household common expenses
          $-1,500.00  Income:Salary
--------------------
                   0

Joint Accounts

The next wrinkle to consider is joint (i.e. shared-ownership) accounts. These should be included in reports for both Alice and Bob, but need to only be counted once when reporting on their combined finances.

To demonstrate, let’s create a joint bank account journal, in alice-and-bob-savings.journal:


A Assets:The Bank:Joint Savings

2018-11-02 Transfer from Alice
  Assets:The Bank:Alice's Chequing  $-100.00

2018-11-02 Transfer from Bob
  Assets:The Bank:Bob's Chequing  $-100.00

And then we’ll add “include alice-and-bob-savings.journal” to all of alice.journal, bob.journal, and joint.journal. What happens now?


$ ledger bal --file alice.journal
             $670.00  Assets:The Bank
             $570.00    Alice's Chequing
            $-100.00    Bob's Chequing
             $200.00    Joint Savings
             $330.00  Expenses
              $30.00    Food:Restaurants
             $200.00    Household common expenses
             $100.00    Transfer to Bob
          $-1,000.00  Income:Salary
--------------------
                   0

$ ledger bal --file bob.journal
             $400.00  Assets:The Bank
            $-100.00    Alice's Chequing
             $300.00    Bob's Chequing
             $200.00    Joint Savings
             $200.00  Expenses:Household common expenses
            $-600.00  Income
            $-500.00    Salary
            $-100.00    Transfer from Alice
--------------------
                   0

$ ledger bal --file joint.journal
           $1,070.00  Assets:The Bank
             $570.00    Alice's Chequing
             $300.00    Bob's Chequing
             $200.00    Joint Savings
             $430.00  Expenses
              $30.00    Food:Restaurants
             $400.00    Household common expenses
          $-1,500.00  Income:Salary
--------------------
                   0

The joint report looks good, but the two individual ones now have a misleading entry for the other party’s chequing account, with an incorrect negative balance. Fortunately, we can use the same pattern as before to fix this! Let’s change alice.journal to:


include alice-chequing.journal

alias Assets:The Bank:Bob's Chequing=Income:Transfer from Bob
include alice-and-bob-savings.journal

And, similarly, let’s add “alias Assets:The Bank:Alice's Chequing=Income:Transfer from Alice” to bob.journal. Then our individual reports become:


$ ledger bal --file alice.journal
             $770.00  Assets:The Bank
             $570.00    Alice's Chequing
             $200.00    Joint Savings
             $330.00  Expenses
              $30.00    Food:Restaurants
             $200.00    Household common expenses
             $100.00    Transfer to Bob
          $-1,100.00  Income
          $-1,000.00    Salary
            $-100.00    Transfer from Bob
--------------------
                   0

$ ledger bal --file bob.journal
             $500.00  Assets:The Bank
             $300.00    Bob's Chequing
             $200.00    Joint Savings
             $200.00  Expenses:Household common expenses
            $-700.00  Income
            $-500.00    Salary
            $-200.00    Transfer from Alice
--------------------
                   0

Much more accurate! And because we didn’t touch joint.journal, that report is unaffected and still looks good.

A Caveat About Names

One thing we had to do in order to keep the accounts distinguishable when reporting on them jointly, was to have Alice and Bob give their chequing accounts different names. What if they had both wanted to name them “My Chequing”? We could have tried to work around it with more aliases, which should have been fine, except for one thing: at this time, a bug(?) or limitation in Ledger means that aliases only apply to accounts explicitly named in transaction entries, not to ones implicitly inserted thanks to the “A Default:Account:Name” declaration at the top of the file.

This means that we have a choice: either every party has to give their accounts different names, or they can share names, but every transaction has to be fully specified; i.e. like this:


2018-11-01 Alice's Employer
  Income:Salary  $-1,000.00
  Assets:The Bank:Alice's Chequing

2018-11-02 Tim Hortons
  Expenses:Food:Restaurants  $30.00
  Assets:The Bank:Alice's Chequing

…instead of like this:


A Assets:The Bank:Alice's Chequing

2018-11-01 Alice's Employer
  Income:Salary  $-1,000.00

2018-11-02 Tim Hortons
  Expenses:Food:Restaurants  $30.00

Either approach works just fine, and comes down to personal preference. It’s a minor annoyance and limitation, but ideally one that shouldn’t exist.

Summary

To set up joint and individual reporting for a group of accounts, we have to create three (or more) “main” journal entry points: one for joint reporting, and one for each party. They all have to include the relevant accounts for their reports (you can’t take the shortcut of having the joint main file include each of the individual main files, or you’ll get double-counting).

No special handling is needed for transfers between parties that are earmarked for a specific purpose. Carefully defined different sets of aliases in each of the three main files let us correctly handle transfers between parties and joint accounts. More complex scenarios can take advantage of the fact that aliases only apply to files read in after the alias was defined, so careful ordering of multiple aliases can sort out almost any configuration of accounts and parties.

With all that in place, Ledger is very capable of handling multi-party accounting with joint and separate reports.


blog comments powered by Disqus