*** no comment ***
This commit is contained in:
parent
80c472733b
commit
86a6af6974
5 changed files with 31 additions and 22 deletions
|
|
@ -835,13 +835,13 @@ std::ostream& operator<<(std::ostream& _out, const amount_t& amt)
|
||||||
std::string ender;
|
std::string ender;
|
||||||
if (i == len)
|
if (i == len)
|
||||||
ender = str;
|
ender = str;
|
||||||
else if (i < comm.precision())
|
else if (i < comm.precision)
|
||||||
ender = std::string(str, 0, comm.precision());
|
ender = std::string(str, 0, comm.precision);
|
||||||
else
|
else
|
||||||
ender = std::string(str, 0, i);
|
ender = std::string(str, 0, i);
|
||||||
|
|
||||||
if (! ender.empty()) {
|
if (! ender.empty()) {
|
||||||
out << ((comm.flags() & COMMODITY_STYLE_EUROPEAN) ? ',' : '.');
|
out << ((comm.flags & COMMODITY_STYLE_EUROPEAN) ? ',' : '.');
|
||||||
out << ender;
|
out << ender;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -167,8 +167,9 @@ entry_t * derive_new_entry(journal_t& journal,
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (! run_hooks(journal.entry_finalize_hooks, *added) ||
|
if (! run_hooks(journal.entry_finalize_hooks, *added, false) ||
|
||||||
! added->finalize())
|
! added->finalize() ||
|
||||||
|
! run_hooks(journal.entry_finalize_hooks, *added, true))
|
||||||
throw error("Failed to finalize derived entry (check commodities)");
|
throw error("Failed to finalize derived entry (check commodities)");
|
||||||
|
|
||||||
return added.release();
|
return added.release();
|
||||||
|
|
|
||||||
15
journal.cc
15
journal.cc
|
|
@ -264,7 +264,7 @@ auto_entry_t::~auto_entry_t()
|
||||||
delete predicate;
|
delete predicate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void auto_entry_t::extend_entry(entry_base_t& entry)
|
void auto_entry_t::extend_entry(entry_base_t& entry, bool post)
|
||||||
{
|
{
|
||||||
transactions_list initial_xacts(entry.transactions.begin(),
|
transactions_list initial_xacts(entry.transactions.begin(),
|
||||||
entry.transactions.end());
|
entry.transactions.end());
|
||||||
|
|
@ -277,10 +277,15 @@ void auto_entry_t::extend_entry(entry_base_t& entry)
|
||||||
t != transactions.end();
|
t != transactions.end();
|
||||||
t++) {
|
t++) {
|
||||||
amount_t amt;
|
amount_t amt;
|
||||||
if ((*t)->amount.commodity().symbol.empty())
|
if (! (*t)->amount.commodity()) {
|
||||||
|
if (! post)
|
||||||
|
continue;
|
||||||
amt = (*i)->amount * (*t)->amount;
|
amt = (*i)->amount * (*t)->amount;
|
||||||
else
|
} else {
|
||||||
|
if (post)
|
||||||
|
continue;
|
||||||
amt = (*t)->amount;
|
amt = (*t)->amount;
|
||||||
|
}
|
||||||
|
|
||||||
account_t * account = (*t)->account;
|
account_t * account = (*t)->account;
|
||||||
std::string fullname = account->fullname();
|
std::string fullname = account->fullname();
|
||||||
|
|
@ -458,7 +463,9 @@ bool journal_t::add_entry(entry_t * entry)
|
||||||
{
|
{
|
||||||
entry->journal = this;
|
entry->journal = this;
|
||||||
|
|
||||||
if (! run_hooks(entry_finalize_hooks, *entry) || ! entry->finalize()) {
|
if (! run_hooks(entry_finalize_hooks, *entry, false) ||
|
||||||
|
! entry->finalize() ||
|
||||||
|
! run_hooks(entry_finalize_hooks, *entry, true)) {
|
||||||
entry->journal = NULL;
|
entry->journal = NULL;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
25
journal.h
25
journal.h
|
|
@ -203,7 +203,7 @@ class entry_t : public entry_base_t
|
||||||
|
|
||||||
struct entry_finalizer_t {
|
struct entry_finalizer_t {
|
||||||
virtual ~entry_finalizer_t() {}
|
virtual ~entry_finalizer_t() {}
|
||||||
virtual bool operator()(entry_t& entry) = 0;
|
virtual bool operator()(entry_t& entry, bool post) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -223,7 +223,7 @@ public:
|
||||||
|
|
||||||
virtual ~auto_entry_t();
|
virtual ~auto_entry_t();
|
||||||
|
|
||||||
virtual void extend_entry(entry_base_t& entry);
|
virtual void extend_entry(entry_base_t& entry, bool post);
|
||||||
virtual bool valid() const {
|
virtual bool valid() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -233,7 +233,7 @@ class journal_t;
|
||||||
struct auto_entry_finalizer_t : public entry_finalizer_t {
|
struct auto_entry_finalizer_t : public entry_finalizer_t {
|
||||||
journal_t * journal;
|
journal_t * journal;
|
||||||
auto_entry_finalizer_t(journal_t * _journal) : journal(_journal) {}
|
auto_entry_finalizer_t(journal_t * _journal) : journal(_journal) {}
|
||||||
virtual bool operator()(entry_t& entry);
|
virtual bool operator()(entry_t& entry, bool post);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -328,12 +328,12 @@ std::ostream& operator<<(std::ostream& out, const account_t& account);
|
||||||
|
|
||||||
|
|
||||||
struct func_finalizer_t : public entry_finalizer_t {
|
struct func_finalizer_t : public entry_finalizer_t {
|
||||||
typedef bool (*func_t)(entry_t& entry);
|
typedef bool (*func_t)(entry_t& entry, bool post);
|
||||||
func_t func;
|
func_t func;
|
||||||
func_finalizer_t(func_t _func) : func(_func) {}
|
func_finalizer_t(func_t _func) : func(_func) {}
|
||||||
func_finalizer_t(const func_finalizer_t& other) : func(other.func) {}
|
func_finalizer_t(const func_finalizer_t& other) : func(other.func) {}
|
||||||
virtual bool operator()(entry_t& entry) {
|
virtual bool operator()(entry_t& entry, bool post) {
|
||||||
return func(entry);
|
return func(entry, post);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -351,11 +351,11 @@ void remove_hook(std::list<T>& list, T obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename Data>
|
template <typename T, typename Data>
|
||||||
bool run_hooks(std::list<T>& list, Data& item) {
|
bool run_hooks(std::list<T>& list, Data& item, bool post) {
|
||||||
for (typename std::list<T>::const_iterator i = list.begin();
|
for (typename std::list<T>::const_iterator i = list.begin();
|
||||||
i != list.end();
|
i != list.end();
|
||||||
i++)
|
i++)
|
||||||
if (! (*(*i))(item))
|
if (! (*(*i))(item, post))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -432,15 +432,16 @@ class journal_t
|
||||||
bool valid() const;
|
bool valid() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void extend_entry_base(journal_t * journal, entry_base_t& entry) {
|
inline void extend_entry_base(journal_t * journal, entry_base_t& entry,
|
||||||
|
bool post) {
|
||||||
for (auto_entries_list::iterator i = journal->auto_entries.begin();
|
for (auto_entries_list::iterator i = journal->auto_entries.begin();
|
||||||
i != journal->auto_entries.end();
|
i != journal->auto_entries.end();
|
||||||
i++)
|
i++)
|
||||||
(*i)->extend_entry(entry);
|
(*i)->extend_entry(entry, post);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool auto_entry_finalizer_t::operator()(entry_t& entry) {
|
inline bool auto_entry_finalizer_t::operator()(entry_t& entry, bool post) {
|
||||||
extend_entry_base(journal, entry);
|
extend_entry_base(journal, entry, post);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -716,7 +716,7 @@ unsigned int textual_parser_t::parse(std::istream& in,
|
||||||
if (parse_transactions(in, account_stack.front(), *pe,
|
if (parse_transactions(in, account_stack.front(), *pe,
|
||||||
"period", end_pos)) {
|
"period", end_pos)) {
|
||||||
if (pe->finalize()) {
|
if (pe->finalize()) {
|
||||||
extend_entry_base(journal, *pe);
|
extend_entry_base(journal, *pe, true);
|
||||||
journal->period_entries.push_back(pe);
|
journal->period_entries.push_back(pe);
|
||||||
pe->src_idx = src_idx;
|
pe->src_idx = src_idx;
|
||||||
pe->beg_pos = beg_pos;
|
pe->beg_pos = beg_pos;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue