diff options
author | John Wiegley <johnw@newartisans.com> | 2007-04-17 02:56:53 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-04-13 03:35:35 -0400 |
commit | e43f54f24936a0fd93ae9dba8a163982ede0e1ab (patch) | |
tree | 49524c2bccb740f362c25eebce6c7808e8a74222 /amount.cc | |
parent | e7f9486f6e524947a29b8e7d20bc834a240a3b23 (diff) | |
download | fork-ledger-e43f54f24936a0fd93ae9dba8a163982ede0e1ab.tar.gz fork-ledger-e43f54f24936a0fd93ae9dba8a163982ede0e1ab.tar.bz2 fork-ledger-e43f54f24936a0fd93ae9dba8a163982ede0e1ab.zip |
Started adding commodity tests
Diffstat (limited to 'amount.cc')
-rw-r--r-- | amount.cc | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -1123,7 +1123,7 @@ static void parse_commodity(std::istream& in, std::string& symbol) symbol = buf; } -void parse_annotations(std::istream& in, amount_t& price, +bool parse_annotations(std::istream& in, amount_t& price, datetime_t& date, std::string& tag) { do { @@ -1200,6 +1200,7 @@ void amount_t::parse(std::istream& in, unsigned char flags) std::string quant; amount_t tprice; datetime_t tdate; + bool had_date = false; std::string tag; unsigned int comm_flags = COMMODITY_STYLE_DEFAULTS; bool negative = false; @@ -1225,7 +1226,7 @@ void amount_t::parse(std::istream& in, unsigned char flags) comm_flags |= COMMODITY_STYLE_SUFFIXED; if (! in.eof() && ((n = in.peek()) != '\n')) - parse_annotations(in, tprice, tdate, tag); + had_date = parse_annotations(in, tprice, tdate, tag); } } else { parse_commodity(in, symbol); @@ -1237,7 +1238,7 @@ void amount_t::parse(std::istream& in, unsigned char flags) parse_quantity(in, quant); if (! quant.empty() && ! in.eof() && ((n = in.peek()) != '\n')) - parse_annotations(in, tprice, tdate, tag); + had_date = parse_annotations(in, tprice, tdate, tag); } } @@ -1261,7 +1262,7 @@ void amount_t::parse(std::istream& in, unsigned char flags) } assert(commodity_); - if (! tprice.realzero() || tdate || ! tag.empty()) + if (! tprice.realzero() || had_date || ! tag.empty()) commodity_ = annotated_commodity_t::find_or_create(*commodity_, tprice, tdate, tag); } |