summaryrefslogtreecommitdiff
path: root/src/journal.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-10-30 19:03:23 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-10-30 19:03:28 -0400
commit63aa8992a81dfaececa4a9b38ba8daf29b57912e (patch)
tree808871837734f3779c369e71774f30fde7d89034 /src/journal.cc
parenta3799eebdb682162eb1edb3706a6ff1097b12f41 (diff)
downloadfork-ledger-63aa8992a81dfaececa4a9b38ba8daf29b57912e.tar.gz
fork-ledger-63aa8992a81dfaececa4a9b38ba8daf29b57912e.tar.bz2
fork-ledger-63aa8992a81dfaececa4a9b38ba8daf29b57912e.zip
Moved ownership of master account into journal_t
The journal_t now completely represents the data part of a session.
Diffstat (limited to 'src/journal.cc')
-rw-r--r--src/journal.cc26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/journal.cc b/src/journal.cc
index fdb49e24..d73d0fb8 100644
--- a/src/journal.cc
+++ b/src/journal.cc
@@ -32,11 +32,34 @@
#include <system.hh>
#include "journal.h"
+#include "amount.h"
+#include "commodity.h"
+#include "pool.h"
#include "xact.h"
#include "account.h"
namespace ledger {
+journal_t::journal_t()
+ : master(new account_t),
+ commodity_pool(new commodity_pool_t)
+{
+ TRACE_CTOR(journal_t, "");
+
+ // Add time commodity conversions, so that timelog's may be parsed
+ // in terms of seconds, but reported as minutes or hours.
+ if (commodity_t * commodity = commodity_pool->create("s"))
+ commodity->add_flags(COMMODITY_BUILTIN | COMMODITY_NOMARKET);
+ else
+ assert(false);
+
+ // Add a "percentile" commodity
+ if (commodity_t * commodity = commodity_pool->create("%"))
+ commodity->add_flags(COMMODITY_BUILTIN | COMMODITY_NOMARKET);
+ else
+ assert(false);
+}
+
journal_t::~journal_t()
{
TRACE_DTOR(journal_t);
@@ -52,6 +75,9 @@ journal_t::~journal_t()
foreach (period_xact_t * xact, period_xacts)
checked_delete(xact);
+
+ checked_delete(master);
+ commodity_pool.reset();
}
void journal_t::add_account(account_t * acct)