Easy.
; -*- mode: beancount -*-
plugin "beancount.plugins.auto_accounts"
2016-09-01 * "Invoicing client A" ^invoice-00000001
Assets:AccountsReceivable:ClientA 30.00 GBP
Income:Work:Services
2016-09-20 * "Invoicing client B" ^invoice-00000002
Assets:AccountsReceivable:ClientB 40.00 GBP
Income:Work:Services
2016-10-01 * "Invoicing client A" ^invoice-00000003
Assets:AccountsReceivable:ClientA 12.00 GBP
Income:Work:Services
2016-09-20 * "Client A" "Payment for invoice" ^invoice-00000001
Assets:AccountsReceivable:ClientA -20.00 GBP
Assets:Checking
You can view how much your liability from this client is, over all invoices:
bean-query stalbansrfctreasurer.beancount "select sum(position) where account = 'Assets:AccountsReceivable:ClientA'"
sum_posit
---------
22.00 GBP
Or you can produce this for each of your clients in one go:
bean-query stalbansrfctreasurer.beancount "select leaf(account) as client, sum(position) as balance where account ~ 'Assets:AccountsReceivable' group by 1"
client balance
------- ---------
ClientB 40.00 GBP
ClientA 22.00 GBP
Finally, if you'd like to isolate that particular invoice, use links or tags to segregate all the transactions for a particular invoice:
bean-query stalbansrfctreasurer.beancount "select date, description, position, balance where account ~ 'Assets:AccountsReceivable:ClientA' and ('invoice-00000001' in links) "
date description position balance
---------- ------------------------------ ---------- ---------
2016-09-01 Invoicing client A 30.00 GBP 30.00 GBP
2016-09-20 Client A | Payment for invoice -20.00 GBP 10.00 GBP
If you invoice payments are always for the total amount owed, you may be able to write a plugin which automatically pairs them up with tags.
See this plugin for some ideas: