beancount icon indicating copy to clipboard operation
beancount copied to clipboard

Support pushtag and poptags for transaction directives

Open twilco opened this issue 6 years ago • 3 comments
trafficstars

Transactions can be tagged with using the # symbol. Example:

2014-04-23 * "Flight to Berlin" #berlin-trip-2014
  Expenses:Flights              -1230.27 USD
  Liabilities:CreditCard

You can also push tags onto the stack using the pushtag syntax - transactions after that pushtag should automatically include all pushed tags in the parsed result. Example:

pushtag #berlin-trip-2014

2014-04-23 * "Flight to Berlin"
  Expenses:Flights              -1230.27 USD
  Liabilities:CreditCard

poptag #berlin-trip-2014

We should be able to support this behavior using Pest's PUSH and POP commands - let's do so.

https://docs.google.com/document/d/1wAMVrKIA2qtRGmoVDSUBJGmYZSygUaR0uOMW1GV3YE0/edit#heading=h.qtkt1bjpx3u0

twilco avatar Feb 14 '19 05:02 twilco

Hi there. I found this via the not-yet-awesome-rust project. I have some spare time on my hands and am looking for a project to help with to gain more experience in Rust programming. If you like, I can look into helping with this issue. Thanks.

jaypha avatar Jul 10 '21 08:07 jaypha

Hi @jaypha! Yes, please feel free to give this a go. Let me know if you have any trouble and I’ll do my best to help.

twilco avatar Jul 10 '21 13:07 twilco

Hi. I have uploaded my work to add pushtag and poptag to the code. I am in the process of putting together some larger beancount files to do some more testing before I make a PR. In the meantime, if you wish to review the code, you can go to my jaypha/beancount repo and check it out. Any feedback is welcome.

Just to note: I wasn't able to use the PUSH or POP commands for Pest for two reasons. 1: Beancount's "stack" isn't a true stack. Tags can be popped in any order. The only restriction that each directive needs to be matched by it's opposite somewhere in the appropriate direction. 2: When adding tags to a transaction, you need to access the entire contents of the "stack", not just the latest. I could not find a way to do this with Pest's push and pop.

Regards P.S. Beancount looks pretty cool. I started recording my own finances with it.

jaypha avatar Jul 25 '21 03:07 jaypha