Coming from the Ledger half of the Free accounting world, I'm used to
the fact that transaction metadata propagates down to postings. Please
correct me if I'm wrong, but this doesn't seem to be the case in
Beancount, at least according to my experiments with bean-query.
I'm fine with Beancount model for this. But when querying it is
sometimes handy to have a way to lookup a metadata *first* in a posting,
and then fallback to the parent transaction if the metadata key is not
defined in the posting. Is there a way to implement this in Beancount
SQL language? E.g., is there a boolean (or n-ary) operator that takes
two (or more) values and return the first of them that is not NULL?
Either way, it might be helpful to have a SQL function that will lookup
a metadata key first in a posting and then fallbacks on the parent
transaction. Attached you can find a proposal for such a function,
called ANY_META for lack of better naming ideas.
It works for me, but I'm open to better suggestion on how to
"hierarchically" lookup metadata within transactions.
Cheers.
--
Stefano Zacchiroli .
za...@upsilon.cc .
upsilon.cc/zack . . o . . . o . o
Computer Science Professor . CTO Software Heritage . . . . . o . . . o o
Former Debian Project Leader . OSI Board Director . . . o o o . . . o .
« the first rule of tautology club is the first rule of tautology club »