diff options
-rw-r--r-- | src/annotate.cc | 7 | ||||
-rw-r--r-- | src/pool.cc | 1 | ||||
-rw-r--r-- | src/pool.h | 1 | ||||
-rw-r--r-- | src/post.h | 3 | ||||
-rw-r--r-- | src/py_commodity.cc | 7 | ||||
-rw-r--r-- | src/textual.cc | 11 | ||||
-rw-r--r-- | src/xact.cc | 2 |
7 files changed, 24 insertions, 8 deletions
diff --git a/src/annotate.cc b/src/annotate.cc index d2e4976e..1140bf0a 100644 --- a/src/annotate.cc +++ b/src/annotate.cc @@ -122,7 +122,12 @@ void annotation_t::parse(std::istream& in) else if (c == '(') { in.get(c); c = static_cast<char>(in.peek()); - if (c == '(') { + if (c == '@') { + in.clear(); + in.seekg(pos, std::ios::beg); + break; + } + else if (c == '(') { if (value_expr) throw_(amount_error, _("Commodity specifies more than one valuation expresion")); diff --git a/src/pool.cc b/src/pool.cc index fd661fe1..1dd91e99 100644 --- a/src/pool.cc +++ b/src/pool.cc @@ -246,6 +246,7 @@ cost_breakdown_t commodity_pool_t::exchange(const amount_t& amount, const amount_t& cost, const bool is_per_unit, + const bool add_price, const optional<datetime_t>& moment, const optional<string>& tag) { @@ -119,6 +119,7 @@ public: cost_breakdown_t exchange(const amount_t& amount, const amount_t& cost, const bool is_per_unit = false, + const bool add_price = true, const optional<datetime_t>& moment = none, const optional<string>& tag = none); @@ -58,7 +58,8 @@ public: #define POST_COST_CALCULATED 0x0080 // posting's cost was calculated #define POST_COST_IN_FULL 0x0100 // cost specified using @@ #define POST_COST_FIXATED 0x0200 // cost is fixed using = indicator -#define POST_ANONYMIZED 0x0400 // a temporary, anonymous posting +#define POST_COST_VIRTUAL 0x0400 // cost is virtualized: (@) +#define POST_ANONYMIZED 0x0800 // a temporary, anonymous posting xact_t * xact; // only set for posts of regular xacts account_t * account; diff --git a/src/py_commodity.cc b/src/py_commodity.cc index 25e5b918..c75b5e64 100644 --- a/src/py_commodity.cc +++ b/src/py_commodity.cc @@ -96,14 +96,15 @@ namespace { pool.exchange(commodity, per_unit_cost, moment); } - cost_breakdown_t py_exchange_5(commodity_pool_t& pool, + cost_breakdown_t py_exchange_7(commodity_pool_t& pool, const amount_t& amount, const amount_t& cost, const bool is_per_unit, + const bool add_prices, const boost::optional<datetime_t>& moment, const boost::optional<string>& tag) { - return pool.exchange(amount, cost, is_per_unit, moment, tag); + return pool.exchange(amount, cost, is_per_unit, add_prices, moment, tag); } commodity_t * py_pool_getitem(commodity_pool_t& pool, const string& symbol) @@ -280,7 +281,7 @@ void export_commodity() .def("exchange", py_exchange_2, with_custodian_and_ward<1, 2>()) .def("exchange", py_exchange_3, with_custodian_and_ward<1, 2>()) - .def("exchange", py_exchange_5) + .def("exchange", py_exchange_7) .def("parse_price_directive", &commodity_pool_t::parse_price_directive) .def("parse_price_expression", &commodity_pool_t::parse_price_expression, diff --git a/src/textual.cc b/src/textual.cc index 66972fb3..a8cb844b 100644 --- a/src/textual.cc +++ b/src/textual.cc @@ -1447,12 +1447,16 @@ post_t * instance_t::parse_post(char * line, // Parse the optional cost (@ PER-UNIT-COST, @@ TOTAL-COST) - if (*next == '@') { + if (*next == '@' || (*next == '(' && *(next + 1) == '@')) { DEBUG("textual.parse", "line " << context.linenum << ": " << "Found a price indicator"); - bool per_unit = true; + if (*next == '(') { + post->add_flags(POST_COST_VIRTUAL); + ++next; + } + bool per_unit = true; if (*++next == '@') { per_unit = false; post->add_flags(POST_COST_IN_FULL); @@ -1460,6 +1464,9 @@ post_t * instance_t::parse_post(char * line, << "And it's for a total price"); } + if (post->has_flags(POST_COST_VIRTUAL) && *(next + 1) == ')') + ++next; + beg = static_cast<std::streamsize>(++next - line); p = skip_ws(next); diff --git a/src/xact.cc b/src/xact.cc index 4e43e680..4e8e56fa 100644 --- a/src/xact.cc +++ b/src/xact.cc @@ -269,7 +269,7 @@ bool xact_base_t::finalize() cost_breakdown_t breakdown = commodity_pool_t::current_pool->exchange - (post->amount, *post->cost, false, + (post->amount, *post->cost, false, ! post->has_flags(POST_COST_VIRTUAL), datetime_t(date(), time_duration(0, 0, 0, 0))); if (post->amount.has_annotation() && post->amount.annotation().price) { |