summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2006-03-04 18:09:13 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 02:41:29 -0400
commit326235ffbe2fcaf3fe612b8852051f7dae08c47f (patch)
treed8ac8826af66014257263830994399284d270720
parent3c0caf1100b2ea93ae46e7642cc8a8ecfa477a33 (diff)
downloadfork-ledger-326235ffbe2fcaf3fe612b8852051f7dae08c47f.tar.gz
fork-ledger-326235ffbe2fcaf3fe612b8852051f7dae08c47f.tar.bz2
fork-ledger-326235ffbe2fcaf3fe612b8852051f7dae08c47f.zip
*** empty log message ***
-rw-r--r--amount.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/amount.cc b/amount.cc
index 24707eff..3a8c7e2a 100644
--- a/amount.cc
+++ b/amount.cc
@@ -1478,8 +1478,9 @@ commodity_t * commodity_t::find_or_create(const std::string& symbol)
DEBUG_PRINT("amounts.commodities", "Find-or-create commodity " << symbol);
commodity_t * commodity = find(symbol);
- if (! commodity)
- return create(symbol);
+ if (commodity)
+ return commodity;
+ return create(symbol);
}
commodity_t * commodity_t::find(const std::string& symbol)
@@ -1631,6 +1632,7 @@ annotated_commodity_t::create(const std::string& symbol,
{
commodity_t * comm = commodity_t::find_or_create(symbol);
assert(comm);
+
if (! price && ! date && tag.empty())
return comm;
@@ -1668,7 +1670,9 @@ annotated_commodity_t::find_or_create(const commodity_t& comm,
commodity_t * base = commodity_t::find(name);
if (base)
return base;
+
base = commodity_t::find_or_create(comm.base_symbol());
+ assert(base);
return create(*base, price, date, tag, name);
}