diff options
-rw-r--r-- | src/journal.h | 3 | ||||
-rw-r--r-- | src/textual.cc | 21 |
2 files changed, 24 insertions, 0 deletions
diff --git a/src/journal.h b/src/journal.h index 4458ba93..803b9511 100644 --- a/src/journal.h +++ b/src/journal.h @@ -63,6 +63,8 @@ typedef std::list<auto_xact_t *> auto_xacts_list; typedef std::list<period_xact_t *> period_xacts_list; typedef std::pair<mask_t, string> payee_alias_mapping_t; typedef std::list<payee_alias_mapping_t> payee_alias_mappings_t; +typedef std::pair<string, string> payee_uuid_mapping_t; +typedef std::list<payee_uuid_mapping_t> payee_uuid_mappings_t; typedef std::pair<mask_t, account_t *> account_mapping_t; typedef std::list<account_mapping_t> account_mappings_t; typedef std::map<string, account_t *> accounts_map; @@ -134,6 +136,7 @@ public: bool recursive_aliases; bool no_aliases; payee_alias_mappings_t payee_alias_mappings; + payee_uuid_mappings_t payee_uuid_mappings; account_mappings_t account_mappings; accounts_map account_aliases; account_mappings_t payees_for_unknown_accounts; diff --git a/src/textual.cc b/src/textual.cc index 0a590e08..60250007 100644 --- a/src/textual.cc +++ b/src/textual.cc @@ -155,6 +155,7 @@ namespace { void payee_directive(char * line); void payee_alias_directive(const string& payee, string alias); + void payee_uuid_directive(const string& payee, string uuid); void commodity_directive(char * line); void commodity_alias_directive(commodity_t& comm, string alias); @@ -1035,6 +1036,8 @@ void instance_t::payee_directive(char * line) string keyword(p); if (keyword == "alias") payee_alias_directive(payee, b); + if (keyword == "uuid") + payee_uuid_directive(payee, b); } } @@ -1045,6 +1048,13 @@ void instance_t::payee_alias_directive(const string& payee, string alias) .push_back(payee_alias_mapping_t(mask_t(alias), payee)); } +void instance_t::payee_uuid_directive(const string& payee, string uuid) +{ + trim(uuid); + context.journal->payee_uuid_mappings + .push_back(payee_uuid_mapping_t(uuid, payee)); +} + void instance_t::commodity_directive(char * line) { char * p = skip_ws(line); @@ -1862,6 +1872,17 @@ xact_t * instance_t::parse_xact(char * line, else { reveal_context = false; + if (!last_post) { + if (xact->has_tag(_("UUID"))) { + string uuid = xact->get_tag(_("UUID"))->to_string(); + foreach (payee_uuid_mapping_t value, context.journal->payee_uuid_mappings) { + if (value.first.compare(uuid) == 0) { + xact->payee = value.second; + } + } + } + } + if (post_t * post = parse_post(p, len - (p - line), account, xact.get())) { reveal_context = true; |