summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/filters.cc1
-rw-r--r--src/iterators.cc11
-rw-r--r--src/iterators.h7
-rw-r--r--src/temps.cc3
-rw-r--r--src/temps.h4
-rw-r--r--src/textual.cc15
6 files changed, 10 insertions, 31 deletions
diff --git a/src/filters.cc b/src/filters.cc
index 25649ad0..b5d0e168 100644
--- a/src/filters.cc
+++ b/src/filters.cc
@@ -686,6 +686,7 @@ void transfer_details::operator()(post_t& post)
xact.payee = expr.calc(bound_scope).to_string();
break;
case SET_ACCOUNT:
+ temp.account->remove_post(&temp);
temp.account = master->find_account(expr.calc(bound_scope).to_string());
temp.account->add_post(&temp);
break;
diff --git a/src/iterators.cc b/src/iterators.cc
index 020f70b0..e9560cc0 100644
--- a/src/iterators.cc
+++ b/src/iterators.cc
@@ -108,24 +108,19 @@ void posts_commodities_iterator::reset(journal_t& journal)
if (i != xacts_by_commodity.end()) {
xact = (*i).second;
} else {
- xact_temps.push_back(new xact_t);
- xact = xact_temps.back();
+ xact = &temps.create_xact();
+ xact_temps.push_back(xact);
xact->payee = symbol;
xact->_date = hpair.first.date();
xacts_by_commodity.insert
(std::pair<string, xact_t *>(symbol, xact));
}
- post_temps.push_back(post_t(account));
- post_t& temp = post_temps.back();
+ post_t& temp = temps.create_post(*xact, account);
temp._date = hpair.first.date();
- temp.xact = xact;
temp.amount = hpair.second;
- temp.set_flags(ITEM_GENERATED | ITEM_TEMP);
temp.xdata().datetime = hpair.first;
-
- xact->add_post(&temp);
}
}
}
diff --git a/src/iterators.h b/src/iterators.h
index a1563539..8aa1b451 100644
--- a/src/iterators.h
+++ b/src/iterators.h
@@ -49,6 +49,7 @@
#include "xact.h"
#include "post.h"
#include "account.h"
+#include "temps.h"
namespace ledger {
@@ -172,9 +173,7 @@ protected:
journal_posts_iterator journal_posts;
xacts_iterator xacts;
xact_posts_iterator posts;
-
- std::list<post_t> post_temps;
- std::list<account_t> acct_temps;
+ temporaries_t temps;
xacts_list xact_temps;
public:
@@ -187,8 +186,6 @@ public:
}
virtual ~posts_commodities_iterator() throw() {
TRACE_DTOR(posts_commodities_iterator);
- foreach (xact_t * xact, xact_temps)
- checked_delete(xact);
}
void reset(journal_t& journal);
diff --git a/src/temps.cc b/src/temps.cc
index a9ecc2a1..f2dee159 100644
--- a/src/temps.cc
+++ b/src/temps.cc
@@ -31,6 +31,9 @@
#include <system.hh>
+#include "xact.h"
+#include "post.h"
+#include "account.h"
#include "temps.h"
namespace ledger {
diff --git a/src/temps.h b/src/temps.h
index acd9cbd7..646f4dcd 100644
--- a/src/temps.h
+++ b/src/temps.h
@@ -46,10 +46,6 @@
#ifndef _TEMPS_H
#define _TEMPS_H
-#include "xact.h"
-#include "post.h"
-#include "account.h"
-
namespace ledger {
class temporaries_t
diff --git a/src/textual.cc b/src/textual.cc
index 26500596..4daecc79 100644
--- a/src/textual.cc
+++ b/src/textual.cc
@@ -1014,21 +1014,8 @@ post_t * instance_t::parse_post(char * line,
if (! diff.is_zero()) {
if (! post->amount.is_null()) {
diff -= post->amount;
- if (! diff.is_zero()) {
-#if 1
+ if (! diff.is_zero())
throw_(parse_error, _("Balance assertion off by %1") << diff);
-#else
- // This code, rather than issuing an error if a balance assignment
- // fails, creates a balancing transaction that causes the
- // assertion to be true.
- post_t * temp = new post_t(post->account, diff,
- ITEM_GENERATED | POST_CALCULATED);
- xact->add_post(temp);
-
- DEBUG("textual.parse", "line " << linenum << ": "
- << "Created balancing posting");
-#endif
- }
} else {
post->amount = diff;
DEBUG("textual.parse", "line " << linenum << ": "