summaryrefslogtreecommitdiff
path: root/src/textual.cc
diff options
context:
space:
mode:
authorMitchell Kember <mk12360@gmail.com>2016-03-22 21:57:56 -0700
committerMitchell Kember <mk12360@gmail.com>2016-03-22 23:09:27 -0700
commitd082b6485f371b9eae01789b245a7944535a69d2 (patch)
treeefb8982deec06497e302cd7c1849454d3c180a15 /src/textual.cc
parent16c2b8d58d98c41a8b9093116dfa34d5da71b44a (diff)
downloadfork-ledger-d082b6485f371b9eae01789b245a7944535a69d2.tar.gz
fork-ledger-d082b6485f371b9eae01789b245a7944535a69d2.tar.bz2
fork-ledger-d082b6485f371b9eae01789b245a7944535a69d2.zip
Fix Bug 1147: Check balance assertions against the amount AFTER
Diffstat (limited to 'src/textual.cc')
-rw-r--r--src/textual.cc22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/textual.cc b/src/textual.cc
index ccd87ca0..4549581b 100644
--- a/src/textual.cc
+++ b/src/textual.cc
@@ -1671,25 +1671,27 @@ post_t * instance_t::parse_post(char * line,
break;
}
- amount_t tot = amt - diff;
-
DEBUG("post.assign",
"line " << context.linenum << ": " << "diff = " << diff);
DEBUG("textual.parse", "line " << context.linenum << ": "
<< "POST assign: diff = " << diff);
- if (! diff.is_zero()) {
- if (! post->amount.is_null()) {
- diff -= post->amount;
- if (! no_assertions && ! diff.is_zero())
- throw_(parse_error,
- _f("Balance assertion off by %1% (expected to see %2%)")
- % diff % tot);
- } else {
+ if (post->amount.is_null()) {
+ // balance assignment
+ if (! diff.is_zero()) {
post->amount = diff;
DEBUG("textual.parse", "line " << context.linenum << ": "
<< "Overwrite null posting");
}
+ } else {
+ // balance assertion
+ diff -= post->amount;
+ if (! no_assertions && ! diff.is_zero()) {
+ amount_t tot = amt - diff;
+ throw_(parse_error,
+ _f("Balance assertion off by %1% (expected to see %2%)")
+ % diff % tot);
+ }
}
if (stream.eof())