Beancount txn parser/writer in Emacs Lisp?

Hi friends,

Over the last years I seem to have implemented some hacky parts of this here and there, and was about to start working on pulling it together properly into a library, and perhaps even publishing it at some point. However I thought I would check around and see if anyone else did it already (as I have a bad habit of re-implementing things that already exist).

I searched the official Beancount mailing list, as well as the Library section of the PTA website, but only found some Rust and tree-sitter based parsers[0]. Maybe that's a better way to go about it, but I don't know Rust (nor tree-sitter) and so...

Why else? Because I don't particularly like Python, I just prefer working on my books in Emacs and often find myself writing my own tools in Emacs Lisp (generally speaking).

I plan on sending this to the Beancount mailing list, as well as maybe r/plaintextaccounting, so apologies if you frequent any of those and see it duplicated.

Any thoughts would be appreciated.

[0] Which seem to be, to date, apparently WIP/incomplete(?).

1 Like

I am very pleased to announce the initial release of my parser/writer library!

beancount-txn-elisp

A library to read/parse and write/insert individual Beancount transactions, implemented in Emacs Lisp.

Please try to break it! :smiley: And let me know if you are successful.

https://sr.ht/~trs-80/beancount-txn-elisp/

2 Likes

Version 0.1.0 published

I just wanted to publish an update. I’ve been using (and improving) my little library this whole time, fixing bugs, adding (small) features, etc. I use it multiple times per week, it’s a big (if underlying) part of my almost completely automated system, I probably couldn’t really do PTA without it.

I just published version 0.1.0, the main feature is “categorizer” support. If you set the variable bean-txn-categorizer (which see) to the name of some function, the TXN-FORM will be passed through said function and modified however you like.

Change log:

Enjoy!

1 Like

Very cool. How does this fit into your workflow ? Does it make editing the journal easier ?

To answer directly, not really, at least not in terms of what I would consider “editing.”

As I think I hinted at, I am using this as more of an underlying library, to be used by other things.

I should probably state that I am not doing the typical straight “import” that most seem to be (bank CSV or whatever). I mean, I used to do that. But I didn’t like it (I found the bank descriptions ugly, quite frankly, lol).

Some things I do, for example:

Take photo of receipt and upload to → Veryfi API → then download jpg, PDF, txt, and JSON[0] of receipt → replace original local file and generate Beancount txn automatically from that.

It’s that latter part (writing the Beancount txn) that I use this for.

I also updated my transfer function (and others) to use this library now.

Then I reconcile my txns, which I get from SimpleFIN API. If I missed any (exist in bank’s records but not mine), I can hit a key “(w)rite” and that also uses this library.

etc…

[0] This is where Veryfi really shines. They not only crop and do OCR, they return JSON of all relevant individual fields as key-value pairs (date, card number, vendor, and many more…).