finance.tax.remove-vat Unreviewed
Extract the VAT already included in a gross amount, using the rate in force on the date of supply.
1.0.2 · published 2026-10-03 by charlie · Anterra
Pinned by 20 tests, run in TypeScript, Python and Rust.
Unreviewed. This capability’s implementations agree in every language and pass its published test vectors, which were worked out from the official sources cited. But no qualified chartered accountant or tax adviser has yet checked those vectors, or confirmed that the capability covers the cases it claims. Treat it as a draft. Do not use it for real people, money or decisions without your own expert review. Once a qualified reviewer signs off, this notice is replaced with their name, qualification and the date. Each new version needs fresh sign-off.
Not professional advice. This capability calculates tax figures from published rules. It is a software component for developers, not tax advice. Rules change and every rate here has an effective date. Check that the dates cover your case. Verify results against the official sources listed in its README, and have a chartered accountant or tax adviser review how you use it, before anyone relies on the output. Provided “as is” under its licence, without warranty.
What it does
Retail prices are quoted gross. Taking 20% off a gross price is the classic error: the VAT in a 120.00 gross price is 20.00, not 24.00.
The net is gross x 10000 / (10000 + rate), and the tax is whatever is left, so net and tax always add back to exactly the gross with no stray penny.
For example
remove_vat(£120.00, GB, STANDARD, 2026-09-16)→ net £100.00, tax £20.00, gross £120.00, rate 20% VAT inside 120 pounds is 20, not 24remove_vat(£2.39, GB, STANDARD, 2026-09-16)→ net £1.99, tax £0.40, gross £2.39, rate 20% round trips with add-vatremove_vat(£1.00, GB, STANDARD, 2026-09-16)→ net £0.83, tax £0.17, gross £1.00, rate 20% a 1 pound gross price
The function
The same function in TypeScript, Python and Rust, pinned by the same tests. Pick your language; the choice follows you around the registry.
def remove_vat(gross: Money, jurisdiction: str, category: str, on_date: str) -> VatBreakdown
| gross | Money | the VAT-inclusive amount |
| jurisdiction | string | |
| category | string | |
| on_date | date | date of supply, not today |
| returns | VatBreakdown |
Your code names it in one line, in the file that uses it
from fune.finance.tax.remove_vat import remove_vat # finance.tax.remove-vat@^1
Imports name this capability’s declared dependencies, which fune builds next to it in your project; each one links to its page.
from .finance_tax_add_vat import VatBreakdown ← from finance.tax.add-vat ^1.0.0 · built alongside by fune
from .finance_tax_vat_rate import vat_rate ← from finance.tax.vat-rate ^1.0.0 · built alongside by fune
from .math_round_div import round_div ← from math.round-div ^1.0.0 · built alongside by fune
from .money_amount import Money, money ← from money.amount ^1.0.0 · built alongside by fune
def remove_vat(gross: Money, jurisdiction: str, category: str, on_date: str) -> VatBreakdown:
"""Extract the VAT already included in a gross amount.
Taking 20% off a gross price is the classic error: the VAT inside a 120.00
gross price is 20.00, not 24.00. The net is gross x 10000 / (10000 + rate),
and the tax is the remainder, so the parts always add back to exactly the
gross with no stray penny.
"""
rate = vat_rate(jurisdiction, category, on_date)
net = money(round_div(gross.minor * 10000, 10000 + rate.basis_points, "half-up"), gross.currency)
return VatBreakdown(
net=net,
tax=money(gross.minor - net.minor, gross.currency),
gross=gross,
basis_points=rate.basis_points,
)Install
fune build
With that line in your source, in a Python project (language python in fune.project), fune build resolves it and its 4 dependencies, pins them in fune.lock, downloads only the Python package of each, and builds the code above into your project’s .fune/build, one readable file per capability with a header linking back here. Or pin a range in fune.project and build in one step:
fune add finance.tax.remove-vat
The manifest, vectors and README with only the Python implementation. Install it without the registry with fune add ./finance.tax.remove-vat-1.0.2-python.fune, or fetch it from a terminal with fune pull finance.tax.remove-vat@1.0.2:python.
The whole function, every language, is one file too: finance.tax.remove-vat-1.0.2.fune, 12,741 bytes, sha256 a0de006f7150d4162a1c9fbb6fdb42ac78bf05e9a21abf97409fe209e8e6bb88. It installs into a project of any language.
Customise it in your app
The seams this capability offers. Put a marker directly above a function of your own and fune build wires it into the built code; the package on the registry is not changed, the built file’s header lists it under CUSTOMISED, and fune hooks lists every hook in the project. How hooks work.
before — your function gets the arguments and returns them, changed or not, or throws to refuse the call.
# fune: before finance.tax.remove-vat
after — your function gets the result and the arguments, and returns the final result.
# fune: after finance.tax.remove-vat
replace — inside this capability’s code only, calls to a dependency go to your function, with the same signature. Other capabilities that use it are unaffected; write in * to replace it everywhere.
# fune: replace finance.tax.add-vat in finance.tax.remove-vat
# fune: replace finance.tax.vat-rate in finance.tax.remove-vat
# fune: replace math.round-div in finance.tax.remove-vat
# fune: replace money.amount in finance.tax.remove-vat
step — your function runs at a numbered point inside the function’s body, receives the in-scope values it names as parameters, and may return replacements. List the points with fune show finance.tax.remove-vat --steps.
# fune: step finance.tax.remove-vat after <n|label>
Tests
A version published now needs at least 8 tests for every function, and one that expects the error for each function that throws; the registry refuses it otherwise. fune verify --all runs each case in TypeScript, Python and Rust, and a project runs them again with fune verify. This page lists the cases; it does not run them. The exact JSON is vectors.json.
| Case | Arguments | Expected | |
|---|---|---|---|
| VAT inside 120 pounds is 20, not 24 | £120.00, GB, STANDARD, 2026-09-16 | → | net £100.00, tax £20.00, gross £120.00, rate 20% |
| round trips with add-vat | £2.39, GB, STANDARD, 2026-09-16 | → | net £1.99, tax £0.40, gross £2.39, rate 20% |
| a 1 pound gross price | £1.00, GB, STANDARD, 2026-09-16 | → | net £0.83, tax £0.17, gross £1.00, rate 20% |
| zero rated gross is all net | £100.00, GB, ZERO, 2026-09-16 | → | net £100.00, tax £0.00, gross £100.00, rate 0% |
| reduced rate gross | £105.00, GB, REDUCED, 2026-09-16 | → | net £100.00, tax £5.00, gross £105.00, rate 5% |
| a 2009 gross price uses the 2009 rate | £115.00, GB, STANDARD, 2009-06-01 | → | net £100.00, tax £15.00, gross £115.00, rate 15% |
| a refund of a gross price | -£120.00, GB, STANDARD, 2026-09-16 | → | net -£100.00, tax -£20.00, gross -£120.00, rate 20% |
| a tie in the net rounds half up, so 9p holds 1p of VAT, not the 2p that 20% of the net suggests | £0.09, GB, STANDARD, 2026-09-16 | → | net £0.08, tax £0.01, gross £0.09, rate 20% |
| a refund's tie rounds away from zero the same way | -£0.09, GB, STANDARD, 2026-09-16 | → | net -£0.08, tax -£0.01, gross -£0.09, rate 20% |
| a penny holds no VAT | £0.01, GB, STANDARD, 2026-09-16 | → | net £0.01, tax £0.00, gross £0.01, rate 20% |
Show the other 10 tests
| Case | Arguments | Expected | |
|---|---|---|---|
| zero gross is zero everything | £0.00, GB, STANDARD, 2026-09-16 | → | net £0.00, tax £0.00, gross £0.00, rate 20% |
| exempt supplies carry no VAT | £100.00, GB, EXEMPT, 2026-09-16 | → | net £100.00, tax £0.00, gross £100.00, rate 0% |
| a 2010 gross price uses the 17.5% rate | £117.50, GB, STANDARD, 2010-06-01 | → | net £100.00, tax £17.50, gross £117.50, rate 17.5% |
| an Irish gross price uses the Irish 23% rate | €123.00, IE, STANDARD, 2026-09-16 | → | net €100.00, tax €23.00, gross €123.00, rate 23% |
| an Irish reduced rate that does not divide evenly | €10.00, IE, REDUCED, 2026-09-16 | → | net €8.81, tax €1.19, gross €10.00, rate 13.5% |
| a large gross stays exact | £1,200,000,000.00, GB, STANDARD, 2026-09-16 | → | net £1,000,000,000.00, tax £200,000,000.00, gross £1,200,000,000.00, rate 20% |
| a jurisdiction with no rules is an error | £120.00, XX, STANDARD, 2026-09-16 | → | error: no VAT rule |
| a category with no rules is an error | £120.00, GB, LUXURY, 2026-09-16 | → | error: no VAT rule |
| a date that is not ISO is an error | £120.00, GB, STANDARD, 16/09/2026 | → | error: ISO date |
| an invalid currency is an error | 120.00 gbp, GB, STANDARD, 2026-09-16 | → | error: ISO 4217 |
More from the author
1.0.1 adds tests; behaviour unchanged.
## Before you rely on this
**Not professional advice.** This capability calculates tax figures from published rules. It is a software component for developers, not tax advice. Rules change and every rate here has an effective date. Check that the dates cover your case. Verify results against the official sources listed above, and have a chartered accountant or tax adviser review how you use it, before anyone relies on the output. Provided "as is" under its licence, without warranty.
**Unreviewed.** This capability's implementations agree in every language and pass its published test vectors, which were worked out from the official sources cited. But no qualified chartered accountant or tax adviser has yet checked those vectors, or confirmed that the capability covers the cases it claims. Treat it as a draft. Do not use it for real people, money or decisions without your own expert review. Once a qualified reviewer signs off, this notice is replaced with their name, qualification and the date. Each new version needs fresh sign-off.
1.0.2 marks it unreviewed. The code and the tests are unchanged.
Files
| Path | Bytes |
|---|---|
| README.md | 1,468 |
| impl/python.py | 922 |
| impl/rust.rs | 1,263 |
| impl/typescript.ts | 952 |
| vectors.json | 5,516 |