reconcile.helper: Add entry_point to avoid traceback
This commit is contained in:
parent
026f54bca1
commit
71bf8137a5
1 changed files with 115 additions and 105 deletions
|
@ -114,7 +114,7 @@ def reconciliation_report_path(account, end_date):
|
||||||
return f'Financial/Controls/Reports-for-Treasurer/{end_date}_{account_name}_bank-reconciliation.csv'
|
return f'Financial/Controls/Reports-for-Treasurer/{end_date}_{account_name}_bank-reconciliation.csv'
|
||||||
|
|
||||||
|
|
||||||
def parse_args():
|
def parse_args(argv):
|
||||||
parser = argparse.ArgumentParser(description='Reconciliation helper')
|
parser = argparse.ArgumentParser(description='Reconciliation helper')
|
||||||
parser.add_argument('--beancount-file', required=True)
|
parser.add_argument('--beancount-file', required=True)
|
||||||
parser.add_argument('--account', help='Full account name, e.g. "Liabilities:CreditCard:AMEX"', required=True)
|
parser.add_argument('--account', help='Full account name, e.g. "Liabilities:CreditCard:AMEX"', required=True)
|
||||||
|
@ -126,7 +126,7 @@ def parse_args():
|
||||||
parser.add_argument('--cost-function', default='COST')
|
parser.add_argument('--cost-function', default='COST')
|
||||||
parser.add_argument('--grep-output-filename')
|
parser.add_argument('--grep-output-filename')
|
||||||
# parser.add_argument('--report-group-regex')
|
# parser.add_argument('--report-group-regex')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args(args=argv[1:])
|
||||||
if args.month or args.period:
|
if args.month or args.period:
|
||||||
if not (args.month and args.period):
|
if not (args.month and args.period):
|
||||||
parser.error('--month and --period must be used together')
|
parser.error('--month and --period must be used together')
|
||||||
|
@ -140,7 +140,7 @@ def beancount_file_exists(path):
|
||||||
return os.path.isfile(path)
|
return os.path.isfile(path)
|
||||||
|
|
||||||
|
|
||||||
args = parse_args()
|
def main(args):
|
||||||
if not beancount_file_exists(args.beancount_file):
|
if not beancount_file_exists(args.beancount_file):
|
||||||
sys.exit(f'Beancount file does not exist: {args.beancount_file}')
|
sys.exit(f'Beancount file does not exist: {args.beancount_file}')
|
||||||
if args.month or args.period:
|
if args.month or args.period:
|
||||||
|
@ -245,3 +245,13 @@ report_path = os.path.join(os.getenv('CONSERVANCY_REPOSITORY', ''), reconciliati
|
||||||
with open(report_path, 'w') as f:
|
with open(report_path, 'w') as f:
|
||||||
f.write(reconciliation_report(account, lastDateInPeriod, cleared_balance, uncleared, '1900-01-01', all_trans_balance, []))
|
f.write(reconciliation_report(account, lastDateInPeriod, cleared_balance, uncleared, '1900-01-01', all_trans_balance, []))
|
||||||
print(f'Wrote reconciliation report: {report_path}.')
|
print(f'Wrote reconciliation report: {report_path}.')
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
args = parse_args(sys.argv)
|
||||||
|
main(args)
|
||||||
|
|
||||||
|
|
||||||
|
def entry_point():
|
||||||
|
args = parse_args(sys.argv)
|
||||||
|
main(args)
|
||||||
|
|
Loading…
Reference in a new issue