reconcile: Update cleared query.

This commit is contained in:
Ben Sturmfels 2022-02-10 10:23:00 +11:00
parent 5d45171ed7
commit 4bb6177e45
Signed by: bsturmfels
GPG key ID: 023C05E2C9C068F0

View file

@ -29,6 +29,8 @@ Problems in scope:
Q. How are reconciliation reports created currently? How do you read them? Q. How are reconciliation reports created currently? How do you read them?
- by hand from copying and pasting from the helper tool output - by hand from copying and pasting from the helper tool output
Problem is potentially similar to diff-ing, but in the books, transaction order isn't super significant.
TODO/ISSUES: TODO/ISSUES:
- AMEX statement doesn't provide bank balance or running total - AMEX statement doesn't provide bank balance or running total
@ -139,14 +141,15 @@ end_date = statement_trans[-1]['date']
# but I'm not clear on how to use compile(). An example would help. # but I'm not clear on how to use compile(). An example would help.
entries, _, options = loader.load_file(args.beancount_file) entries, _, options = loader.load_file(args.beancount_file)
total_query = f"""SELECT sum(COST(position)) AS aa WHERE account = "{args.account}" cleared_query = f"""SELECT sum(COST(position)) AS aa WHERE account = "{args.account}"
AND date <= {end_date.isoformat()} AND META('bank-statement') != NULL""" AND date <= {end_date.isoformat()} AND META('bank-statement') != NULL"""
result_types, result_rows = run_query( result_types, result_rows = run_query(
entries, entries,
options, options,
total_query, cleared_query,
numberify=True, numberify=True,
) )
cleared_total = result_rows[0][0] cleared_total = result_rows[0][0]
# String concatenation looks bad, but there's no SQL injection possible here # String concatenation looks bad, but there's no SQL injection possible here