diff options
-rw-r--r-- | src/py_post.cc | 7 | ||||
-rw-r--r-- | test/regress/9188F587.py | 27 | ||||
-rw-r--r-- | test/regress/9188F587_py.test | 15 |
3 files changed, 45 insertions, 4 deletions
diff --git a/src/py_post.cc b/src/py_post.cc index ce3bd71b..692542a0 100644 --- a/src/py_post.cc +++ b/src/py_post.cc @@ -166,8 +166,8 @@ void export_post() .def("get_tag", py_get_tag_1m) .def("get_tag", py_get_tag_2m) - .def("date", &post_t::date) - .def("aux_date", &post_t::aux_date) + .add_property("date", &post_t::date) + .add_property("aux_date", &post_t::aux_date) .def("must_balance", &post_t::must_balance) @@ -177,8 +177,7 @@ void export_post() .def("has_xdata", &post_t::has_xdata) .def("clear_xdata", &post_t::clear_xdata) - .def("xdata", py_xdata, - return_internal_reference<>()) + .def("xdata", py_xdata, return_internal_reference<>()) //.def("add_to_value", &post_t::add_to_value) .def("set_reported_account", &post_t::set_reported_account) 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 diff --git a/test/regress/9188F587_py.test b/test/regress/9188F587_py.test new file mode 100644 index 00000000..28bb34ff --- /dev/null +++ b/test/regress/9188F587_py.test @@ -0,0 +1,15 @@ +test python test/regress/9188F587.py +-5.00 GBP +GBP +Total is presently: (0.00 EUR) +Converted to EUR: (-6.00 EUR) +Total is now: (-6.00 EUR) + +-5.00 EUR {0.8733 GBP} [2012/01/03] +EUR +Total is presently: (-6.00 EUR) +Converted to EUR: (-5.00 EUR) +Total is now: (-11.00 EUR) + +-11.00 EUR +end test |