I solve a similar problem by adopting a naming convention
For example, at work I like to keep track of expenses on science grants I manage using 3 different account hierarchies. One hierarchy of account names is "real", the other two are virtual.
One hierarchy represents the way my institution (WHOI) prints it's project balance sheets, another represents the way my funders (NSF) like to see expenses reported in annual reports, and the third is the way I (ANDY) think about the money I am spending and managing. So, when I run across a salary cost (for example) I post it something like this...
2015-01-01 Week 01 Payroll Distribution
WHOI:Expenses:Salary 1000
WHOI:Assets:Grant#2304982 -1000
(NSF:Expenses:Personnel 1000)
(ANDY:Expenses:PeopleCosts 1000)
ledger bal ^NSF:Expenses
prints out all my expenses the way NSF likes to see them
Using a similar approach one could setup the above journal entries as follows: