예제 #1
0
import ledger
import re
import sys

account_re = sys.argv[1]

# A poor man's register report

running_total = ledger.Value(0)

for post in ledger.Journal("/Users/johnw/src/ledger/doc/sample.dat").collect(
        "-M assets"):
    print "%s %-20.20s %-20.20s %12s %12s" % \
        (post.xact.date, post.xact.payee, post.account, post.amount,
         running_total)

print "Got to here!"

#running_total = ledger.Value(0)
#
#for txn in ledger.Journal("/Users/johnw/src/ledger/doc/sample.dat"):
#    for post in txn:
#        if re.match(account_re, str(post.account)):
#            running_total += post.amount
#            print "%s %-20.20s %-20.20s %12s %12s" % \
#                (txn.date, txn.payee, post.account, post.amount,
#                 running_total)
예제 #2
0
assertEqual(100.12, amt.to_double())
assert amt.fits_in_long()
assertEqual(100, amt.to_long())

amt2 = ledger.Amount('$100.12 {140 EUR}')

assert amt2.has_annotation()
assertEqual(amt, amt2.strip_annotations(ledger.KeepDetails()))

# jww (2009-11-19): Not working: missing conversion from optional<amount_t>
#assertEqual(ledger.Amount('20 EUR'), amt.annotation.price)

# VALUES

val = ledger.Value('$100.00')

assert val.is_amount()
assertEqual('$', val.to_amount().commodity.symbol)

# JOURNALS

#journal.find_account('')
#journal.find_or_create_account('')

# ACCOUNTS

#account.name
#account.fullname()
#account.amount
#account.total