summaryrefslogtreecommitdiff
path: root/src/commodity.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2008-09-20 13:48:36 -0400
committerJohn Wiegley <johnw@newartisans.com>2008-09-20 13:48:36 -0400
commit1bbb6933af6c3052297ca647e31980b4dcce6960 (patch)
treeda2e9d53094dd6b43d64aa39ef58d9d283fb3b1e /src/commodity.h
parent0e95974360464212de55803c4fc6c671502dbf99 (diff)
downloadfork-ledger-1bbb6933af6c3052297ca647e31980b4dcce6960.tar.gz
fork-ledger-1bbb6933af6c3052297ca647e31980b4dcce6960.tar.bz2
fork-ledger-1bbb6933af6c3052297ca647e31980b4dcce6960.zip
Cleaned up the way that commodity pricing is handled.
Diffstat (limited to 'src/commodity.h')
-rw-r--r--src/commodity.h26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/commodity.h b/src/commodity.h
index 27827c1a..af90f6b8 100644
--- a/src/commodity.h
+++ b/src/commodity.h
@@ -192,18 +192,26 @@ public:
return base->history;
}
- void add_price(const datetime_t& date, const amount_t& price);
- bool remove_price(const datetime_t& date);
+ void add_price(const datetime_t& date, const amount_t& price);
+ bool remove_price(const datetime_t& date);
optional<amount_t> value(const optional<datetime_t>& moment = none);
- static amount_t exchange(const amount_t& amount,
- amount_t& final_cost, // out
- amount_t& basis_cost, // out
- const optional<amount_t>& total_cost,
- const optional<amount_t>& per_unit_cost = none,
- const optional<datetime_t>& moment = none,
- const optional<string>& tag = none);
+ struct cost_breakdown_t {
+ amount_t amount;
+ amount_t final_cost;
+ amount_t basis_cost;
+ };
+
+ static void exchange(commodity_t& commodity,
+ const amount_t& per_unit_cost,
+ const datetime_t& moment);
+
+ static cost_breakdown_t exchange(const amount_t& amount,
+ const amount_t& cost,
+ const bool is_per_unit = false,
+ const optional<datetime_t>& moment = none,
+ const optional<string>& tag = none);
static void parse_symbol(std::istream& in, string& symbol);
static void parse_symbol(char *& p, string& symbol);