Changeset - b5a22a963f77
[Not reviewed]
0 2 0
Brett Smith - 3 years ago 2021-02-01 15:11:12
brettcsmith@brettcsmith.org
statement: Accept search terms.

This is the most consistent way to be able to reconcile specific kinds of
payroll taxes.
2 files changed with 19 insertions and 4 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/reconcile/statement.py
Show inline comments
...
 
@@ -338,13 +338,13 @@ The default is one month after the start date.
 
        '--account', '-a',
 
        dest='accounts',
 
        metavar='ACCOUNT',
 
        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',
 
        metavar='METAKEY',
 
        help="""Show the named metadata as a posting identifier.
 
Default varies by account.
...
 
@@ -358,16 +358,28 @@ been reconciled. Default varies by account.
 
    parser.add_argument(
 
        '--output-file', '-O',
 
        metavar='PATH',
 
        type=Path,
 
        help="""Write the report to this file, or stdout when PATH is `-`.
 
The default is `ReconciliationReport_<StartDate>_<StopDate>.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,
 
         stdout: TextIO=sys.stdout,
 
         stderr: TextIO=sys.stderr,
 
         config: Optional[configmod.Config]=None,
...
 
@@ -422,23 +434,26 @@ def main(arglist: Optional[Sequence[str]]=None,
 

	
 
    for error in load_errors:
 
        bc_printer.print_error(error, file=stderr)
 
    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,
 
        pre_range,
 
        rec_range,
 
        post_range,
 
        real_accounts,
 
        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(
 
            args.start_date.isoformat(),
 
            args.stop_date.isoformat(),
 
        )
setup.py
Show inline comments
...
 
@@ -2,13 +2,13 @@
 

	
 
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+',
 

	
 
    install_requires=[
 
        'babel>=2.6',  # Debian:python3-babel
0 comments (0 inline, 0 general)