Documentation
¶
Overview ¶
Package euvatrates provides VAT rates for 44 European countries (EU-27 + 17 non-EU).
EU rates are sourced from the European Commission TEDB (Taxes in Europe Database) and embedded at compile time. Non-EU rates are maintained manually.
Usage:
import euvatrates "github.com/vatnode/eu-vat-rates-data-go"
rate, ok := euvatrates.GetRate("FI")
// rate.Standard == 25.5, rate.Country == "Finland", rate.EUMember == true
standard, ok := euvatrates.GetStandardRate("DE") // 19.0, true
euvatrates.IsEUMember("NO") // false
euvatrates.IsEUMember("FR") // true
euvatrates.DataVersion() // "2026-03-18"
Index ¶
- func DataVersion() string
- func GetAllRates() map[string]VatRate
- func GetFlag(countryCode string) string
- func GetStandardRate(countryCode string) (float64, bool)
- func HasRate(countryCode string) bool
- func IsEUMember(countryCode string) bool
- func ValidateFormat(vatID string) bool
- type Dataset
- type VatRate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DataVersion ¶
func DataVersion() string
DataVersion returns the ISO 8601 date when the EU data was last fetched from EC TEDB.
func GetAllRates ¶
GetAllRates returns a copy of the full rates map (44 countries).
func GetFlag ¶ added in v1.6.0
GetFlag returns the flag emoji for a 2-letter ISO 3166-1 alpha-2 country code. Computed from regional indicator symbols — no lookup table needed. Returns an empty string if the input is not exactly 2 ASCII letters.
Example:
GetFlag("FI") // "🇫🇮"
GetFlag("DE") // "🇩🇪"
GetFlag("GB") // "🇬🇧"
func GetStandardRate ¶
GetStandardRate returns the standard VAT rate for the given country code. The second return value is false if the country is not in the dataset.
func HasRate ¶ added in v1.0.1
HasRate returns true if the given country code is present in the dataset (all 44 countries). Use IsEUMember to check EU membership specifically.
func IsEUMember ¶
IsEUMember returns true if the country is an EU-27 member state. Returns false for non-EU countries in the dataset (GB, NO, CH, etc.) and for unknown country codes.
func ValidateFormat ¶ added in v1.5.0
ValidateFormat returns true if vatID matches the expected format for its country. Input must include the country code prefix (e.g. "ATU12345678"). Returns false when the country has no standardised format or the ID does not match. Note: Greece uses the "EL" prefix, not "GR".
Types ¶
type Dataset ¶
type Dataset struct {
Version string `json:"version"`
Source string `json:"source"`
URL string `json:"url"`
Rates map[string]VatRate `json:"rates"`
}
Dataset is the top-level structure of the data file.
type VatRate ¶
type VatRate struct {
Country string `json:"country"`
Currency string `json:"currency"`
EUMember bool `json:"eu_member"`
VATName string `json:"vat_name"`
VATAbbr string `json:"vat_abbr"`
Standard float64 `json:"standard"`
Reduced []float64 `json:"reduced"`
SuperReduced *float64 `json:"super_reduced"`
Parking *float64 `json:"parking"`
Format string `json:"format"`
Pattern string `json:"pattern"` // Always present for all 44 countries
}
VatRate holds all VAT rates for a single country.