-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmake-initial
executable file
·54 lines (42 loc) · 1.34 KB
/
make-initial
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python
import csv
import sys
import json
import argparse
def command_line_parser():
"""Create the command line parser."""
parser = argparse.ArgumentParser(
description=("Extract initial account balances from prior year's "
"final balance statement")
)
parser.add_argument(
'--chart',
default='chart.csv',
metavar='CHART',
help=("Chart of accounts dumped from Church Windows as a CSV file"
" (default: %(default)s)")
)
return parser
def scan_chart(file):
"""Scan chart of accounts for initial balances"""
initial = {}
with open(file) as csvfile:
for line in csv.reader(csvfile):
typ = line[0]
fund = line[1]
name = line[2]
number = line[3]
balance = line[5]
if typ in ['Asset', 'Liability', 'Fund', 'Income', 'Expense']:
if balance != '0.00':
if typ == 'Liability' and number == '':
number = name
initial[number] = balance
return initial
def main():
parser = command_line_parser()
args = parser.parse_args()
initial = scan_chart(args.chart)
print json.dumps({"initial balance": initial}, indent=2, sort_keys=True)
if __name__ == "__main__":
main()