beancount> select * where type != "transaction"
(empty)
beancount>
2017-03-01 note Assets:Credits:CLIENT "Via Lungolago 13, CH-6900 Lugano" #address
SELECT last(narration) FROM (type = "note") AND ("address" in tags) WHERE account = "Assets:Credits:CLIENT"
2017-03-01 open Assets:Credits:CLIENT
address: ""
telephone: ""
contact:""--
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+unsubscribe@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/e0ef1c87-578f-4656-aeb7-d3cc9716352c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
2017-03-01 open Assets:Credits:CLIENT
name: "Client's Company Name"
address: "1234 somewhere, someplace 0000 USA"
e-mail: "he...@adele.com"#!/usr/bin/env python3
from beancount.core import data
import re
def get_open_meta(entries, acct_regex):
"""
Return a dictionary formed from combining the metadata dictionaries
of all 'Open' statements for accounts matching 'acct_regex'.
Will return an empty dicionary if no accounts matched.
Done this say so that metadata from multiple related accounts can be gathered
into one set, which can then be queried.
"""
meta = {}
for ent in entries:
if type(ent) == data.Open and re.match(acct_regex, ent.account):
meta.update(ent.meta)
return meta
# MAIN
if __name__ == "__main__" :
from beancount import loader
entries, errors, options = loader.load_file("somefile.beancount")
meta = get_open_meta(entries, '.*CLIENT') #client metadata
print("""
{0}
{1}
{2}""".format(meta['name'], #will error if 'name' not defined
' \n'.join(meta['address'].split('; ')), #allows multiple lines as 'line1; line2'
meta.get('e-mail')) #doesn't barf if e-mail isn't specified
)
--
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+unsubscribe@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/fd6fd747-fc78-48f1-a86e-5e282a8676d2%40googlegroups.com.
from beancount.loader import load_file
from beancount.core import data
import re
# MAIN
if __name__ == "__main__" :
# parse beancount file
entries, errors, options = load_file("somefile.beancount")
# gather metadata from all account 'open' directives
meta = { k: v for ent in entries for k, v in ent.meta.items()
if type(ent) == data.Open and re.match('.*CLIENT', ent.account)
}
# print statement from earlier example goes here
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.