diff options
-rw-r--r-- | src/filters.cc | 27 | ||||
-rw-r--r-- | test/baseline/opt-anon.test | 4 |
2 files changed, 25 insertions, 6 deletions
diff --git a/src/filters.cc b/src/filters.cc index 7c27a710..967e0843 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -142,6 +142,7 @@ namespace { buf.width(8); buf.fill('0'); buf << std::hex << message_digest[i]; + break; // only output the first dword } return buf.str(); } @@ -175,13 +176,31 @@ void anonymize_posts::operator()(post_t& post) post_t& temp = post_temps.back(); temp.xact = &xact; - sha.Reset(); - sha << post.account->fullname().c_str(); - sha.Result(message_digest); + std::list<string> account_names; + account_t * new_account = NULL; + + for (account_t * acct = post.account; + acct; + acct = acct->parent) { + if (! acct->parent) { + new_account = acct; + break; + } + + sha.Reset(); + sha << acct->name.c_str(); + sha.Result(message_digest); + + account_names.push_front(to_hex(message_digest)); + } + assert(new_account); + + foreach (const string& name, account_names) + new_account = new_account->find_account(name); temp.copy_details(post); - temp.account = post.xact->journal->find_account(to_hex(message_digest)); + temp.account = new_account; temp.note = none; temp.add_flags(ITEM_TEMP); diff --git a/test/baseline/opt-anon.test b/test/baseline/opt-anon.test index fb8acd64..f9244451 100644 --- a/test/baseline/opt-anon.test +++ b/test/baseline/opt-anon.test @@ -4,8 +4,8 @@ reg --anon Assets:Investments:Vanguard:VMMXX 0.350 VMMXX @ $1.00 Income:Dividends:Vanguard:VMMXX $-0.35 >>>1 -07-Feb-02 6a93dcb30aa7722e967.. ..cfb2807d6a978b431fc7 0.350 VMMXX 0.350 VMMXX - ..4fbac0065bfcc300a24e $-0.35 $-0.35 +07-Feb-02 6a93dcb3 20:5d:27:988a9c3a 0.350 VMMXX 0.350 VMMXX + 1c:b6:27:988a9c3a $-0.35 $-0.35 0.350 VMMXX >>>2 === 0 |