diff options
-rw-r--r-- | test/regress/78AB4B87.dat | 14 | ||||
-rw-r--r-- | test/regress/78AB4B87.py | 27 | ||||
-rw-r--r-- | test/regress/78AB4B87_py.test | 15 |
3 files changed, 56 insertions, 0 deletions
diff --git a/test/regress/78AB4B87.dat b/test/regress/78AB4B87.dat new file mode 100644 index 00000000..45b3028a --- /dev/null +++ b/test/regress/78AB4B87.dat @@ -0,0 +1,14 @@ +D 1000.00 EUR +P 2011-01-01 GBP 1.2 EUR + +2011-01-01 * Opening balance + Assets:Bank 10.00 GBP + Equity:Opening balance + +2012-01-02 * Test + Assets:Bank 5.00 GBP + Income:Whatever + +2012-01-03 * Test + Assets:Bank + Income:Whatever -5.00 EUR @ 0.8733 GBP diff --git a/test/regress/78AB4B87.py b/test/regress/78AB4B87.py new file mode 100644 index 00000000..fed95b54 --- /dev/null +++ b/test/regress/78AB4B87.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) + 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 diff --git a/test/regress/78AB4B87_py.test b/test/regress/78AB4B87_py.test new file mode 100644 index 00000000..8f847145 --- /dev/null +++ b/test/regress/78AB4B87_py.test @@ -0,0 +1,15 @@ +test python test/regress/78AB4B87.py +-5.00 GBP +GBP +Total is presently: (0.00 EUR) +Converted to EUR: (-5.73 EUR) +Total is now: (-5.73 EUR) + +-5.00 EUR {0.8733 GBP} [2012/01/03] +EUR +Total is presently: (-5.73 EUR) +Converted to EUR: (-5.00 EUR) +Total is now: (-10.73 EUR) + +-10.73 EUR +end test |