Selecting right tax identifier for invoices

In Spain, a company may have two tax identifiers, one used for transactions inside Spain and another used for European Companies. It will be great if tryton selects the company identifer automatically based on the party tax identifier.

With the current design, it will be easy to pass the prefix for the party tax identifer to the get_tax_identifier function. When such prefix is set, the function will look at all the available identifers to see if any has the same prefix and use it no mather on who it is ordered. This is similar to what we do for contact mechanisms to decide which one to use for each type of communication.

This will be a simple solution to make tryton a little bit smarter. Does it sound reasonable? Do you have some example which such algorith won’t work?