summaryrefslogtreecommitdiff
path: root/py_amount.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2007-04-16 04:27:26 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 03:35:35 -0400
commite7f9486f6e524947a29b8e7d20bc834a240a3b23 (patch)
tree9720b3b7750bffc3cab66a707cac8719371ad857 /py_amount.cc
parent8a63ad1c8d0f03b9be57331f911c0ccd998ece68 (diff)
downloadfork-ledger-e7f9486f6e524947a29b8e7d20bc834a240a3b23.tar.gz
fork-ledger-e7f9486f6e524947a29b8e7d20bc834a240a3b23.tar.bz2
fork-ledger-e7f9486f6e524947a29b8e7d20bc834a240a3b23.zip
Finished uncommoditized amount unit tests.
Diffstat (limited to 'py_amount.cc')
-rw-r--r--py_amount.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/py_amount.cc b/py_amount.cc
index d8f42762..ac36b134 100644
--- a/py_amount.cc
+++ b/py_amount.cc
@@ -21,6 +21,13 @@ void py_parse_2(amount_t& amount, const std::string& str) {
amount.parse(str);
}
+amount_t py_round_1(amount_t& amount, unsigned int prec) {
+ return amount.round(prec);
+}
+amount_t py_round_2(amount_t& amount) {
+ return amount.round();
+}
+
struct commodity_updater_wrap : public commodity_base_t::updater_t
{
PyObject * self;
@@ -148,6 +155,7 @@ void export_amount()
.def("strip_annotations", &amount_t::strip_annotations)
.def("clear_commodity", &amount_t::clear_commodity)
+ .def("to_string", &amount_t::to_string)
.def("quantity_string", &amount_t::quantity_string)
.def("abs", &amount_t::abs)
@@ -159,10 +167,15 @@ void export_amount()
.def("parse", py_parse_1)
.def("parse", py_parse_2)
.def("price", &amount_t::price)
+ .def("realzero", &amount_t::realzero)
.def("reduce", &amount_t::reduce)
.def("reduced", &amount_t::reduced)
+ .def("round", py_round_1)
+ .def("round", py_round_2)
.def("sign", &amount_t::sign)
+ .def("unround", &amount_t::unround)
.def("value", &amount_t::value)
+ .def("zero", &amount_t::zero)
.def("valid", &amount_t::valid)
;