summaryrefslogtreecommitdiff
path: root/src/journal.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2014-04-13 23:25:31 -0500
committerJohn Wiegley <johnw@newartisans.com>2014-04-13 23:26:14 -0500
commit8f8a94c28e26c0b46a43e89d566c941994645de7 (patch)
tree3cbd52816734c55fb6233b9a3f7fb35cb0b36fd9 /src/journal.cc
parent634aa589cd97d088524ae2fb68ec6120d5e4a873 (diff)
downloadfork-ledger-8f8a94c28e26c0b46a43e89d566c941994645de7.tar.gz
fork-ledger-8f8a94c28e26c0b46a43e89d566c941994645de7.tar.bz2
fork-ledger-8f8a94c28e26c0b46a43e89d566c941994645de7.zip
Add the concept of "deferred postings"
This is pretty much exclusively for allowing one to use balance assertions with replicated transactions across multiple files.
Diffstat (limited to 'src/journal.cc')
-rw-r--r--src/journal.cc17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/journal.cc b/src/journal.cc
index ef35722c..94a535d7 100644
--- a/src/journal.cc
+++ b/src/journal.cc
@@ -385,9 +385,24 @@ bool journal_t::add_xact(xact_t * xact)
// will have been performed by extend_xact, so asserts can still be
// applied to it.
if (optional<value_t> ref = xact->get_tag(_("UUID"))) {
+ std::string uuid = ref->to_string();
std::pair<checksum_map_t::iterator, bool> result
- = checksum_map.insert(checksum_map_t::value_type(ref->to_string(), xact));
+ = checksum_map.insert(checksum_map_t::value_type(uuid, xact));
if (! result.second) {
+ // This UUID has been seen before; apply any postings which the
+ // earlier version may have deferred.
+ foreach (post_t * post, xact->posts) {
+ account_t * acct = post->account;
+ if (acct->deferred_posts) {
+ deferred_posts_map_t::iterator
+ i = acct->deferred_posts->find(uuid);
+ if (i != acct->deferred_posts->end()) {
+ foreach (post_t * rpost, (*i).second)
+ acct->add_post(rpost);
+ }
+ }
+ }
+
// jww (2012-02-27): Confirm that the xact in
// (*result.first).second is exact match in its significant
// details to xact.