Allocating payments to customer accounts - newbie question

432 views
Skip to first unread message

stalbansrf...@gmail.com

unread,
Dec 13, 2016, 7:42:37 AM12/13/16
to Beancount
Hi
I want to use beancount to maintain customers and vendors, and so want to be able to allocate payments to invoices (and, by extension, use it to reconcile bank accounts). 
I'm not sure if this has been solved - I couldn't find anything relating to it on Google.
In essence, this would mean that each transaction has a record showing how much of the transaction has been posted and to where.
For example, a payment of £20 against an invoice of £30 would have a record on both the invoice transaction and payment transaction showing £20. The payment is then fully allocated but the invoice is only partly allocated. This would allow reports to show that £10 was left.
Perhaps this could be done with tags? Has this been solved previously?
Thanks
Paul

Martin Blais

unread,
Dec 15, 2016, 10:31:10 PM12/15/16
to Beancount
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:



--
You received this message because you are subscribed to the Google Groups "Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beancount+unsubscribe@googlegroups.com.
To post to this group, send email to bean...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/27d3787d-1814-4389-b931-0123e211e5c1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

p.w.ha...@gmail.com

unread,
Dec 16, 2016, 3:30:42 PM12/16/16
to Beancount
Perfect thank you so much!
Reply all
Reply to author
Forward
0 new messages