Hi beancounters,

One thing I have been wanting for long in beancount ecosystem is some 
tooling to programmatically *edit* my ledger. For example:

   - Formatting
      - Sort ledger entries, without losing formatting, comments, or 
      pushtag.
      - Sort postings / meta.
      - Format non-transactions and details (e.g. inside cost) that 
      bean-format doesn't do.
      - Enforce formatting rules.
   - Refactoring
      - Rearrange my accounts based on narration / tags / comments.
      - Optimize existing ledgers with plugins.
         - Migrate some posting meta to the inline form by 
         autobean.narration 
         <https://github.com/SEIAROTg/autobean/tree/master/autobean/narration>
         .
         - Migrate my tedious stock split transactions to use the 
         single-line form by autobean.stock_split 
         <https://github.com/SEIAROTg/autobean/tree/master/autobean/stock_split>
         .
      - Ease plugin usage by having automatic onboarding script that 
      inserts "plugin" directive and optimize existing ledger.
      - Automatically migrate from v2 to v3 syntax.
      - Automatically migrate from / to other bookkeeping systems.
   - Importing
      - Generate postings with total price (@@), which the official models 
      don't support.
      - Let importers insert transactions directly to the right file, at 
      the right line.
      - Let importers find and augment existing transactions.
         - A receipt OCR importer may find the transaction previously 
         imported from the bank and add postings about what I bought.
      - Automatically generate refund transaction in an editor extension.
   
There are some existing ways doing editing:

   - Manual editing always works, but takes time.
   - Plugin is great but sometimes I want to land the changes in the file.
   - beancount.loader applies plugins, drops spacing, comments and 
   directives (pushtag).
   - beancount.parser doesn't apply plugins, but also drops spacing, 
   comments and directives.

As a solution to *all* above use cases, I've come up with autobean.refactor 
<https://github.com/SEIAROTg/autobean/tree/master/autobean/refactor>, which 
is a pure Python library providing an ergonomic yet powerful interface to 
edit beancount files. It's now 80% completed so I'm sharing it here, though 
there are still some missing pieces (coming soon):

   - Documentation
   - Performance improvements
   - Support for out-of-line tags / links in transaction

You can play with it here: 
https://replit.com/@SEIAROTg/autobeanrefactor-example#main.py or check out 
more examples in tests 
<https://github.com/SEIAROTg/autobean/tree/master/autobean/refactor/tests>.

Anyone interested in this project? Any bug reports / suggestions would be 
appreciated.

Regards,
SEIAROTg

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/5b92826f-3fba-4f0f-a47a-c9c9d77bfd4en%40googlegroups.com.

Reply via email to