Don't output extra commodity "posts"
If a posting has already been registered for a given date with a given price, don't register it again.
This commit is contained in:
parent
e182f01de1
commit
d5b1ee56e1
1 changed files with 38 additions and 27 deletions
|
|
@ -90,10 +90,8 @@ void posts_commodities_iterator::reset(journal_t& journal)
|
||||||
std::map<string, xact_t *> xacts_by_commodity;
|
std::map<string, xact_t *> xacts_by_commodity;
|
||||||
|
|
||||||
foreach (commodity_t * comm, commodities) {
|
foreach (commodity_t * comm, commodities) {
|
||||||
optional<commodity_t::varied_history_t&> history = comm->varied_history();
|
if (optional<commodity_t::varied_history_t&> history =
|
||||||
if (! history)
|
comm->varied_history()) {
|
||||||
continue;
|
|
||||||
|
|
||||||
account_t * account = journal.master->find_account(comm->symbol());
|
account_t * account = journal.master->find_account(comm->symbol());
|
||||||
|
|
||||||
foreach (commodity_t::base_t::history_by_commodity_map::value_type pair,
|
foreach (commodity_t::base_t::history_by_commodity_map::value_type pair,
|
||||||
|
|
@ -116,6 +114,17 @@ void posts_commodities_iterator::reset(journal_t& journal)
|
||||||
(std::pair<string, xact_t *>(symbol, xact));
|
(std::pair<string, xact_t *>(symbol, xact));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool post_already_exists = false;
|
||||||
|
|
||||||
|
foreach (post_t * post, xact->posts) {
|
||||||
|
if (post->_date == hpair.first.date() &&
|
||||||
|
post->amount == hpair.second) {
|
||||||
|
post_already_exists = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! post_already_exists) {
|
||||||
post_t& temp = temps.create_post(*xact, account);
|
post_t& temp = temps.create_post(*xact, account);
|
||||||
temp._date = hpair.first.date();
|
temp._date = hpair.first.date();
|
||||||
temp.amount = hpair.second;
|
temp.amount = hpair.second;
|
||||||
|
|
@ -124,6 +133,8 @@ void posts_commodities_iterator::reset(journal_t& journal)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
xacts.xacts_i = xact_temps.begin();
|
xacts.xacts_i = xact_temps.begin();
|
||||||
xacts.xacts_end = xact_temps.end();
|
xacts.xacts_end = xact_temps.end();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue