Changeset - 6b1ce7d73a1a
[Not reviewed]
0 1 0
Ben Sturmfels (bsturmfels) - 2 years ago 2022-02-09 01:58:11
ben@sturm.com.au
reconcile: Fix edge case in helper when only one unreconciled transaction.
1 file changed with 3 insertions and 2 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/reconcile/helper.py
Show inline comments
...
 
@@ -8,24 +8,25 @@ Run like this:
 
    --account="Liabilities:CreditCard:AMEX"
 

	
 
In the spirit of bc-reconcile-helper.plx (the original Perl code)
 

	
 
Not implemented:
 
 - --report-group-regex
 
 - git branch selection from bean-query-goofy-daemon.plx
 

	
 
"""
 
import argparse
 
from dateutil.relativedelta import relativedelta
 
import datetime
 
import decimal
 
import io
 
import tempfile
 
import textwrap
 
import typing
 
from typing import List
 
import os
 

	
 
from beancount import loader
 
from beancount.query.query import run_query
 

	
 

	
 
def end_of_month(date: datetime.date) -> datetime.date:
...
 
@@ -166,19 +167,19 @@ QUERIES = {
 
# Run Beancount queries.
 
print(f"START RECONCILIATION FOR {account} ENDING {lastDateInPeriod} (previous end date {preDate})")
 
entries, _, options = loader.load_file(beancount_file)
 
for desc, query in QUERIES.items():
 
    rtypes, rrows = run_query(entries, options, query, numberify=True)
 
    if not rrows:
 
        print(f'{desc:<55} {"N/A":>11}')
 
    elif desc.startswith('04'):
 
        homedir = os.getenv('HOME', '')
 
        print(f'{desc}\n   See {grep_output_file.name}')
 
        grep_rows = [format_record_for_grep(row, homedir) for row in rrows]
 
        print(tabulate(grep_rows), file=grep_output_file)
 
    elif len(rrows) == 1:
 
    elif len(rrows) == 1 and isinstance(rrows[0][0], decimal.Decimal):
 
        result = rrows[0][0]
 
        print(f'{desc:<55} {result:>11,.2f}')
 
        print(f'{desc:<55} {result:11,.2f}')
 
    else:
 
        headers = [c[0].capitalize() for c in rtypes]
 
        print(desc)
 
        print(textwrap.indent(tabulate(rrows, headers=headers), '    '))
0 comments (0 inline, 0 general)