diff --git a/conservancy_beancount/reports/core.py b/conservancy_beancount/reports/core.py index ec71f6c5e55fc6218fae873b2f4781c53fd05792..1d271a707bb1e7bf98a796416bc55845b5c04020 100644 --- a/conservancy_beancount/reports/core.py +++ b/conservancy_beancount/reports/core.py @@ -29,9 +29,14 @@ from typing import ( Mapping, Optional, Sequence, + Set, Tuple, Union, ) +from ..beancount_types import ( + MetaKey, + MetaValue, +) class Balance(Mapping[str, data.Amount]): """A collection of amounts mapped by currency @@ -134,3 +139,9 @@ class RelatedPostings(Sequence[data.Posting]): return balance except NameError: return Balance() + + def meta_values(self, + key: MetaKey, + default: Optional[MetaValue]=None, + ) -> Set[Optional[MetaValue]]: + return {post.meta.get(key, default) for post in self}