Fix to xact_t::valid()

This commit is contained in:
John Wiegley 2009-11-01 00:20:23 -04:00
parent 3497076e04
commit c5c2027624
3 changed files with 7 additions and 13 deletions

View file

@ -524,6 +524,7 @@ void instance_t::automated_xact_directive(char * line)
journal.auto_xacts.push_back(ae.get()); journal.auto_xacts.push_back(ae.get());
ae->journal = &journal;
ae->pos = position_t(); ae->pos = position_t();
ae->pos->pathname = pathname; ae->pos->pathname = pathname;
ae->pos->beg_pos = pos; ae->pos->beg_pos = pos;
@ -559,6 +560,7 @@ void instance_t::period_xact_directive(char * line)
if (parse_posts(account_stack.front(), *pe.get())) { if (parse_posts(account_stack.front(), *pe.get())) {
reveal_context = true; reveal_context = true;
pe->journal = &journal;
if (pe->finalize()) { if (pe->finalize()) {
extend_xact_base(&journal, *pe.get(), true); extend_xact_base(&journal, *pe.get(), true);
@ -574,6 +576,7 @@ void instance_t::period_xact_directive(char * line)
pe.release(); pe.release();
} else { } else {
pe->journal = NULL;
throw parse_error(_("Period transaction failed to balance")); throw parse_error(_("Period transaction failed to balance"));
} }
} }

View file

@ -457,7 +457,7 @@ bool xact_t::valid() const
DEBUG("ledger.validate", "xact_t: ! _date"); DEBUG("ledger.validate", "xact_t: ! _date");
return false; return false;
} }
if (! journal) { if (! has_flags(ITEM_GENERATED | ITEM_TEMP) && ! journal) {
DEBUG("ledger.validate", "xact_t: ! journal"); DEBUG("ledger.validate", "xact_t: ! journal");
return false; return false;
} }

View file

@ -79,7 +79,9 @@ public:
virtual bool remove_post(post_t * post); virtual bool remove_post(post_t * post);
virtual bool finalize(); virtual bool finalize();
virtual bool valid() const = 0; virtual bool valid() const {
return true;
}
#if defined(HAVE_BOOST_SERIALIZATION) #if defined(HAVE_BOOST_SERIALIZATION)
private: private:
@ -179,9 +181,6 @@ public:
} }
virtual void extend_xact(xact_base_t& xact, bool post); virtual void extend_xact(xact_base_t& xact, bool post);
virtual bool valid() const {
return true;
}
#if defined(HAVE_BOOST_SERIALIZATION) #if defined(HAVE_BOOST_SERIALIZATION)
private: private:
@ -262,14 +261,6 @@ class period_xact_t : public xact_base_t
TRACE_DTOR(period_xact_t); TRACE_DTOR(period_xact_t);
} }
virtual bool valid() const {
if (! period.is_valid()) {
DEBUG("ledger.validate", "period_xact_t: ! period.is_valid()");
return false;
}
return true;
}
#if defined(HAVE_BOOST_SERIALIZATION) #if defined(HAVE_BOOST_SERIALIZATION)
private: private:
/** Serialization. */ /** Serialization. */