Using ledger for shared expenses

1,101 views
Skip to first unread message

Sébastien Gross

unread,
Apr 19, 2016, 11:55:51 AM4/19/16
to Ledger
Hi there,

This might be an ultra-classic use-case of ledger here I am facing.

Let's plot the scene:


- They have their own bank account (Alice and Bob) and a Join account

- Alice and Bob rent a flat ($1500/mo), which for some reasons is paid
  by Bob from his own account (not for the Join one).
  
- Every month Alice wires half the rent ($750) to Bob's checking account
- Every month wire the rent to the owner


For clean readability I always use the following scheme:
  (Assets|Income|Expenses|Liabilities|Equity):(Alice|Bob|Join):Account


I assume the following opening balances:

  2016/01/01 * Opening balance
      Assets:Bob:Bank:Checking            $12345
      Equity:Bob:Bank:Checking      
  
  2016/01/01 * Opening balance
      Assets:Join:Bank:Checking             $123
      Equity:Join:Bank:Checking        


This can be written as follow:


  2016/01/01 Alice
      Assets:Bob:Bank:Checking              $750
      Income:Bob:Alice:Rent
  
  2016/01/01 Owner
      Assets:Bob:Bank:Checking  
      Expenses:Bob:Rent                    $1500

The balance is then:

  $ ./test.ledger bal
                $11718  Assets
                $11595    Bob:Bank:Checking
                  $123    Join:Bank:Checking
               $-12468  Equity
               $-12345    Bob:Bank:Checking
                 $-123    Join:Bank:Checking
                 $1500  Expenses:Bob:Rent
                 $-750  Income:Bob:Alice:Rent
  --------------------
                     0

This is good and works fine but hides a few things:

a) Who pays the rent
b) If Alice made a mistake in the wire there is no way to check it
c) An extra income is shown for Bob which should disappear after bob
   paid the rent

I thus add a few automatic rules such as:

  =/^Expenses:Bob:Rent$/
      $account  -1
      Expenses:Join:Alice:Rent               0.5
      Expenses:Join:Bob:Rent                 0.5
      ;
      Income:Bob:Alice:Rent                  0.5
      Income:Join:Alice:Rent                -0.5


The goal here is to split Bob's rent expense into 2 Expenses for the
Join accounting and transfers the Bob's income to the Join account.

Now the result is better:

  $ ./test.ledger bal
                $11718  Assets
                $11595    Bob:Bank:Checking
                  $123    Join:Bank:Checking
               $-12468  Equity
               $-12345    Bob:Bank:Checking
                 $-123    Join:Bank:Checking
                 $1500  Expenses:Join
                  $750    Alice:Rent
                  $750    Bob:Rent
                 $-750  Income:Join:Alice:Rent
  --------------------
                     0

We can see who paid what (From Expenses:Join):

  $ ./test.ledger bal '/^(expenses):join/'
                 $1500  Expenses:Join
                  $750    Alice:Rent
                  $750    Bob:Rent
  --------------------
                 $1500

and Bob does not have the extra income:

  $ ./test.ledger bal '/^(expenses|income):bob/'  -E
                     0  Expenses:Bob:Rent
                     0  Income:Bob:Alice:Rent
  --------------------
                     0


But the Join seems to be false then:

  $ ./test.ledger bal '/^(expenses|income):join/'  -E
                 $1500  Expenses:Join
                  $750    Alice:Rent
                  $750    Bob:Rent
                 $-750  Income:Join:Alice:Rent
  --------------------
                  $750

If I understand correctly this means that the Join has more expenses
than income which is logical since there is no Income:Join:Bob:Rent.

Is it correct to add this line to the automatic rule?
    (Income:Join:John:Rent)              -0.5
If I do so, The balance is not 0 unless I query with "-R" switch.

Thus is there a way to display wanted information without using a
virtual transaction? Or from where should I take the amount to balance
"Income:Join:John:Rent"?


extra question: Is there a way to use regexp backrefs to write something
like:

