Re: bql subtract Amounts?

2021-12-17 Thread Martin Blais
Sorry just catching up on that thread. I've been meaning to delete the beanquery from beancount/master and start using the beanquery repo. To be fair, I haven't been able to switch over yet; I just added it to my environment, it works. I should probably delete beancount/beancount/query Not sure

Re: bql subtract Amounts?

2021-12-14 Thread Ben L
The changes I made were pretty minor and leveraged existing code for adding / subtracting Amounts. See https://github.com/beancount/beancount/pull/688 and let me know what you think, etc. On Tuesday, December 14, 2021 at 4:29:59 PM UTC-5 redst...@gmail.com wrote: > I would start with this

Re: bql subtract Amounts?

2021-12-14 Thread redst...@gmail.com
See this comment right above those lines from Martin. Would be great to do get both these working if you're up for it :) # Note: We ought to implement implicit type

Re: bql subtract Amounts?

2021-12-14 Thread redst...@gmail.com
I would start with this line : class EvalSub(EvalBinaryOp): def __init__(self, left, right): f = lambda x, y: Decimal(x - y) super().__init__(f, left, right,

Re: bql subtract Amounts?

2021-12-14 Thread Ben L
Happy to take a stab at it if you want to point where it look. I can't find where in the beancount code to start. Since the error raised is TypeError, I searched that and for the "unsupported operand" error, but I can't find that in the code. Can you point me to where does the bql stuff for

Re: bql subtract Amounts?

2021-12-13 Thread Martin Blais
I don't think it's supported; you can try adding it (in branch master), should be easy, just check the currencies match On Mon, Dec 13, 2021 at 9:13 PM Ben L wrote: > Is there a way to subtract Amounts (same currency) in bql? > > select cost(position) - value(position); > > I get: > >

bql subtract Amounts?

2021-12-13 Thread Ben L
Is there a way to subtract Amounts (same currency) in bql? select cost(position) - value(position); I get: TypeError: unsupported operand type(s) for -: 'Amount' and 'Amount' I can structure the query so the results are only one currency. Is there a function that will report an Amount as