summaryrefslogtreecommitdiff
path: root/balance.cc
diff options
context:
space:
mode:
Diffstat (limited to 'balance.cc')
-rw-r--r--balance.cc105
1 files changed, 67 insertions, 38 deletions
diff --git a/balance.cc b/balance.cc
index 69066f97..14ce1615 100644
--- a/balance.cc
+++ b/balance.cc
@@ -1,5 +1,4 @@
#include "balance.h"
-#include "ledger.h"
#include <deque>
@@ -84,40 +83,6 @@ void balance_t::write(std::ostream& out,
}
}
-balance_pair_t::balance_pair_t(const transaction_t& xact)
- : quantity(xact.amount), cost(NULL)
-{
- DEBUG_PRINT("ledger.memory.ctors", "ctor balance_pair_t");
- if (xact.cost)
- cost = new balance_t(*xact.cost);
-}
-
-balance_pair_t& balance_pair_t::operator+=(const transaction_t& xact)
-{
- if (xact.cost && ! cost)
- cost = new balance_t(quantity);
-
- quantity += xact.amount;
-
- if (cost)
- *cost += xact.cost ? *xact.cost : xact.amount;
-
- return *this;
-}
-
-balance_pair_t& balance_pair_t::operator-=(const transaction_t& xact)
-{
- if (xact.cost && ! cost)
- cost = new balance_t(quantity);
-
- quantity -= xact.amount;
-
- if (cost)
- *cost -= xact.cost ? *xact.cost : xact.amount;
-
- return *this;
-}
-
} // namespace ledger
#ifdef USE_BOOST_PYTHON
@@ -169,10 +134,11 @@ void export_balance()
.def(! self)
.def(abs(self))
- //.def(str(self))
+#if 0
+ .def(str(self))
+#endif
- .def("negate", &balance_t::negate,
- return_value_policy<reference_existing_object>())
+ .def("negate", &balance_t::negate)
.def("amount", &balance_t::amount)
.def("value", &balance_t::value)
.def("write", &balance_t::write)
@@ -180,6 +146,69 @@ void export_balance()
;
class_< balance_pair_t > ("BalancePair")
+ .def(init<balance_pair_t>())
+ .def(init<balance_t>())
+ .def(init<amount_t>())
+ .def(init<int>())
+ .def(init<unsigned int>())
+ .def(init<double>())
+
+ .def(self += self)
+ .def(self += other<balance_t>())
+ .def(self += other<amount_t>())
+ .def(self + self)
+ .def(self + other<balance_t>())
+ .def(self + other<amount_t>())
+ .def(self -= self)
+ .def(self -= other<balance_t>())
+ .def(self -= other<amount_t>())
+ .def(self - self)
+ .def(self - other<balance_t>())
+ .def(self - other<amount_t>())
+ .def(self *= self)
+ .def(self *= other<balance_t>())
+ .def(self *= other<amount_t>())
+ .def(self * self)
+ .def(self * other<balance_t>())
+ .def(self * other<amount_t>())
+ .def(self /= self)
+ .def(self /= other<balance_t>())
+ .def(self /= other<amount_t>())
+ .def(self / self)
+ .def(self / other<balance_t>())
+ .def(self / other<amount_t>())
+ .def(- self)
+
+ .def(self < self)
+ .def(self < other<balance_t>())
+ .def(self < other<amount_t>())
+ .def(self <= self)
+ .def(self <= other<balance_t>())
+ .def(self <= other<amount_t>())
+ .def(self > self)
+ .def(self > other<balance_t>())
+ .def(self > other<amount_t>())
+ .def(self >= self)
+ .def(self >= other<balance_t>())
+ .def(self >= other<amount_t>())
+ .def(self == self)
+ .def(self == other<balance_t>())
+ .def(self == other<amount_t>())
+ .def(self != self)
+ .def(self != other<balance_t>())
+ .def(self != other<amount_t>())
+ .def(! self)
+
+ .def(abs(self))
+#if 0
+ .def(str(self))
+#endif
+
+ .def("negate", &balance_pair_t::negate)
+ .def("amount", &balance_pair_t::amount)
+ .def("value", &balance_pair_t::value)
+ .def("write", &balance_pair_t::write)
+ .def("valid", &balance_pair_t::valid)
;
}