A seller in Germany lists an item at €24.99. A seller in Poland lists the same item at 24.99 zł-equivalent. Both see the same headline number. Neither receives it.
In the EU, prices are quoted VAT-inclusive. The tax is collected on behalf of the state, and it comes out of the headline price before any platform takes its percentage. That single fact breaks most fee calculators, because they compute percentages against the number on the price tag.
This is a note on the model, the arithmetic, and one implementation detail I found more interesting than expected: getting the same calculation to run on the server and in the browser without duplicating it.
The part everyone gets wrong
Take a €24.99 item at Germany's 19% rate, with a 9% referral fee, 10% creator commission, and 1.5% + €0.25 payment fees.
The intuitive (wrong) calculation:
fees = 24.99 × (0.09 + 0.10 + 0.015) + 0.25 = 5.37 payout = 24.99 − 5.37 − 7.80 (product) − 3.90 (shipping) = 7.92 The correct one:
net price = 24.99 ÷ 1.19 = 21.00 VAT = 24.99 − 21.00 = 3.99 ← never yours fees = 21.00 × (0.09 + 0.10 + 0.015) + 0.25 = 4.56 payout = 21.00 − 4.56 − 7.80 − 3.90 = 4.74 The gap is €3.17 per order: the intuitive result is 67% higher than the real one, and it is entirely an artefact of applying percentages to a base that includes tax.
At a 20% rate, every percentage is applied to a base that is a fifth larger than the real one. On 500 orders a month a €3 error per order is roughly €1,500 of margin that never existed.
Seven rates, one formula
The formula is the same everywhere; only the rate changes:
net price = gross ÷ (1 + rate) VAT collected = gross − net price What changes per country is the rate, and it is not uniform:
| Country | Standard rate |
|---|---|
| Germany | 19% |
| France | 20% |
| Netherlands | 21% |
| Spain | 21% |
| Italy | 22% |
| Poland | 23% |
| Sweden | 25% |
That is a 6-point spread. A seller shipping the same product from a Polish warehouse to German and Swedish customers is operating two different margin structures, and the difference is bigger than most shipping-cost variations.
Under EU distance-selling rules the rate follows the destination, not the warehouse. Which is why the calculator asks for a country rather than a warehouse location.
The code: one function, two runtimes
The calculator is a static site. There is no server doing arithmetic at request time — but the first paint still needs real numbers, because a calculator showing — until JavaScript loads is a bad calculator.
The trick is that the maths lives in a plain ES module that both runtimes import:
// src/lib/calc.js const num = (v, key, fallback = 0) => { const n = Number(v[key]); return Number.isFinite(n) ? n : fallback; }; export function compute(slug, v) { switch (slug) { case "tiktok-shop-fee-calculator-eu": { const gross = num(v, "price"); const netPrice = gross / (1 + num(v, "vat") / 100); const referral = (netPrice * num(v, "referral")) / 100; const affiliate = (netPrice * num(v, "affiliate")) / 100; const payment = (netPrice * num(v, "feePct")) / 100 + num(v, "feeFixed"); const takeHome = netPrice - referral - affiliate - payment - num(v, "cogs") - num(v, "ship"); return { takeHome, netPrice, vatAmount: gross - netPrice, margin: netPrice > 0 ? (takeHome / netPrice) * 100 : 0, fees: referral + affiliate + payment, }; } // …eight other calculators } } The page component imports it twice, for two different consumers:
--- // Build time: render the initial values into the HTML import { compute, fmt } from "../lib/calc.js"; const out = compute(tool.slug, defaultValues); const currency = tool.currency ?? "$"; --- <b data-out="takeHome">{fmt(out.takeHome, "money", currency)}</b> <script> // Browser: re-run the same function on every input change import { compute, fmt } from "../lib/calc.js"; form.addEventListener("input", () => { /* update from compute() */ }); </script> Astro bundles the <script> block and leaves the frontmatter import server-side. One module, two consumers, zero duplicated arithmetic. When I changed the VAT handling, both the pre-rendered HTML and the live calculation changed together — the class of bug where server and client disagree about a number simply cannot happen.
Three details worth stealing
1. Currency is a parameter, not a hardcoded symbol. fmt(value, "money", "€") — because the same calculator exists in USD, GBP and EUR variants, and string-replacing $ later is how you get dollars in a eurozone page.
2. Rates are data, not code. The VAT rate lives in the field definition (options: ["19","20","21","22","23","24","25"]), so adding Hungary's 27% is a one-line change and does not touch the formula.
3. The tax is displayed, not just deducted. Showing VAT collected: €3.99 next to the payout is what makes the number believable. A single "take-home" figure invites the question "why is this so low?"; showing the line item answers it.
What I would do differently
I originally applied the payment percentage to the gross price and only stripped VAT at the end. It produced numbers that looked plausible and were wrong by exactly the tax rate — the worst kind of bug, because nothing crashes and the result is still in the right ballpark.
The fix was not code. It was writing the formula out in plain text first:
net price = gross ÷ (1 + VAT rate) fees = net price × rate If a formula cannot be written as three lines above the implementation, the implementation is doing something the author has not decided yet.
The calculator this came from is free and runs entirely client-side: TikTok Shop EU fee calculator. There are UK and US variants built the same way, and the VAT table is one object if you want to check a rate against yours.
If you are modelling EU pricing and hit a case this does not cover — reduced rates on books and children's clothing, OSS registration thresholds, IOSS consignments under €150 — I would like to hear about it. Those are the edges where a simple formula stops being enough.


