Improvement to account alias expansion
Aliases are now expanded not only if they occur by themselves, but also if they occur as the beginning of a multi-part account. Given <alias Food=Expenses:Food> the account <Food:Tomatos> should now be expanded to <Expenses:Food:Tomatos>.
This commit is contained in:
parent
82ac7ef313
commit
aba0a5ed2d
1 changed files with 12 additions and 1 deletions
|
|
@ -127,8 +127,19 @@ account_t * journal_t::register_account(const string& name, post_t * post,
|
|||
// object.
|
||||
if (account_aliases.size() > 0) {
|
||||
accounts_map::const_iterator i = account_aliases.find(name);
|
||||
if (i != account_aliases.end())
|
||||
if (i != account_aliases.end()) {
|
||||
result = (*i).second;
|
||||
} else {
|
||||
// only check the very first account for alias expansion, in case
|
||||
// that can be expanded successfully
|
||||
size_t colon = name.find(':');
|
||||
if(colon != string::npos) {
|
||||
accounts_map::const_iterator i = account_aliases.find(name.substr(0, colon));
|
||||
if (i != account_aliases.end()) {
|
||||
result = find_account((*i).second->fullname() + name.substr(colon));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create the account object and associate it with the journal; this
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue