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,37 +90,48 @@ 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,
|
||||||
|
history->histories) {
|
||||||
|
foreach (commodity_t::base_t::history_map::value_type hpair,
|
||||||
|
pair.second.prices) {
|
||||||
|
xact_t * xact;
|
||||||
|
string symbol = hpair.second.commodity().symbol();
|
||||||
|
|
||||||
foreach (commodity_t::base_t::history_by_commodity_map::value_type pair,
|
std::map<string, xact_t *>::iterator i =
|
||||||
history->histories) {
|
xacts_by_commodity.find(symbol);
|
||||||
foreach (commodity_t::base_t::history_map::value_type hpair,
|
if (i != xacts_by_commodity.end()) {
|
||||||
pair.second.prices) {
|
xact = (*i).second;
|
||||||
xact_t * xact;
|
} else {
|
||||||
string symbol = hpair.second.commodity().symbol();
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
std::map<string, xact_t *>::iterator i =
|
bool post_already_exists = false;
|
||||||
xacts_by_commodity.find(symbol);
|
|
||||||
if (i != xacts_by_commodity.end()) {
|
foreach (post_t * post, xact->posts) {
|
||||||
xact = (*i).second;
|
if (post->_date == hpair.first.date() &&
|
||||||
} else {
|
post->amount == hpair.second) {
|
||||||
xact = &temps.create_xact();
|
post_already_exists = true;
|
||||||
xact_temps.push_back(xact);
|
break;
|
||||||
xact->payee = symbol;
|
}
|
||||||
xact->_date = hpair.first.date();
|
}
|
||||||
xacts_by_commodity.insert
|
|
||||||
(std::pair<string, xact_t *>(symbol, xact));
|
if (! post_already_exists) {
|
||||||
|
post_t& temp = temps.create_post(*xact, account);
|
||||||
|
temp._date = hpair.first.date();
|
||||||
|
temp.amount = hpair.second;
|
||||||
|
|
||||||
|
temp.xdata().datetime = hpair.first;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
post_t& temp = temps.create_post(*xact, account);
|
|
||||||
temp._date = hpair.first.date();
|
|
||||||
temp.amount = hpair.second;
|
|
||||||
|
|
||||||
temp.xdata().datetime = hpair.first;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue