Changeset - 52ea12d4cf57
[Not reviewed]
0 1 0
Ben Sturmfels (bsturmfels) - 2 months ago 2024-07-18 11:49:08
ben@sturm.com.au
statement_reconciler: switch to generator expression
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/reconcile/statement_reconciler.py
Show inline comments
...
 
@@ -813,49 +813,49 @@ def main(
 
    # convenient, but we don't have access to the full transaction
 
    # entry objects. Feels a bit strange that these approaches are so
 
    # disconnected.
 
    #
 
    # beancount.query.query_compile.compile() and
 
    # beancount.query.query_execute.filter_entries() look useful in this respect,
 
    # but I'm not clear on how to use compile(). An example would help.
 
    entries, _, options = loader.load_file(args.beancount_file)
 
    # String concatenation looks bad, but there's no SQL injection possible here
 
    # because BQL can't write back to the Beancount files. I hope!
 
    query = f"""
 
        SELECT filename,
 
        META("lineno") AS line,
 
        META("bank-statement") AS bank_statement,
 
        date,
 
        number(cost(position)),
 
        payee,
 
        ENTRY_META("entity") as entity,
 
        ANY_META("check-id") as check_id,
 
        narration
 
        WHERE account = "{args.account}"
 
            AND date >= {begin_date}
 
            AND date <= {end_date}"""
 
    _, result_rows = run_query(entries, options, query)
 
    books_trans = sort_records([standardize_beancount_record(row) for row in result_rows])
 
    books_trans = sort_records(standardize_beancount_record(row) for row in result_rows)
 

	
 
    # Apply two passes of matching, one for standard matches and one
 
    # for subset matches.
 
    (
 
        matches,
 
        remaining_statement_trans,
 
        remaining_books_trans,
 
    ) = match_statement_and_books(statement_trans, books_trans)
 
    subset_matches, remaining_statement_trans, remaining_books_trans = subset_match(
 
        remaining_statement_trans, remaining_books_trans
 
    )
 
    matches.extend(subset_matches)
 

	
 
    # Add the remaining unmatched to make one big list of matches, successful or not.
 
    unmatched = process_unmatched(remaining_statement_trans, remaining_books_trans)
 
    matches.extend(unmatched)
 

	
 
    # Print out results of our matching.
 
    print(
 
        format_output(
 
            matches,
 
            begin_date,
 
            end_date,
 
            args.csv_statement,
0 comments (0 inline, 0 general)