summaryrefslogtreecommitdiff
path: root/src/xact.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-27 02:35:51 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-27 02:35:51 -0400
commit06365aac05bb77deb7ef2e6f82d7b6806ee77f92 (patch)
treea213e1f2fd199fe6e7f26549074920757fd17d6f /src/xact.cc
parentfbb0d2583173073e11976c7cd7e570d4829f0621 (diff)
downloadfork-ledger-06365aac05bb77deb7ef2e6f82d7b6806ee77f92.tar.gz
fork-ledger-06365aac05bb77deb7ef2e6f82d7b6806ee77f92.tar.bz2
fork-ledger-06365aac05bb77deb7ef2e6f82d7b6806ee77f92.zip
Fixed the way item state is parsed and managed
Diffstat (limited to 'src/xact.cc')
-rw-r--r--src/xact.cc23
1 files changed, 7 insertions, 16 deletions
diff --git a/src/xact.cc b/src/xact.cc
index a434da6f..52ac68a6 100644
--- a/src/xact.cc
+++ b/src/xact.cc
@@ -54,19 +54,6 @@ xact_base_t::~xact_base_t()
}
}
-item_t::state_t xact_base_t::state() const
-{
- state_t result = CLEARED;
-
- foreach (post_t * post, posts) {
- if (post->_state == UNCLEARED)
- return UNCLEARED;
- else if (post->_state == PENDING)
- result = PENDING;
- }
- return result;
-}
-
void xact_base_t::add_post(post_t * post)
{
posts.push_back(post);
@@ -160,8 +147,10 @@ bool xact_base_t::finalize()
null_post->amount = pair.second.negated();
first = false;
} else {
- add_post(new post_t(null_post->account, pair.second.negated(),
- ITEM_GENERATED));
+ post_t * p = new post_t(null_post->account, pair.second.negated(),
+ ITEM_GENERATED);
+ p->set_state(null_post->state());
+ add_post(p);
}
}
}
@@ -292,7 +281,9 @@ bool xact_base_t::finalize()
else
account = journal->find_account(_("Equity:Capital Losses"));
- add_post(new post_t(account, gain_loss.rounded(), ITEM_GENERATED));
+ post_t * p = new post_t(account, gain_loss.rounded(), ITEM_GENERATED);
+ p->set_state(post->state());
+ add_post(p);
DEBUG("xact.finalize", "added gain_loss, balance = " << balance);
}
} else {