Further improvements to handling temporaries
This commit is contained in:
parent
cc532c31aa
commit
aa45d2d38c
6 changed files with 10 additions and 31 deletions
|
|
@ -686,6 +686,7 @@ void transfer_details::operator()(post_t& post)
|
||||||
xact.payee = expr.calc(bound_scope).to_string();
|
xact.payee = expr.calc(bound_scope).to_string();
|
||||||
break;
|
break;
|
||||||
case SET_ACCOUNT:
|
case SET_ACCOUNT:
|
||||||
|
temp.account->remove_post(&temp);
|
||||||
temp.account = master->find_account(expr.calc(bound_scope).to_string());
|
temp.account = master->find_account(expr.calc(bound_scope).to_string());
|
||||||
temp.account->add_post(&temp);
|
temp.account->add_post(&temp);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -108,24 +108,19 @@ void posts_commodities_iterator::reset(journal_t& journal)
|
||||||
if (i != xacts_by_commodity.end()) {
|
if (i != xacts_by_commodity.end()) {
|
||||||
xact = (*i).second;
|
xact = (*i).second;
|
||||||
} else {
|
} else {
|
||||||
xact_temps.push_back(new xact_t);
|
xact = &temps.create_xact();
|
||||||
xact = xact_temps.back();
|
xact_temps.push_back(xact);
|
||||||
xact->payee = symbol;
|
xact->payee = symbol;
|
||||||
xact->_date = hpair.first.date();
|
xact->_date = hpair.first.date();
|
||||||
xacts_by_commodity.insert
|
xacts_by_commodity.insert
|
||||||
(std::pair<string, xact_t *>(symbol, xact));
|
(std::pair<string, xact_t *>(symbol, xact));
|
||||||
}
|
}
|
||||||
|
|
||||||
post_temps.push_back(post_t(account));
|
post_t& temp = temps.create_post(*xact, account);
|
||||||
post_t& temp = post_temps.back();
|
|
||||||
temp._date = hpair.first.date();
|
temp._date = hpair.first.date();
|
||||||
temp.xact = xact;
|
|
||||||
temp.amount = hpair.second;
|
temp.amount = hpair.second;
|
||||||
temp.set_flags(ITEM_GENERATED | ITEM_TEMP);
|
|
||||||
|
|
||||||
temp.xdata().datetime = hpair.first;
|
temp.xdata().datetime = hpair.first;
|
||||||
|
|
||||||
xact->add_post(&temp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@
|
||||||
#include "xact.h"
|
#include "xact.h"
|
||||||
#include "post.h"
|
#include "post.h"
|
||||||
#include "account.h"
|
#include "account.h"
|
||||||
|
#include "temps.h"
|
||||||
|
|
||||||
namespace ledger {
|
namespace ledger {
|
||||||
|
|
||||||
|
|
@ -172,9 +173,7 @@ protected:
|
||||||
journal_posts_iterator journal_posts;
|
journal_posts_iterator journal_posts;
|
||||||
xacts_iterator xacts;
|
xacts_iterator xacts;
|
||||||
xact_posts_iterator posts;
|
xact_posts_iterator posts;
|
||||||
|
temporaries_t temps;
|
||||||
std::list<post_t> post_temps;
|
|
||||||
std::list<account_t> acct_temps;
|
|
||||||
xacts_list xact_temps;
|
xacts_list xact_temps;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -187,8 +186,6 @@ public:
|
||||||
}
|
}
|
||||||
virtual ~posts_commodities_iterator() throw() {
|
virtual ~posts_commodities_iterator() throw() {
|
||||||
TRACE_DTOR(posts_commodities_iterator);
|
TRACE_DTOR(posts_commodities_iterator);
|
||||||
foreach (xact_t * xact, xact_temps)
|
|
||||||
checked_delete(xact);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset(journal_t& journal);
|
void reset(journal_t& journal);
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,9 @@
|
||||||
|
|
||||||
#include <system.hh>
|
#include <system.hh>
|
||||||
|
|
||||||
|
#include "xact.h"
|
||||||
|
#include "post.h"
|
||||||
|
#include "account.h"
|
||||||
#include "temps.h"
|
#include "temps.h"
|
||||||
|
|
||||||
namespace ledger {
|
namespace ledger {
|
||||||
|
|
|
||||||
|
|
@ -46,10 +46,6 @@
|
||||||
#ifndef _TEMPS_H
|
#ifndef _TEMPS_H
|
||||||
#define _TEMPS_H
|
#define _TEMPS_H
|
||||||
|
|
||||||
#include "xact.h"
|
|
||||||
#include "post.h"
|
|
||||||
#include "account.h"
|
|
||||||
|
|
||||||
namespace ledger {
|
namespace ledger {
|
||||||
|
|
||||||
class temporaries_t
|
class temporaries_t
|
||||||
|
|
|
||||||
|
|
@ -1014,21 +1014,8 @@ post_t * instance_t::parse_post(char * line,
|
||||||
if (! diff.is_zero()) {
|
if (! diff.is_zero()) {
|
||||||
if (! post->amount.is_null()) {
|
if (! post->amount.is_null()) {
|
||||||
diff -= post->amount;
|
diff -= post->amount;
|
||||||
if (! diff.is_zero()) {
|
if (! diff.is_zero())
|
||||||
#if 1
|
|
||||||
throw_(parse_error, _("Balance assertion off by %1") << diff);
|
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 {
|
} else {
|
||||||
post->amount = diff;
|
post->amount = diff;
|
||||||
DEBUG("textual.parse", "line " << linenum << ": "
|
DEBUG("textual.parse", "line " << linenum << ": "
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue