summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/post.cc11
-rw-r--r--src/post.h2
-rw-r--r--src/textual.cc14
-rw-r--r--src/xact.cc23
-rw-r--r--src/xact.h2
5 files changed, 21 insertions, 31 deletions
diff --git a/src/post.cc b/src/post.cc
index 8293bfe4..5c0d98e7 100644
--- a/src/post.cc
+++ b/src/post.cc
@@ -102,17 +102,6 @@ optional<date_t> post_t::effective_date() const
return date;
}
-item_t::state_t post_t::state() const
-{
- if (xact) {
- state_t xact_state = xact->state();
- if ((_state == UNCLEARED && xact_state != UNCLEARED) ||
- (_state == PENDING && xact_state == CLEARED))
- return xact_state;
- }
- return _state;
-}
-
namespace {
value_t get_this(post_t& post) {
return value_t(static_cast<scope_t *>(&post));
diff --git a/src/post.h b/src/post.h
index 4c20fb37..4455559a 100644
--- a/src/post.h
+++ b/src/post.h
@@ -118,8 +118,6 @@ public:
virtual date_t date() const;
virtual optional<date_t> effective_date() const;
- virtual state_t state() const;
-
bool must_balance() const {
return ! has_flags(POST_VIRTUAL) || has_flags(POST_MUST_BALANCE);
}
diff --git a/src/textual.cc b/src/textual.cc
index c971006f..bc221671 100644
--- a/src/textual.cc
+++ b/src/textual.cc
@@ -1220,6 +1220,20 @@ xact_t * instance_t::parse_xact(char * line,
}
}
+ if (xact->_state == item_t::UNCLEARED) {
+ item_t::state_t result = item_t::CLEARED;
+
+ foreach (post_t * post, xact->posts) {
+ if (post->_state == item_t::UNCLEARED) {
+ result = item_t::UNCLEARED;
+ break;
+ }
+ else if (post->_state == item_t::PENDING) {
+ result = item_t::PENDING;
+ }
+ }
+ }
+
xact->end_pos = curr_pos;
xact->end_line = linenum;
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 {
diff --git a/src/xact.h b/src/xact.h
index 33127911..8d9b7d0f 100644
--- a/src/xact.h
+++ b/src/xact.h
@@ -72,8 +72,6 @@ public:
virtual ~xact_base_t();
- virtual state_t state() const;
-
virtual void add_post(post_t * post);
virtual bool remove_post(post_t * post);