=/^Expenses:Bob:(Rent)$/
    $account  -1
    Expenses:Join:Alice:$1               0.5
    Expenses:Join:Bob:$1                 0.5
    Income:Bob:Alice:$1                  0.5
    Income:Join:Alice:$1                -0.5
    (Income:Join:John:$1)               -0.5


Thanks in advance.

Seb.

Erik Hetzner

unread,
Apr 20, 2016, 2:48:42 AM4/20/16
to ledge...@googlegroups.com, Sébastien Gross
Hi Sébastien,

Here are two ways to do it. I don’t see how the joint account fits in this
scenario, so I’ve ignored it.

First, the simple way:

2016/01/01 Transfer
Assets:Bank:Checking $750
Expenses:Rent -$750

2016/01/01 Rent payment
Assets:Bank:Checking -$1500
Expenses:Rent $1500

This is from Bob’s point of view - his expenses are $750 in rent, and he doesn’t
care what Alice’s expense are or what her bank account looks like.

A more complicated way:

2016/01/01 Transfer
Assets:Bank:Checking $750
Liabilities:Rent -$750

2016/01/01 Rent payment
Assets:Bank:Checking -$1500
Liabilities:Rent $750
Expenses:Rent $750

This is also from Bob’s p.o.v. He doesn’t care about Alice’s expenses, but he
does care that Alice has lent him $750 for rent and he wants to make sure that
he has paid his debt (though his debt was paid to the landlord). So before the
2nd transaction is used, he will have a negative balance in Liabilities:Rent.

More complicated still:

2016/01/01 Transfer
Assets:Bank:Bob:Checking $750
Assets:Bank:Alice:Checking -$750
Expenses:Alice:Rent $750
Liabilities:Bob:Rent -$750

2016/01/01 Rent payment
Assets:Bob:Bank:Checking -$1500
Liabilities:Bob:Rent $750
Expenses:Bob:Rent $750

In this case, we are tracking Alice & Bob’s expenses and accounts. In the first
transaction, the transfer happens between accounts, Alice has paid her rent, and
Alice has loaned $750 to Bob for her share of the rent. In the second, Bob pays
off the debt to Alice and pays the rent.

That is how I would handle it. I am no accountant, but I have used ledger for
situations like this. :)

If you want to bring automated transactions into this, give it a shot, but they
are not as expressive as regular ledger.

best, Erik

On Tue, 19 Apr 2016 07:52:08 -0700,
Sébastien Gross <seb-g...@chezwam.org> wrote:
>
> [1.1 <text/plain; UTF-8 (7bit)>]
> --
>
> ---
> You received this message because you are subscribed to the Google Groups "Ledger" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ledger-cli+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
> [1.2 <text/html; UTF-8 (quoted-printable)>]

Jostein Berntsen

unread,
Apr 21, 2016, 3:11:09 PM4/21/16
to Ledger
I would do this:

Make a separate file for each of the accounts including join with their
own euqity, assests, liabilities setup. Ledger can query all these as
one file. Then when Alice transfers money to Bob from her account it
should be visible as an Expense in her account. Then also use tags for
the transfers to describe what happens, like for Bob:

; Rent: Transfer from Alice March 2016

You can then separate what you need in your queries.

Jostein

Martin Blais

unread,
Apr 21, 2016, 4:33:24 PM4/21/16
to ledger-cli
On Tue, Apr 19, 2016 at 10:52 AM, Sébastien Gross <seb-g...@chezwam.org> wrote:
Hi there,

This might be an ultra-classic use-case of ledger here I am facing.

Let's plot the scene:


- They have their own bank account (Alice and Bob) and a Join account

It's "joint", not "join".
 

- Alice and Bob rent a flat ($1500/mo), which for some reasons is paid
  by Bob from his own account (not for the Join one).
  
- Every month Alice wires half the rent ($750) to Bob's checking account
- Every month wire the rent to the owner

