From 1cc4e732f4e2051432d6e656ed859bb092b401b5 Mon Sep 17 00:00:00 2001 From: Brett Smith Date: Wed, 21 Oct 2020 09:19:09 -0400 Subject: [PATCH] accrual: Add --end option. For assemble-audit-reports as shown. --- conservancy_beancount/reports/accrual.py | 17 +++++++++++++++-- conservancy_beancount/tools/audit_report.py | 7 ++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/conservancy_beancount/reports/accrual.py b/conservancy_beancount/reports/accrual.py index 39a306f..b6b0bfe 100644 --- a/conservancy_beancount/reports/accrual.py +++ b/conservancy_beancount/reports/accrual.py @@ -667,6 +667,14 @@ and `balance` any other time. You can either specify a fiscal year, or a negative offset from the current fiscal year, to start loading entries from. The default is to load the current, unaudited books. +""") + parser.add_argument( + '--end', '--stop', '-e', + dest='stop_date', + metavar='DATE', + type=cliutil.date_arg, + help="""Do not consider entries from this date forward, in YYYY-MM-DD +format. """) parser.add_argument( '--output-file', '-O', @@ -723,7 +731,12 @@ def main(arglist: Optional[Sequence[str]]=None, for error in load_errors: bc_printer.print_error(error, file=stderr) - postings_src = data.Posting.from_entries(entries) + stop_date = args.stop_date or datetime.date(datetime.MAXYEAR, 12, 31) + postings_src: Iterator[data.Posting] = ( + posting + for posting in data.Posting.from_entries(entries) + if posting.meta.date < stop_date + ) for rewrite_path in args.rewrite_rules: try: ruleset = rewrite.RewriteRuleset.from_yaml(rewrite_path) @@ -775,7 +788,7 @@ def main(arglist: Optional[Sequence[str]]=None, args.output_file = out_dir_path / now.strftime('AgingReport_%Y-%m-%d_%H:%M.ods') logger.info("Writing report to %s", args.output_file) out_bin = cliutil.bytes_output(args.output_file, stdout) - report = AgingReport(rt_wrapper, out_bin) + report = AgingReport(rt_wrapper, out_bin, args.stop_date) report.ods.set_common_properties(config.books_repo()) elif args.report_type is ReportType.OUTGOING: rt_wrapper = config.rt_wrapper() diff --git a/conservancy_beancount/tools/audit_report.py b/conservancy_beancount/tools/audit_report.py index 096a78c..a8a773e 100644 --- a/conservancy_beancount/tools/audit_report.py +++ b/conservancy_beancount/tools/audit_report.py @@ -184,7 +184,12 @@ def main(arglist: Optional[Sequence[str]]=None, (ledger.main, list(common_args('Receipts', args.audit_year, '--receipts'))), (ledger.main, list(common_args('Disbursements', next_year, '--disbursements'))), (ledger.main, list(common_args('Receipts', next_year, '--receipts'))), - (accrual.main, list(common_args('AgingReport.ods'))), + (accrual.main, list(common_args(f'FY{next_year}AgingReport.ods'))), + (accrual.main, list(common_args( + f'FY{args.audit_year}AgingReport.ods', + None, + f'--end={audit_end.isoformat()}', + ))), (balance_sheet.main, list(common_args('Summary', args.audit_year))), (fund.main, list(common_args('FundReport', args.audit_year))), (fund.main, list(common_args('FundReport', next_year))),