beanquery
beanquery copied to clipboard
Implement `AVERAGE(inventory)` BQL fucntion
I'm going through the TODO.md file checking what has been implemented already, what fits with the current vision for beanquery, and what remains to do. There are two entries related to an AVERAGE() or AVG() function that operates on inventories.
The first is an example query:
SELECT
root_account, AVG(balance)
FROM (
SELECT
MAXDEPTH(account, 2) as root_account
MONTH(date) as month,
SUM(change) as balance
WHERE
date > 2014-01-01
GROUP BY
root_account,
month
)
GROUP BY
root_account
which should work, except there is no AVG() function. How would an AVG() function work on inventories? I'm not sure a definition where the different commodity components of the inventory are averaged makes much sense, but I cannot think of a better one that is universally useful.
The second is this note:
FIXME: To render holdings at "average cost", e.g. when aggregating by account, you could provide an "AVERAGE(Inventory)" function that merges an inventory's lots in the same way that the holdings merge right now. THIS is how to replace and remove all holdings support.
which I'm not sure I completely understand.
@blais What did you have in mind?