> How can this still be possible? Shouldn't all tax legislation be such that if you break the spirit of it by having internal transfers (royalties, fees, interest) to a low-tax area, then you are still taxed based on the business that you had in the country in question, and based on the net sum (i.e. zero).
How would that even work? The costs are actually costs.
Imagine it was actually a dozen different companies. One of them is in California and it develops software on contract, one is in Germany and it develops hardware on contract, one is in China and it manufactures hardware on contract, one is in Ireland and it has the original capital which it pays to the first three in exchange for copyrights, hardware designs and hardware, one is in Spain and it buys product/services from the Irish company and sells local advertising, etc.
It turns out the company with that owns the copyrights makes the most money. That's how it honestly works whether the companies are separate or not. If you made the Spanish company liable for taxes on the profits of the whole supply chain, every company in Spain that uses Google ads would owe taxes on the money paid to Google (and the same for anything they buy from anyone). In other words you would have enacted a sales tax. Which is fine, but isn't an income tax and isn't a tax on Google.
What you seem to want to do is to identify that the companies are actually owned by the same party and do something different in that case. But five seconds after you require that, they would separate. Specifically the company that exists in a jurisdiction that cares about that would become independent. You don't need to own the stock of a company to capture all of its profits when you're its only viable supplier. So now there is an independent contractor in Spain that pays Google Ireland for ad space and resells it for just enough money to pay its own bills and makes no profits.
The problem is fundamentally that income tax makes no sense across borders. People will move whatever it is you're taxing into the country with the lowest taxes if the cost of moving that thing is less than the cost of the taxes. The cost of moving profits is very small. You have to tax something which is harder to move, which is then no longer an income tax.