Example #1
0
def rename():
    old_name, new_name = sys.argv[1:3]
    for dash_f in reporting.list_datfiles():
        filename = dash_f[len('-f '):]
        with open(filename, 'r') as fp:
            contents = fp.read()
        for tmpl in ("    {:<64}$", "    {:<63}-$"):
            old = tmpl.format(old_name)
            new = tmpl.format(new_name)
            contents = contents.replace(old, new)
        with open(filename, 'w+') as fp:
            fp.write(contents)
Example #2
0
#!/usr/bin/env python2.7
from __future__ import absolute_import, division, print_function, unicode_literals

import sys
from os import path

ourdir = path.realpath(path.dirname(__file__))
sys.path.insert(0, ourdir)

import reporting

argv = sys.argv[1:]
start, end = reporting.parse(argv)
cmd = ['ledger'] + argv + reporting.list_datfiles(start, end)

reporting.report(cmd)
Example #3
0
ourdir = path.realpath(path.dirname(__file__))
sys.path.insert(0, ourdir)

import reporting

cmd = [ 'ledger'
      , 'balance'
      , '--prepend-width=0' # this is here to satisfy ledger on Travis
      , '--sort "account =~ /^Assets.*/ ? 0 : '
      ,        '(account =~ /^Liabilities.*/ ? 1 : '
      ,        '(account =~ /^Equity.*/ ? 2 : 3))"'
       ]
cmd += sys.argv[1:]

year, month = reporting.parse(sys.argv[1:])[1]

# Each year opens with a carryover balance, so we don't have to go further back than that.
start = [year, None]
end = [year, month]

cmd += reporting.list_datfiles(start, end)

print()
print("BALANCE SHEET".center(42))
print("as of {} {}, {}".format( calendar.month_name[int(end[1])]
                              , calendar.monthrange(int(end[0]), int(end[1]))[1]
                              , end[0]
                               ).center(42))
print()
reporting.report(cmd)