Hi,
First let me say that beancount has been a blast to work with so far! The code is really easy to read and follow and extend and I'm very impressed with the overall architecture and design. Thanks a bunch for all the work that has gone into it!
I'm sorry for so many posts all at once! Recently, I've been "refactoring" my account structure to get my reporting a little easier and preparing for tax season next year. But that means I'm writing all sorts of SQL queries for bean-query. There are some roadblocks I'm hitting that can be easily crossed with some additions to the list of functions in bean-query. Here are 2 that I have so far (with links for reference):
So, I'd love to your hear your thoughts on these. As always, I can implement them and send a patch. I hope a hg export should work well for you? Also, I know that I said I could implement the date functions as well. I'm planning on getting to all that this weekend since I would need them for my reports anyway.
As I said, beancount is an awesome product and I'm really happy to contribute to make it better in any way I can.
- Shreedhar
Hi,
First let me say that beancount has been a blast to work with so far! The code is really easy to read and follow and extend and I'm very impressed with the overall architecture and design. Thanks a bunch for all the work that has gone into it!
I'm sorry for so many posts all at once! Recently, I've been "refactoring" my account structure to get my reporting a little easier and preparing for tax season next year. But that means I'm writing all sorts of SQL queries for bean-query. There are some roadblocks I'm hitting that can be easily crossed with some additions to the list of functions in bean-query. Here are 2 that I have so far (with links for reference):
- SUB(pattern, replacement, string) - Basically this would be a wrapper on top of re.sub (link). This helps a lot in case you want to print things slightly differently or reorder something for a report.
- COALESCE(x, y) - This is a staple SQL function to deal with NULLs in the data (link). For example if you want to multiply price and number for a collection of postings but not all have a price and you want price for the NULL scenarios to be interpreted as 1. : SELECT number * COALESCE(price, 1) where narration ~ 'BLAH'. Now, SQL supports variadic arguments which might be tough to implement in beancount, so I think sticking to two arguments is enough because it can be nested to achieve the same effect.
So, I'd love to your hear your thoughts on these.
As always, I can implement them and send a patch.
I hope a hg export should work well for you?
Also, I know that I said I could implement the date functions as well. I'm planning on getting to all that this weekend since I would need them for my reports anyway.
As I said, beancount is an awesome product and I'm really happy to contribute to make it better in any way I can.
--
- Shreedhar
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 beancount+...@googlegroups.com.
To post to this group, send email to bean...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/2591eb99-2d58-45f8-bbe2-06dffe6ae2cd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
On Wed, Nov 14, 2018 at 10:15 PM <shreedha...@gmail.com> wrote:Hi,
First let me say that beancount has been a blast to work with so far! The code is really easy to read and follow and extend and I'm very impressed with the overall architecture and design. Thanks a bunch for all the work that has gone into it!
Thanks for the nice words.I'm always happy when a new voice shows up and I find out it's working for them.I'm sorry for so many posts all at once! Recently, I've been "refactoring" my account structure to get my reporting a little easier and preparing for tax season next year. But that means I'm writing all sorts of SQL queries for bean-query. There are some roadblocks I'm hitting that can be easily crossed with some additions to the list of functions in bean-query. Here are 2 that I have so far (with links for reference):
- SUB(pattern, replacement, string) - Basically this would be a wrapper on top of re.sub (link). This helps a lot in case you want to print things slightly differently or reorder something for a report.
SGTMLet's do it
- COALESCE(x, y) - This is a staple SQL function to deal with NULLs in the data (link). For example if you want to multiply price and number for a collection of postings but not all have a price and you want price for the NULL scenarios to be interpreted as 1. : SELECT number * COALESCE(price, 1) where narration ~ 'BLAH'. Now, SQL supports variadic arguments which might be tough to implement in beancount, so I think sticking to two arguments is enough because it can be nested to achieve the same effect.
Also SGTMI think the dispatching mechanism supports multiple signatures, so you could define versions for 1, 2, 3, 4, 5 parameters (probably sufficient).
def get_function(self, name, operands):
"""Return a function accessor for the given named function.
Args:
name: A string, the name of the function to access.
"""
try:
key = tuple([name] + [operand.dtype for operand in operands])
return self.functions[key](operands)
except KeyError:
# If not found with the operands, try just looking it up by name.
try:
return self.functions[name](operands)
except KeyError:
signature = '{}({})'.format(name,
', '.join(operand.dtype.__name__
for operand in operands))
raise CompilationError("Invalid function '{}' in {} context".format(
signature, self.context_name))So, I'd love to your hear your thoughts on these.
Yes.The SQL client is an experimental thing intended to absorb most feature requests. Very liberal about adding stuff.Note: It's not tested well.The goal is ultimately to reimplement vastly better as a separate project and to have a Beancount adapter for its input.
As always, I can implement them and send a patch.
AwesomeI hope a hg export should work well for you?
If you can wrangle bitbucket that's the no.1 way.Otherwise an export or old-school patch works too.