Apple is getting more publicity than it ever dreamed of just before the expected launch of its new iPhone 7. You'd think CEO Tim Cook would be happier.

But instead of celebrating, Cook is outraged by a European Commission ruling that the company owes Ireland what could amount to more than $27 billion in back taxes, drawing unwelcome attention to the company's international attempts at tax avoidance during a U.S. election campaign.

"We now find ourselves in the unusual position of being ordered to retroactively pay additional taxes to a government that says we don't owe them any more than we've already paid," Cook wrote in a letter responding to the EC ruling.

Irish windfall

European Commissioner for Competition Margrethe Vestager gestures during a news conference about Ireland's tax dealings with Apple. (REUTERS) Both Apple and the Irish government say they will appeal the ruling, though the windfall for Ireland might make you wonder how hard its lawyers will try to get it overturned.

Europe has ordered Apple to pay 13 billion euros, plus interest, to the Irish government for taxes Ireland should have collected and, perhaps more importantly, that Apple should have paid, if not to Ireland then to someone else.

To a country the size of Ireland, the sum is astounding, wiping out its deficit and making a significant dent in its national debt. That is more than $4,000 Cdn for every Irish woman, child and man.

Awkward reminder

After tacking on years of interest on the money Apple owes, the number could rise to more like 19 billion euros. That's more than $27 billion Cdn, enough to buy everyone in Canada a new iPhone.

Apple has assured its shareholders that its lawyers will make sure the ruling doesn't stand. But the huge amount of money involved is an awkward reminder of the absurdity of a multibillion-dollar de facto U.S. corporation having a "head office" in a small country where the tax bills are a tiny fraction of what the company would pay at home.

Apple CEO Tim Cook condemned the European tax ruling, saying the company obeys the tax rules of every country where it operates, but he didn't mention the term 'tax avoidance.' (Reuters) "In Ireland and in every country where we operate, Apple follows the law and we pay all the taxes we owe," Cook says in a statement that rings with righteous indignation

But the overall impression you might get from reading the Apple boss's statement is one of disingenuousness.

Not once does Cook mention the key phrase "tax avoidance," a process that allows companies ostensibly following all the laws of their countries of tax residence to avoid tax they would owe if they repatriated all their various global income.

'Existed on paper'

Part of what Europe objects to is the widespread phenomenon of "tax residence of convenience," where a subsidiary company that legally owns such things as patents and licences is located in a low-tax country. In that way, internal corporate accounting allows profits from parts of the company in high-tax regimes to be transferred to low-tax countries in the form of charges, fees and royalties.

The European ruling points out that the Irish "head office" was a fiction that "existed on paper."

But in Ireland there was a further consideration. Under earlier Irish rules, while companies might tell their "home" country they were based elsewhere, Ireland declared them stateless for the purposes of declaring their global profits.

"These profits allocated to the 'head office,'" said the commission, "were not subject to tax in any country under specific provisions of the Irish tax law."

Apple says it will appeal the European tax ruling, but the dispute has overshadowed the launch of the new iPhone 7, expected next week. (Reuters) Ireland has now changed parts of its tax laws.

Even the European Commission's press release is complicated. The ruling is based on the idea that the deal given to Apple was anti-competitive because other companies didn't get equivalent benefits. No doubt there will be lots of legal room to niggle, increasing the chances of a successful appeal.

Billions on the table

But the high-value, high-profile decision reminds everyone, including U.S. voters, that there are billions of dollars of unpaid taxes on the table, and not just at Apple. Supporters of presidential candidates Donald Trump and Hillary Clinton might ask why American companies are allowed to get away with it and why it's Europe and not the U.S. government policing corporate tax avoidance.

Apple is an American business champion, an innovator and a success story. But as the Financial Times pointed out yesterday, "Apple's lightly taxed foreign cash mountain is the biggest of any U.S. multinational."

Despite the fact that elected governments are supposed to represent their voters, the U.S. Congress has been reluctant to crack down on tax avoidance.

The rich countries' think-tank, the Organization for Economic Co-operation and Development​, has led a campaign to bring governments together to restore needed corporate taxation, but as yesterday's ruling shows, the problem is far from resolved.

If Europe's move this week prompts new global action, everyone — except perhaps Apple shareholders, Apple managers and other tax-avoiding companies — will benefit.

And with billions of dollars at stake and years of litigation ahead, once again the tax lawyers will make out like bandits.

Follow Don on Twitter @don_pittis

​More analysis by Don Pittis

.