source: remit/util/add_gl_accounts.py

Last change on this file was f298bd7, checked in by Alex Dehnert <adehnert@…>, 11 years ago

Allow using a virtualenv's Python

Rather than starting each script with #!/usr/bin/python, we change to
#!/usr/bin/env python, to allow using Python's supplied by a virtualenv we're
running in.

  • Property mode set to 100755
File size: 1.4 KB
Line 
1#!/usr/bin/env python
2
3import sys
4import os
5
6if __name__ == '__main__':
7    cur_file = os.path.abspath(__file__)
8    django_dir = os.path.abspath(os.path.join(os.path.dirname(cur_file), '..'))
9    sys.path.append(django_dir)
10    os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
11
12import finance_core.models
13import vouchers.models
14import finance_core.util
15
16expense_gls = (
17    ('Travel', 420050),
18    ('Audio-Visual', 420106),
19    ('Conference Expense', 420140),
20    ('Entertainment', 420166),
21    ('Materials and Services', 420226),
22    ('Office Supplies', 420258),
23    ('Professional Services', 420298),
24    ('Copying', 420392),
25    ('Books and Publications', 420800),
26    ('Food', None),
27    ('Food.Meetings', 421000),
28    ('Food.Events', 421200),
29    ('IT', None),
30    ('IT.Computer Supplies', 421900),
31    ('IT.On-line Services', 421920),
32    ('Promotional & Memorabilia', 420302),
33)
34
35def add_gl_accounts():
36    try:
37        base = finance_core.models.BudgetArea.get_by_path(['Accounts', 'Expenses', ])
38    except KeyError:
39        base = finance_core.models.BudgetArea.get_by_path(['Accounts',])
40        base = base.add_child(name='Expenses', always=True, use_owner=True)
41        base = finance_core.models.BudgetArea.get_by_path(['Accounts', 'Expenses', ])
42    finance_core.util.mass_add_accounts(base, expense_gls, writeto=sys.stdout)
43
44
45if __name__ == '__main__':
46    add_gl_accounts()
Note: See TracBrowser for help on using the repository browser.