Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dannyvankooten/vat
Go package for dealing with EU VAT. Does VAT number validation & rates retrieval.
https://github.com/dannyvankooten/vat
Last synced: about 1 month ago
JSON representation
Go package for dealing with EU VAT. Does VAT number validation & rates retrieval.
- Host: GitHub
- URL: https://github.com/dannyvankooten/vat
- Owner: dannyvankooten
- License: mit
- Created: 2016-06-18T16:10:09.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-11-07T19:31:09.000Z (about 1 year ago)
- Last Synced: 2024-07-31T20:51:36.732Z (5 months ago)
- Language: Go
- Homepage:
- Size: 33.2 KB
- Stars: 111
- Watchers: 5
- Forks: 16
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - vat - VAT number validation & EU VAT rates. (Financial / Search and Analytic Databases)
- awesome-go - vat - Go package for dealing with EU VAT. Does VAT number validation & rates retrieval. - ★ 51 (Financial)
- awesome-go-extra - vat - 06-18T16:10:09Z|2022-01-26T08:12:34Z| (Financial / Advanced Console UIs)
README
Package vat
===[![Go Report Card](https://goreportcard.com/badge/github.com/dannyvankooten/vat)](https://goreportcard.com/report/github.com/dannyvankooten/vat)
[![GoDoc](https://godoc.org/github.com/dannyvankooten/vat?status.svg)](https://godoc.org/github.com/dannyvankooten/vat)
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/dannyvankooten/vat/master/LICENSE)Package for validating VAT numbers & retrieving VAT rates (from [ibericode/vat-rates](https://github.com/ibericode/vat-rates)) in Go.
## Installation
Use go get.
```
go get github.com/dannyvankooten/vat
```Then import the package into your own code.
```
import "github.com/dannyvankooten/vat"
```## Usage
### Validating VAT numbers
VAT numbers can be validated by format, existence or both. VAT numbers are looked up using the [VIES VAT validation API](http://ec.europa.eu/taxation_customs/vies/).
```go
package mainimport "github.com/dannyvankooten/vat"
func main() {
// Validate number by format + existence
validity, err := vat.ValidateNumber("NL123456789B01")// Validate number format
validity, err := vat.ValidateNumberFormat("NL123456789B01")// Validate number existence
validity, err := vat.ValidateNumberExistence("NL123456789B01")
}
```### Retrieving VAT rates
> This package relies on a [community maintained repository of vat rates](https://github.com/ibericode/vat-rates). We invite you to toggle notifications for that repository and contribute changes to VAT rates in your country once they are announced.
To get VAT rate periods for a country, first get a CountryRates struct using the country's ISO-3166-1-alpha2 code.
You can get the rate that is currently in effect using the `GetRate` function.
```go
package mainimport (
"fmt"
"github.com/dannyvankooten/vat"
)func main() {
c, err := vat.GetCountryRates("NL")
r, err := c.GetRate("standard")fmt.Printf("Standard VAT rate for NL is %.2f", r)
// Output: Standard VAT rate for NL is 21.00
}
```## License
MIT licensed. See the LICENSE file for details.