So it sounds like Bob & Alice aren't making use of that joint account.
- Alice wires money from her account to Bob's.
- Bob pays the rent from his checking account.

Where does the joint account come into play?
This seems misguided to me.

Bob should not track the full contents of the joint account on his balance sheet, nor should he be tracking Alice's.
Bob's balance sheet should reflect Bobs' ownership, so only his portion of the joint account.
If the balance sheet & ledger is for "the union of Bob and Alice" then that might work, but I'm reading that it's not what you're trying to do.

Let's look at better ways of doing what you are trying to do.

(1)
The simplest solution involves Bob just keeping track of the money owed by Alice for rent and other expenses. At any time, Alice can make transfers to account for this running balance. I'd keep it as an uncategorized Liabilities account, e.g., "Liabilities:Alice". It can be applied to any type of shared expense. It's the money Alice owes Bob. Print out a journal to explain Alice its current balance.


;; -*- mode: beancount -*-                                                                                                                                                                       
;; This is the simpler solution, one which involves a running account for your roommate.                                                                                                         

plugin "beancount.plugins.auto_accounts"

;; A running account for all of the shared expenses Alice needs to chip in for.                                                                                                                  
2000/01/01 open Liabilities:Alice

2016/01/01 * "Opening balance"
  Assets:Bank:Checking            12345 USD
  Equity:Opening-Balances

;; Shared expenses Alice's part to her running balance.                                                                                                                                          

2016/01/01 * "Paying the rent"
  Assets:Bank:Checking           -1500 USD
  Expenses:Rent                    750 USD
  Liabilities:Alice                750 USD

2016/01/01 * "Paying electricity"
  Assets:Bank:Checking          -45.34 USD
  Expenses:Electricity           45.34/2 USD
  Liabilities:Alice              45.34/2 USD

2016/01/01 * "Alice sends some money towards her running balance"
  Assets:Bank:Checking             1000 USD
  Liabilities:Alice



(2) 
A solution which involves a joint account means two ledger files: one to track Bob's personal balance sheet, and one to track the joint account. Someone uses the joint account to pay for the rent and updates that file, and Bob replicates his side of the transactions in his personal file.

;; -*- mode: beancount -*-                                                                                                                                                                       
;; This is a solution which makes use of the Joint account in order to pay                                                                                                                       
;; shares expenses, and here we represent Bob's side only.                                                                                                                                       

plugin "beancount.plugins.auto_accounts"

;; Personal account of Bob.                                                                                                                                                                             
2000/01/01 open Assets:Bank:Personal

;; Bob's portion of the joint account.                                                                                                                                                              
2000/01/01 open Assets:Bank:Joint

2016/01/01 * "Opening balance"
  Assets:Bank:Checking            12345 USD
  Equity:OpeningBalances

;; You'll need to transfer money to that joint account.                                                                                                                                          
2016/01/01 * "Transferring money to the joint account"
  Assets:Bank:Checking          -2000 USD
  Assets:Bank:Joint

;; Then, expenses have to replicate Bob's portion of what happens to his stash                                                                                                                   
;; in the Joint account.                                                                                                                                                                         
2016/01/01 * "Paying the rent"
  Assets:Bank:Joint
  Expenses:Rent                    750 USD

2016/01/01 * "Paying electricity"
  Assets:Bank:Joint
  Expenses:Electricity           45.34/2 USD



I'm not providing the detail in the joint file here, but it should be obvious.


(3)
You could also combine both of these methods if you'd like to pay the rent from Bob's account and get repayment by making a transfer between Bob and Alice in their joint account.



 

Erik Hetzner

unread,
Apr 22, 2016, 1:59:56 AM4/22/16
to ledge...@googlegroups.com
Hi Martin,

A few quick points:

On Thu, 21 Apr 2016 13:33:02 -0700,
Martin Blais <bl...@furius.ca> wrote:
>

> […]

> 2016/01/01 * "Paying the rent"
> Assets:Bank:Checking -1500 USD
> Expenses:Rent 750 USD
> Liabilities:Alice 750 USD

