Exemple #1
0
      flush=True)
accounts_ = ledger.queryHledgerForAccountListWithBalance(hledger_ledgerpath_,
                                                         depth=depth,
                                                         args=sys.argv[1:])
print("done")

#need to convert filter-generator to actual list or we can only read it once
print(
    "getting journal from hledger (apply filters) and parsing it into python objects ...",
    end="",
    flush=True)
transactions = list(
    filter(
        lambda t: len(t.postings) > 0,
        ledger.parseJournal(
            ledger.getHLedger(hledger_ledgerpath_, ["--cost"] + sys.argv[1:],
                              depth=None))))
print("done")

print("depth limiting transactions ...", end="", flush=True)
for t in transactions:
    t.reduceDepth(depth)
print("done")

transactions_with_tempaccounts_without_multidates = list(
    ledger.sortTransactionsByDate(
        list(
            ledger.createTempAccountsForAndConvertFromMultiDatePostings(
                transactions))))

## make running sum of journal for the graphs
print("calculating running sum ...", end="", flush=True)
Exemple #2
0
    def addLabel(self, label):
        self.graph.append('labelloc="t"')
        if self.html:
            self.graph.append('label=<<u><b>%s</b></u>>' % cgi.escape(label))
        else:
            self.graph.append('label="%s"' % label.replace("\"","\\\""))

    def mkGraph(self, name):
        return "digraph %s {\n" % (name,) + "".join(map(lambda s: "\t%s;\n" % s ,self.graph)) + "}\n"


depth = 3
#depth = None
accounts = ledger.queryHledgerForAccountListWithBalance(hledger_ledgerpath_, depth=depth)
transactions = filter(lambda t: len(t.postings) > 0, ledger.parseJournal(ledger.getHLedger(hledger_ledgerpath_, ["--cost"],depth=None)))
#transactions_all = ledger.parseJournal(ledger.getHLedger(hledger_ledgerpath_, ["--cost"],depth=None))
transactions_dict = {}
for t in transactions:
    if t.name in transactions_dict:
        try:
            transactions_dict[t.name].mergeInPostingsFrom(t)
        except ledger.DifferentCurrency:
            print("Transaction Currencies Differ:", file=sys.stderr)
            print(transactions_dict[t.name], file=sys.stderr)
            print(t, file=sys.stderr)
    else:
        transactions_dict[t.name] = t.reduceDepth(None) # make sure each posting has an unique account

for t in transactions_dict.values():
    t.reduceDepth(depth)
Exemple #3
0
        else:
            self.graph.append('label="%s"' % label.replace("\"", "\\\""))

    def mkGraph(self, name):
        return "digraph %s {\n" % (name, ) + "".join(
            map(lambda s: "\t%s;\n" % s, self.graph)) + "}\n"


depth = 3
#depth = None
accounts = ledger.queryHledgerForAccountListWithBalance(hledger_ledgerpath_,
                                                        depth=depth)
transactions = filter(
    lambda t: len(t.postings) > 0,
    ledger.parseJournal(
        ledger.getHLedger(hledger_ledgerpath_, ["--cost"], depth=None)))
#transactions_all = ledger.parseJournal(ledger.getHLedger(hledger_ledgerpath_, ["--cost"],depth=None))
transactions_dict = {}
for t in transactions:
    if t.name in transactions_dict:
        try:
            transactions_dict[t.name].mergeInPostingsFrom(t)
        except ledger.DifferentCurrency:
            print("Transaction Currencies Differ:", file=sys.stderr)
            print(transactions_dict[t.name], file=sys.stderr)
            print(t, file=sys.stderr)
    else:
        transactions_dict[t.name] = t.reduceDepth(
            None)  # make sure each posting has an unique account

for t in transactions_dict.values():

############## MAIN #####################

depth = 3
#depth = None
print("running hledger (apply filters), getting balances ...", end="", flush=True)
accounts_ = ledger.queryHledgerForAccountListWithBalance(hledger_ledgerpath_, depth=depth, args=sys.argv[1:])
print("done")

#need to convert filter-generator to actual list or we can only read it once
print("getting journal from hledger (apply filters) and parsing it into python objects ...", end="", flush=True)
transactions = list(
                filter(
                    lambda t: len(t.postings) > 0, ledger.parseJournal(
                        ledger.getHLedger(hledger_ledgerpath_, ["--cost"] + sys.argv[1:],depth=None)
                        )
                    )
                )
print("done")

print("depth limiting transactions ...", end="", flush=True)
for t in transactions:
    t.reduceDepth(depth)
print("done")

transactions_with_tempaccounts_without_multidates = list(ledger.sortTransactionsByDate(
        list(ledger.createTempAccountsForAndConvertFromMultiDatePostings(transactions))
    ))

## make running sum of journal for the graphs