Hey everyone,
I wanted to sort my transactions, and at the same time I really wanted to be able to access my Journal from the JVM.
It contains a parser implementation based on ANTLRv4 that is 99% compatible with normal Beancount (working on full support). Currently it errors on pushtag/poptag and emacs mode sections.
It has the ability to stably sort all transactions in a file based on the date (I don't think this existed in the ecosystem at all? - it generally works with comments, still improving on that front in coming iterations)
It also contains a formatter kind of similar to bean-format. Both will be expanded in the future to offer opinionated formatting.
The library architecture is based on the battle-tested
GraphQL Java library way of transforming the AST into an immutable data structure. With Java 17 sealed classes it is fully typesafe.
It also contains a feature to merge multiple journals together into one (or your root journal with include pragmas into one!).
It also uses GraalVM, this makes startup time a non-issue.
Measure-Command {.\jbeancount.exe merge -r -o merged.beancount all.beancount; .\jbeancount.exe format --experimental-sort-transactions merged.beancount -o merged.beancount}
Merges my ~15 files into a 14.000 line file and sorts+formats the transactions in ~270 milliseconds (it currently sorts a bit jangly when transaction directives are intermixed with other directives or pragmas - this will be fixed)
I'll accept feature requests for the sorting and formatting, or general library requests in the GitHub issue tracker. Test coverage will also improve (currently only manual testing on my big transaction-only-by-year files)
Thank you Martin for the amazing work on Beancount.
Regards,
Jordie