From 1bbb6933af6c3052297ca647e31980b4dcce6960 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sat, 20 Sep 2008 13:48:36 -0400 Subject: Cleaned up the way that commodity pricing is handled. --- src/commodity.h | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'src/commodity.h') 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 value(const optional& moment = none); - static amount_t exchange(const amount_t& amount, - amount_t& final_cost, // out - amount_t& basis_cost, // out - const optional& total_cost, - const optional& per_unit_cost = none, - const optional& moment = none, - const optional& 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& moment = none, + const optional& tag = none); static void parse_symbol(std::istream& in, string& symbol); static void parse_symbol(char *& p, string& symbol); -- cgit v1.2.3