summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMitchell Kember <mk12360@gmail.com>2016-10-04 21:34:09 -0700
committerMitchell Kember <mk12360@gmail.com>2016-10-07 20:25:20 -0700
commitd541cceaf7d4e77c239849679e3ae7a449ae8c8b (patch)
treec6cc326dd21ac5648fd865f118add86ae9a251ca /src
parente27ae09e2285482f2c95f1ec53d8629f4072f081 (diff)
downloadfork-ledger-d541cceaf7d4e77c239849679e3ae7a449ae8c8b.tar.gz
fork-ledger-d541cceaf7d4e77c239849679e3ae7a449ae8c8b.tar.bz2
fork-ledger-d541cceaf7d4e77c239849679e3ae7a449ae8c8b.zip
Fix bug 1187: Allow balance assertions with multiple posts to same account
Diffstat (limited to 'src')
-rw-r--r--src/textual.cc13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/textual.cc b/src/textual.cc
index 7ef5c7eb..456ff8af 100644
--- a/src/textual.cc
+++ b/src/textual.cc
@@ -1655,7 +1655,8 @@ post_t * instance_t::parse_post(char * line,
switch (account_total.type()) {
case value_t::AMOUNT:
- diff -= account_total.as_amount();
+ if (account_total.as_amount().commodity_ptr() == diff.commodity_ptr())
+ diff -= account_total.as_amount();
break;
case value_t::BALANCE:
@@ -1673,6 +1674,16 @@ post_t * instance_t::parse_post(char * line,
DEBUG("textual.parse", "line " << context.linenum << ": "
<< "POST assign: diff = " << diff);
+ // Subtract amounts from previous posts to this account in the xact.
+ for (post_t* p : xact->posts) {
+ if (p->account == post->account &&
+ p->amount.commodity_ptr() == diff.commodity_ptr()) {
+ diff -= p->amount;
+ DEBUG("textual.parse", "line " << context.linenum << ": "
+ << "Subtract " << p->amount << ", diff = " << diff);
+ }
+ }
+
if (post->amount.is_null()) {
// balance assignment
if (! diff.is_zero()) {