summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPascal Fleury <pascal@telefleuries.com>2018-07-17 23:36:50 +0200
committerPascal Fleury <pascal@telefleuries.com>2018-07-17 23:36:50 +0200
commit135a9e52ad0d753477aa4723f1ed23c16e8a3f32 (patch)
treee144d8e442ab25945c00cf10bcc6a4a7ea6ff283 /src
parent3186ff514a19851266b5be63773a54086e2ae2d9 (diff)
downloadfork-ledger-135a9e52ad0d753477aa4723f1ed23c16e8a3f32.tar.gz
fork-ledger-135a9e52ad0d753477aa4723f1ed23c16e8a3f32.tar.bz2
fork-ledger-135a9e52ad0d753477aa4723f1ed23c16e8a3f32.zip
fix regression of test 1147_a
Diffstat (limited to 'src')
-rw-r--r--src/textual.cc35
1 files changed, 18 insertions, 17 deletions
diff --git a/src/textual.cc b/src/textual.cc
index 5d7706ec..246db751 100644
--- a/src/textual.cc
+++ b/src/textual.cc
@@ -1652,8 +1652,8 @@ post_t * instance_t::parse_post(char * line,
DEBUG("post.assign", "line " << context.linenum << ": "
<< "account balance = " << account_total);
- DEBUG("post.assign",
- "line " << context.linenum << ": " << "post amount = " << amt);
+ DEBUG("post.assign", "line " << context.linenum << ": "
+ << "post amount = " << amt << " (is_zero = " << amt.is_zero() << ")");
balance_t diff = amt;
@@ -1688,6 +1688,21 @@ post_t * instance_t::parse_post(char * line,
}
}
+ // If amt has a commodity, restrict balancing to that. Otherwise, it's the blanket '0' and
+ // check that all of them are zero.
+ if (amt.has_commodity()) {
+ DEBUG("textual.parse", "line " << context.linenum << ": "
+ << "Finding commodity " << amt.commodity() << " (" << amt << ") in balance " << diff);
+ optional<amount_t> wanted_commodity = diff.commodity_amount(amt.commodity());
+ if (!wanted_commodity) {
+ diff = amt - amt; // this is '0' with the correct commodity.
+ } else {
+ diff = *wanted_commodity;
+ }
+ DEBUG("textual.parse", "line " << context.linenum << ": "
+ << "Diff is now " << diff);
+ }
+
if (post->amount.is_null()) {
// balance assignment
if (! diff.is_zero()) {
@@ -1700,26 +1715,12 @@ post_t * instance_t::parse_post(char * line,
} else {
// balance assertion
diff -= post->amount;
- // If amt has a commodity, restrict balancing to that. Otherwise, it's the blanket '0' and
- // check that all of them are zero.
- if (amt.has_commodity()) {
- DEBUG("textual.parse", "line " << context.linenum << ": "
- << "Finding commodity " << amt.commodity() << " (" << amt << ") in balance " << diff);
- optional<amount_t> wanted_commodity = diff.commodity_amount(amt.commodity());
- if (!wanted_commodity) {
- diff = amt - amt; // this is '0' with the correct commodity.
- } else {
- diff = *wanted_commodity;
- }
- DEBUG("textual.parse", "line " << context.linenum << ": "
- << "Diff is now " << diff);
- }
if (! no_assertions && ! diff.is_zero()) {
balance_t tot = -diff + amt;
DEBUG("textual.parse", "Balance assertion: off by " << diff << " (expected to see " << tot << ")");
throw_(parse_error,
_f("Balance assertion off by %1% (expected to see %2%)")
- % diff % tot);
+ % diff.to_string() % tot.to_string());
}
}