diff options
author | John Wiegley <johnw@newartisans.com> | 2012-03-30 00:50:10 -0500 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2012-03-30 00:51:06 -0500 |
commit | 931d6ff3f4c805232fd531da1750ab43befee8d2 (patch) | |
tree | 8a77f15976ef5a6e5314216217a1414dc5a4075e /test/regress/9188F587.py | |
parent | bf66abc258ee70de5bd5510301795168f46929f8 (diff) | |
download | fork-ledger-931d6ff3f4c805232fd531da1750ab43befee8d2.tar.gz fork-ledger-931d6ff3f4c805232fd531da1750ab43befee8d2.tar.bz2 fork-ledger-931d6ff3f4c805232fd531da1750ab43befee8d2.zip |
Fix to Python value() method handling
Diffstat (limited to 'test/regress/9188F587.py')
-rw-r--r-- | test/regress/9188F587.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/regress/9188F587.py b/test/regress/9188F587.py new file mode 100644 index 00000000..50195252 --- /dev/null +++ b/test/regress/9188F587.py @@ -0,0 +1,27 @@ +import ledger + +eur = ledger.commodities.find_or_create('EUR') + +total_eur = ledger.Amount("0.00 EUR") +total_gbp = ledger.Amount("0.00 GBP") +total = ledger.Amount("0.00 EUR") + +for post in ledger.read_journal("test/regress/78AB4B87.dat").query("^income:"): + print post.amount + print post.amount.commodity + if post.amount.commodity == "EUR": + total_eur += post.amount + elif post.amount.commodity == "GBP": + total_gbp += post.amount + + a = post.amount.value(eur, post.date) + if a: + print "Total is presently: (%s)" % total + print "Converted to EUR: (%s)" % a + total += a + print "Total is now: (%s)" % total + else: + print "Cannot convert '%s'" % post.amount + print + +print total |