Writing scripts

113 views
Skip to first unread message

Olivier Crémel

unread,
Jun 30, 2023, 12:57:08 AM6/30/23
to Beancount
I'd like to write some simple reports, for instance "net income", defined as income minus a set of non-discretionary expenses (like taxes).

So I looked up the doc and it states, more or less:

You call the beancount.loader.load_file() loader function, you get the list of "entries"  and you can process the entries as you like.

And that's it.

But, surely, I'm not expected to re-implement balance computing by going through all the entries, so I assume there is another API that takes "entries" and gives me back balances.

Where do I find a list of such canonical external APIs ?

Thanks.


 



Red S

unread,
Jun 30, 2023, 4:40:11 AM6/30/23
to Beancount
It's all in the documentation. More specifically, balance realization is here.

However, accomplishing what you're wanting to do is easily done by writing BQL + python. The bean-query shell works well for basic queries. For advanced manipulation, a typical recipe is to get the output of a basic query from a BQL statement in python, and then processing the results to your heart's content. Here is an example.


Olivier Crémel

unread,
Jun 30, 2023, 9:47:30 PM6/30/23
to Beancount
Ah! That is not at all what I expected but now I understand how to proceed. Thanks a lot!
Reply all
Reply to author
Forward
0 new messages