Changeset - 5d45171ed7c4
[Not reviewed]
0 1 0
Ben Sturmfels (bsturmfels) - 2 years ago 2022-02-09 23:15:01
ben@sturm.com.au
reconcile: Add statement total and cleared total.
1 file changed with 17 insertions and 0 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/reconcile/prototype_amex_reconciler.py
Show inline comments
...
 
@@ -29,2 +29,3 @@ Problems in scope:
 
Q. How are reconciliation reports created currently? How do you read them?
 
 - by hand from copying and pasting from the helper tool output
 

	
...
 
@@ -112,4 +113,7 @@ parser.add_argument('--grep-output-filename')
 
parser.add_argument('--show-reconciled-matches', action='store_true')
 
parser.add_argument('--statement-total', required=True)
 
args = parser.parse_args()
 

	
 
statement_total = decimal.Decimal(args.statement_total)
 

	
 
# TODO: Should put in a sanity check to make sure the statement you're feeding
...
 
@@ -137,2 +141,12 @@ entries, _, options = loader.load_file(args.beancount_file)
 

	
 
total_query = f"""SELECT sum(COST(position)) AS aa WHERE account = "{args.account}"
 
    AND date <= {end_date.isoformat()} AND META('bank-statement') != NULL"""
 
result_types, result_rows = run_query(
 
    entries,
 
    options,
 
    total_query,
 
    numberify=True,
 
)
 
cleared_total = result_rows[0][0]
 

	
 
# String concatenation looks bad, but there's no SQL injection possible here
...
 
@@ -185,2 +199,5 @@ for _, output in sorted(matches):
 
print('-' * 155)
 
print(f'STATEMENT TOTAL: {statement_total}')
 
print(f'CLEARED TOTAL:   {cleared_total:12,.2f}')
 
print('-' * 155)
 

	
0 comments (0 inline, 0 general)