summaryrefslogtreecommitdiff
path: root/value.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2006-02-27 23:52:31 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 02:41:27 -0400
commit7901598f1d1e419e19c860e81749805371298030 (patch)
treef3b4b42ad4217cd5a59eafb8cb8ffacea83b60ca /value.cc
parent4507573d4fbc4ece6a4bb832b2e1fffae0885db8 (diff)
downloadfork-ledger-7901598f1d1e419e19c860e81749805371298030.tar.gz
fork-ledger-7901598f1d1e419e19c860e81749805371298030.tar.bz2
fork-ledger-7901598f1d1e419e19c860e81749805371298030.zip
Checked in all major updates.
Diffstat (limited to 'value.cc')
-rw-r--r--value.cc32
1 files changed, 32 insertions, 0 deletions
diff --git a/value.cc b/value.cc
index 2af9ecf6..1680ebd7 100644
--- a/value.cc
+++ b/value.cc
@@ -747,6 +747,38 @@ value_t value_t::cost() const
return value_t();
}
+value_t value_t::factor_price() const
+{
+ switch (type) {
+ case BOOLEAN:
+ case INTEGER:
+ return *this;
+
+ case AMOUNT: {
+ commodity_t& comm = ((amount_t *) data)->commodity();
+ if (comm.price != NULL)
+ return value_t(*comm.price * *((amount_t *) data));
+ return *this;
+ }
+
+ case BALANCE:
+ return ((balance_t *) data)->factor_price();
+
+ case BALANCE_PAIR: {
+ balance_pair_t temp(((balance_pair_t *) data)->quantity.factor_price());
+ if (((balance_pair_t *) data)->cost)
+ temp.cost = new balance_t(((balance_pair_t *) data)->cost);
+ return temp;
+ }
+
+ default:
+ assert(0);
+ break;
+ }
+ assert(0);
+ return value_t();
+}
+
value_t& value_t::add(const amount_t& amount, const amount_t * cost)
{
switch (type) {