summaryrefslogtreecommitdiff
path: root/src/annotate.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2012-03-10 02:27:33 -0600
committerJohn Wiegley <johnw@newartisans.com>2012-03-10 02:27:33 -0600
commit080c1d9a2d0f3013a4d26879a3e98cfa62ef3e48 (patch)
treeb95c15c1dc13925bcc4b3c11d98c06c50bba1bcc /src/annotate.cc
parent50f202c4e8faecf7398fb21ba5b31768ec46c826 (diff)
downloadfork-ledger-080c1d9a2d0f3013a4d26879a3e98cfa62ef3e48.tar.gz
fork-ledger-080c1d9a2d0f3013a4d26879a3e98cfa62ef3e48.tar.bz2
fork-ledger-080c1d9a2d0f3013a4d26879a3e98cfa62ef3e48.zip
Added syntactic sugar for lot pricing: {{$500.00}}
Diffstat (limited to 'src/annotate.cc')
-rw-r--r--src/annotate.cc20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/annotate.cc b/src/annotate.cc
index 1140bf0a..d2c7f983 100644
--- a/src/annotate.cc
+++ b/src/annotate.cc
@@ -88,6 +88,12 @@ void annotation_t::parse(std::istream& in)
throw_(amount_error, _("Commodity specifies more than one price"));
in.get(c);
+ c = static_cast<char>(in.peek());
+ if (c == '{') {
+ in.get(c);
+ add_flags(ANNOTATION_PRICE_NOT_PER_UNIT);
+ }
+
c = peek_next_nonws(in);
if (c == '=') {
in.get(c);
@@ -95,10 +101,18 @@ void annotation_t::parse(std::istream& in)
}
READ_INTO(in, buf, 255, c, c != '}');
- if (c == '}')
+ if (c == '}') {
in.get(c);
- else
- throw_(amount_error, _("Commodity price lacks closing brace"));
+ if (has_flags(ANNOTATION_PRICE_NOT_PER_UNIT)) {
+ c = static_cast<char>(in.peek());
+ if (c != '}')
+ throw_(amount_error, _("Commodity lot price lacks double closing brace"));
+ else
+ in.get(c);
+ }
+ } else {
+ throw_(amount_error, _("Commodity lot price lacks closing brace"));
+ }
amount_t temp;
temp.parse(buf, PARSE_NO_MIGRATE);