How to make Pretty Financial Statememts?

854 views
Skip to first unread message

Len Wanger

unread,
Nov 16, 2016, 1:29:16 AM11/16/16
to Beancount

Hi,

Excuse the newbie question. I am trying to make reports that mimic financial statements for a company. I could use some tips on how to get the reports formatted for external consumption. I am currently working on the balance sheet. A few questions I have:

- Is there a way to get the balance sheet report to: 1) show a specified string for an account number, instead of the account name (e.g. account Assets:FixedAssets:Equip to render as "Equipment & Machinery"? Also, is there a way to get the accounts to render in a specified order instead of alphabetical order (e.g I want to have bank accounts, then other current assets, then fixed assets)?
- To do this do I need to write a custom report in Python? Should I look towards the query format? What's the best approach?

Thanks,

Len

Dominik Aumayr

unread,
Nov 16, 2016, 2:10:31 AM11/16/16
to bean...@googlegroups.com
You could implement this on top of Fava (http://beancount.github.io/fava/):

- Generate your report as HTML and then print it as PDF. There are also libraries (http://weasyprint.org for example) that can do that on the server (in Fava) for you, so you can render a HTML-page to a PDF and then send it to the browser.

- In your HTML-template, use metadata for custom names and ordering. This could be optional, so if present it will be used, and the account name by default.

open 2016-01-01 Assets:FixedAssets:Equip USD
report-name: "Equipment & Machinery"
report-order: 2

- If you want to make it even more generic, use a custom option in beancount that let's you specify the path to a custom CSS file, so other users can include their own logo, colors, fonts and other styling without rewriting Python code.

I would love to help if you submit a PR to Fava to include this as a new feature.

Best regards,
Dominik
> --
> 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+...@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/3dc4fc4a-3ec1-46ef-b3d7-2733613be376%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Martin Blais

unread,
Nov 16, 2016, 11:09:47 PM11/16/16
to Beancount
None of the canned ways to query and report allow you to do this at the moment. 

I'd recommend you run a query using SQL / bean-query, render to CSV, and write a script to insert the lines into your favorite template. If you're more ambitious / skilled (at Python), you can also write directly to the Beancount Python API. You could reuse this from a script: https://bitbucket.org/blais/beancount/src/b969f5f75b699707d50e52d686248997e5786655/src/python/beancount/query/query.py?at=default&fileviewer=file-view-default


 

Thanks,

Len

--
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.

Len Wanger

unread,
Nov 18, 2016, 4:15:30 PM11/18/16
to Beancount
Dominik,

Thanks for the reply. I am a happy fava user already, so this sounds like a good approach. I'll take a look and let you know when I need some help.

Len

Martin Blais

unread,
Nov 19, 2016, 6:25:42 PM11/19/16
to Beancount
Hi Lee,
Just another thought about this, something I just remembered now:
There's a way to do this in the SQL shell, by using a function that pulls an account's corresponding Open directive's metadata.
You'd do something like this, where you attach the clean name as an attribute (here "name"):

2016-01-01 open Assets:US:BofA:Checking
  name: "BofA Checking Account"

2016-01-01 open Assets:US:Investments:ETrade
  name: "ETrade Investments"

2016-01-01 open Assets:US:Vanguard:Retirement
  name: "Vanguard Retirement Account"

2016-09-11 *
  Assets:US:BofA:Checking   -12000 USD
  Assets:US:Investments:ETrade    50 AAPL {100.00 USD}
  Assets:US:Investments:ETrade    70 MSFT {100.00 USD}

Then you should be able to produce such a report like this:

bean-query clean-account-names.beancount "select getitem(open_meta(account), 'name') as name, cost(sum(position)) group by 1"

That works:


bean-query /home/blais/r/q/beancount-data/user/leewanger/clean-account-names.beancount "select getitem(open_meta(account), 'name') as name, cost(sum(position)) group by 1"
        name          cost_sum_posi
--------------------- -------------
ETrade Investments     12000.00 USD
BofA Checking Account -12000    USD


I hope this helps,
Also, happy to add new functions to the shell if required,



Reply all
Reply to author
Forward
0 new messages