summaryrefslogtreecommitdiff
path: root/src/commodity.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2012-03-06 03:18:10 -0600
committerJohn Wiegley <johnw@newartisans.com>2012-03-06 03:24:06 -0600
commit97d68ebc8cf2bf88feffaedd6873934dc785c411 (patch)
treeb19e73eb8860dda1bbf8358141ddf1afc2060b50 /src/commodity.h
parenteb3591f898e194be0cb6c15107e8e41e9dd67206 (diff)
downloadfork-ledger-97d68ebc8cf2bf88feffaedd6873934dc785c411.tar.gz
fork-ledger-97d68ebc8cf2bf88feffaedd6873934dc785c411.tar.bz2
fork-ledger-97d68ebc8cf2bf88feffaedd6873934dc785c411.zip
Added "value" sub-directive for commodity directive
Diffstat (limited to 'src/commodity.h')
-rw-r--r--src/commodity.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/commodity.h b/src/commodity.h
index 5cf9c53d..3d36e35e 100644
--- a/src/commodity.h
+++ b/src/commodity.h
@@ -47,6 +47,8 @@
#ifndef _COMMODITY_H
#define _COMMODITY_H
+#include "expr.h"
+
namespace ledger {
struct keep_details_t;
@@ -113,6 +115,7 @@ protected:
optional<string> note;
optional<amount_t> smaller;
optional<amount_t> larger;
+ optional<expr_t> value_expr;
typedef std::pair<optional<datetime_t>,
optional<datetime_t> > optional_time_pair_t;
@@ -259,6 +262,13 @@ public:
base->larger = arg;
}
+ virtual optional<expr_t> value_expr() const {
+ return base->value_expr;
+ }
+ void set_value_expr(const optional<expr_t>& expr = none) {
+ base->value_expr = expr;
+ }
+
void add_price(const datetime_t& date, const amount_t& price,
const bool reflexive = true);
void remove_price(const datetime_t& date, commodity_t& commodity);
@@ -268,6 +278,10 @@ public:
const optional<datetime_t>& _oldest = none);
optional<price_point_t>
+ find_price_from_expr(expr_t& expr, const optional<commodity_t&>& commodity,
+ const datetime_t& moment) const;
+
+ optional<price_point_t>
virtual find_price(const optional<commodity_t&>& commodity = none,
const optional<datetime_t>& moment = none,
const optional<datetime_t>& oldest = none) const;