diff --git a/conservancy_beancount/reconcile/statement.py b/conservancy_beancount/reconcile/statement.py index 8edd7339d030b3b4ba2a1a712baaed30636bd5b6..4de7c5f2ee258c462e5ead05e2df4e70dedb13bc 100644 --- a/conservancy_beancount/reconcile/statement.py +++ b/conservancy_beancount/reconcile/statement.py @@ -341,7 +341,7 @@ The default is one month after the start date. action='append', help="""Reconcile this account. You can specify this option multiple times. You can specify a part of the account hierarchy, or an account -classification from metadata. Default 'Cash'. +classification from metadata. Default adapts to your search criteria. """) parser.add_argument( '--id-metadata-key', '-i', @@ -361,10 +361,22 @@ been reconciled. Default varies by account. type=Path, help="""Write the report to this file, or stdout when PATH is `-`. The default is `ReconciliationReport__.ods`. +""") + parser.add_argument( + 'search_terms', + metavar='FILTER', + type=cliutil.SearchTerm.arg_parser(), + nargs=argparse.ZERO_OR_MORE, + help="""Report on postings that match this criteria. The format is +NAME=TERM. TERM is a link or word that must exist in a posting's NAME +metadata to match. """) args = parser.parse_args(arglist) if not args.accounts: - args.accounts = ['Cash'] + if any(term.meta_key == 'payroll-type' for term in args.search_terms): + args.accounts = ['Expenses:Payroll'] + else: + args.accounts = ['Cash'] return args def main(arglist: Optional[Sequence[str]]=None, @@ -425,6 +437,9 @@ def main(arglist: Optional[Sequence[str]]=None, rt_wrapper = config.rt_wrapper() if rt_wrapper is None: logger.warning("could not initialize RT client; spreadsheet links will be broken") + postings = data.Posting.from_entries(entries) + for search_term in args.search_terms: + postings = search_term.filter_postings(postings) report = StatementReconciliation( rt_wrapper, @@ -435,7 +450,7 @@ def main(arglist: Optional[Sequence[str]]=None, args.statement_metadata_key, args.id_metadata_key, ) - report.write(data.Posting.from_entries(entries)) + report.write(postings) if args.output_file is None: out_dir_path = config.repository_path() or Path() args.output_file = out_dir_path / 'ReconciliationReport_{}_{}.ods'.format( diff --git a/setup.py b/setup.py index 52996563d8d4651e81827a6367527bf4b81d1702..b126f4d8f2ec1777852ab61d4c66aa15a8ffe2ba 100755 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ from setuptools import setup setup( name='conservancy_beancount', description="Plugin, library, and reports for reading Conservancy's books", - version='1.17.0', + version='1.17.1', author='Software Freedom Conservancy', author_email='info@sfconservancy.org', license='GNU AGPLv3+',