From Bob’s point of view, this is an asset, not a liability - Alice owes $750 to
Bob. Paying $1500 in rent transfers to $750 to expenses and the other $750 to a
loan - an asset that is reduced when Alice pays back the loan, transferring the
money from the loan asset to a bank account.

> A solution which involves a joint account means two ledger files: one to
> track Bob's personal balance sheet, and one to track the joint account.
> Someone uses the joint account to pay for the rent and updates that file,
> and Bob replicates his side of the transactions in his personal file.

There is no reason not to track both of these accounts in the same file, in my
opinion.

The key question is, what answers do you want? Do you want to know what Bob’s
expenses are? Do you want to know the state of Bob’s bank account? A joint bank
account? How much Alice owes Bob (from Bob’s point of view, or Alice’s?) These
should guide the transactions you enter. There is no “right” answer, no correct
model. It depends on what you want to know.

best, Erik
--
Sent from my free software system <http://fsf.org/>.

Sébastien Gross

unread,
Apr 22, 2016, 9:51:45 AM4/22/16
to Ledger
Hi,

A few things:
- The Joint account is used for all common expenses (grocery, ISP...)
- The rent is not really payed using the joint account (for some reasons)
- I'd like to keep track of what's going on.

The main mistake here is that I wanted to use a single set of files for both Bob and Joint account (remember John does not handle Alice financials)
The solution of having 2 sets of files as suggested by Jostein seems to solve the issue with Erik's method.

On the other hand, using Martin's tutorial for travel ledgering [1] helps a lot. Think Joint expenses an endless trip ;-).


Martin Blais

unread,
Apr 22, 2016, 10:23:30 AM4/22/16
to ledger-cli
On Fri, Apr 22, 2016 at 1:59 AM, Erik Hetzner <ehet...@gmail.com> wrote:
Hi Martin,

A few quick points:

On Thu, 21 Apr 2016 13:33:02 -0700,
Martin Blais <bl...@furius.ca> wrote:
>

> […]

> 2016/01/01 * "Paying the rent"
>   Assets:Bank:Checking           -1500 USD
>   Expenses:Rent                    750 USD
>   Liabilities:Alice                750 USD

From Bob’s point of view, this is an asset, not a liability - Alice owes $750 to
Bob. Paying $1500 in rent transfers to $750 to expenses and the other $750 to a
loan - an asset that is reduced when Alice pays back the loan, transferring the
money from the loan asset to a bank account.

Sure, you can call these "receivables" and track them as an asset.

In Ledger/Beancount worlds, that's just a matter of semantics since all accounts are treated the same, we don't recognize credit & debit accounts. The main question is whether Alice pays her balance ahead of time or after the expenses are incurred. In the former, Bob would generally have some extra money he doesn't own on hand (best viewed as a liability), in the latter case, Bob would have a receivable to be paid by Alice (best viewed as an asset). In the former, the account is positive, in the latter, it'll generally be negative.


> A solution which involves a joint account means two ledger files: one to
> track Bob's personal balance sheet, and one to track the joint account.
> Someone uses the joint account to pay for the rent and updates that file,
> and Bob replicates his side of the transactions in his personal file.

There is no reason not to track both of these accounts in the same file, in my
opinion.

Yes there is. Alice's portion of the joint account should not appear on Bob's balance sheet.


The key question is, what answers do you want? Do you want to know what Bob’s
expenses are? Do you want to know the state of Bob’s bank account? A joint bank
account? How much Alice owes Bob (from Bob’s point of view, or Alice’s?) These
should guide the transactions you enter. There is no “right” answer, no correct
model. It depends on what you want to know.

No I think you're wrong about that. One has to carefully define the notion of "the entity". What's the entity? Bob's money? Bob's money including the joint property? Bob & Alice? "Bob + the joint account, including Alice's money in it" is a strange entity.

 
 

best, Erik
--
Sent from my free software system <http://fsf.org/>.
Reply all
Reply to author
Forward
0 new messages