calculate_vat
Converts between net, tax and gross for a given VAT rate, in either direction.
Give an amount and say whether it is net or gross, and you get all three figures back rounded to the cent. Germany's rates are 19 % (standard) and 7 % (reduced), but any rate from 0 to 100 is accepted, so this also works for an Austrian or French invoice.
Rounding is half-away-from-zero, the convention invoices and tax authorities use, and the three returned figures always reconcile: net plus tax equals gross exactly, with no cent left over from rounding each separately.
What this does NOT do: it does not decide which rate applies to a supply, handle more than one rate at a time, or know anything about reverse charge, intra-community supply or the Kleinunternehmer rules. It is arithmetic, not tax advice.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rate | Yes | VAT rate as a percentage, not a fraction: 19 means 19 %, not 1900 %. | |
| basis | Yes | Whether `amount` is the net figure (add tax to it) or the gross figure (take tax out of it). | |
| amount | Yes | The amount to convert, in the invoice currency. Must not be negative. |