countries

package
v0.0.0-...-da9e6da Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package countries contains European countries and their VAT rates from an European Union point of view.

Index

Constants

This section is empty.

Variables

View Source
var All = []Country{AT, BE, BG, CH, CY, CZ, DE, DK, EE, ES, FI, FR, GB, GR, HR, HU, IE, IT, LT, LU, LV, ME, MT, NL, PL, PT, RO, SE, SI, SK}
View Source
var EuropeanUnion = []Country{AT, BE, BG, CY, CZ, DE, DK, EE, ES, FI, FR, GR, HR, HU, IE, IT, LT, LU, LV, MT, NL, PL, PT, RO, SE, SI, SK}

Functions

func Convert

func Convert(value int, src Country, srcRate Rate, dst Country, dstRate Rate) int

func InEuropeanUnion

func InEuropeanUnion(country Country) bool

Types

type Country

type Country string // ISO 3166-1 code
const (
	// European Union
	AT Country = "AT"
	BE Country = "BE"
	BG Country = "BG"
	CY Country = "CY"
	CZ Country = "CZ"
	DE Country = "DE"
	DK Country = "DK"
	EE Country = "EE"
	ES Country = "ES"
	FI Country = "FI"
	FR Country = "FR"
	GR Country = "GR"
	HR Country = "HR"
	HU Country = "HU"
	IE Country = "IE"
	IT Country = "IT"
	LT Country = "LT"
	LU Country = "LU"
	LV Country = "LV"
	MT Country = "MT"
	NL Country = "NL"
	PL Country = "PL"
	PT Country = "PT"
	RO Country = "RO"
	SE Country = "SE"
	SI Country = "SI"
	SK Country = "SK"

	NonEU Country = "non-EU"

	// selected Non-EU countries
	CH Country = "CH"
	GB Country = "GB"
	ME Country = "ME"
)

func Get

func Get(cs []Country, id string) (Country, bool)

func (Country) TranslateName

func (c Country) TranslateName(l lang.Lang) string

func (Country) VAT

func (c Country) VAT() VATRates

VAT rates are from: https://europa.eu/youreurope/business/taxation/vat/vat-rules-rates/index_en.htm#shortcut-5. Note that the ISO 3166-1 code for Greece is "GR", but the VAT rate table uses its ISO 639-1 code "EL".

type CountryWithName

type CountryWithName struct {
	Country
	Name string
}

func TranslateAndSort

func TranslateAndSort(l lang.Lang, countries []Country) []CountryWithName

type Rate

type Rate string
const (
	RateStandard     Rate = "standard"
	RateReduced1     Rate = "reduced-1"
	RateReduced2     Rate = "reduced-2"
	RateSuperReduced Rate = "super-reduced"
	RateParking      Rate = "parking"
)

type VATRates

type VATRates map[Rate]float64

func (VATRates) Gross

func (vr VATRates) Gross(net float64, rateKey Rate) (float64, bool)

Gross returns the gross of the given net amount using the given VAT rate key. The boolean return value indicates if the rate has been found. If it is not found, the maximum rate is used.

func (VATRates) Net

func (vr VATRates) Net(gross float64, rateKey Rate) (float64, bool)

Gross returns the net of the given gross amount using the given VAT rate key. The boolean return value indicates if the rate has been found. If it is not found, the maximum rate is used.

func (VATRates) Rate

func (vr VATRates) Rate(rateKey Rate) (float64, bool)

VATRate returns the VAT rate with the given key. The boolean return value indicates if the rate has been found. If it is not found, the maximum rate is used.

Directories

Path Synopsis
Package detect detects a customer's country options based on their Accept-Language and IP address.
Package detect detects a customer's country options based on their Accept-Language and IP address.
Command print-rates prints the VAT rates of European Union countries in a format similar to https://europa.eu/youreurope/business/taxation/vat/vat-rules-rates/index_en.htm#shortcut-5 so we can easily diff it.
Command print-rates prints the VAT rates of European Union countries in a format similar to https://europa.eu/youreurope/business/taxation/vat/vat-rules-rates/index_en.htm#shortcut-5 so we can easily diff it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL