Download the PHP package fidelo-software/vatrates without Composer
On this page you can find all versions of the php package fidelo-software/vatrates. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fidelo-software/vatrates
More information about fidelo-software/vatrates
Files in fidelo-software/vatrates
Package vatrates
Short Description Up-to-date European VAT Rates
License MIT
Homepage https://vatrates.fidelo.com
Informations about the package vatrates
VATRates
Up-to-date European VAT Rates
VAT rates stored in JSON
format, with PHP classes for easy access.
Install
Download
- vatrates.min.js minified
- vatrates.js un-minified
CDN
NPM
Composer
For the PHP package:
Javascript
Require vatrates or use a script tag to include vatrates.js:
An instance created with new VATRates()
gives you several VAT rate functions. It's recommended to always use an isVATCountry()
check before using them, like this:
Default rates are for today, to get rates for a different day pass in a Date
:
You can also change the date by calling setDate()
on a previously created instance:
getCountry(countryCode)
Another approach is to use getCountry()
, it returns a VATCountry
or undefined
if the country doesn't use VAT. With a VATCountry you'll have all the VAT rate functions and some extra helpers.
The United Kingdom and Greece use extra non standard country codes "UK" and "EL", these are also accepted.
getCountries()
Returns an Array
of all the countries using VAT, as VATCountry
's.
setDate(date)
Set the Date
for which to return VAT rates.
This is identical to:
All other functions take this date into account, so make sure to always set the date first.
isVATCountry(countryCode)
Returns true
if a country uses VAT, or false
if not.
getSuperReducedRate(countryCode)
Returns the super reduced rate for a country, or undefined
when none is available.
A VATCountry
returned by getCountry()
offers this method directly.
getReducedRates(countryCode)
Returns an Array
of reduced rates for a country, or undefined
when none are available.
A VATCountry
offers this method directly.
getStandardRate(countryCode)
Returns the standard rate for a country, or undefined
when none is available.
A VATCountry
offers this method directly.
getParkingRate(countryCode)
Returns the parking rate for a country, or undefined
when none is available.
A VATCountry
offers this method directly.
PHP
After installing through Composer use Staaky\VATRates\VATRates
An instance created with new VATRates()
gives you several VAT rate functions. It's recommended to always use an isVATCountry()
check before using them, like this:
Default rates are for today, to get rates for a different day pass in a DateTime
:
You can also change the date by calling setDate()
on a previously created instance:
getCountry(countryCode)
Another approach is to use getCountry()
, it returns a VATCountry
or null
if the country doesn't use VAT. With a VATCountry
you'll have all the VAT rate functions and some extra helpers.
The United Kingdom and Greece use extra non standard country codes "UK" and "EL", these are also accepted.
getCountries()
Returns an array
of all the countries using VAT, as VATCountry
's.
setDate(DateTime $date)
Set the date for which to return VAT rates.
This is identical to:
All other functions take this date into account, so make sure to always set the date first.
isVATCountry($countryCode)
Returns true
if a country uses VAT, or false
if not.
getSuperReducedRate($countryCode)
Returns the super reduced rate for a country, or null
if none is available.
A VATCountry
returned by getCountry()
offers this method directly.
getReducedRates($countryCode)
Returns an array
of reduced rates for a country, or null
if none are available.
A VATCountry
offers this method directly.
getStandardRate($countryCode)
Returns the standard rate for a country, or null
when none is available.
A VATCountry
offers this method directly.
getParkingRate($countryCode)
Returns the parking rate for a country, or null
when none is available.
A VATCountry
offers this method directly.
Development
Webpack
Use webpack
to create a new build after you've made changes.
Gulp
Use gulp
to load up the page in the /example
folder. It shows the output of all files (Javascript, JSON & PHP) and automatically rebuilds with webpack as you modify source code.
Unit Tests
Run unit tests using npm test
, this runs tests for every language.
Javascript tests are run with Mocha and PHP tests with Peridot. They can be run individually as well:
Contribute
VAT rates are kept up to date manually using data from the European Commission and VATLive.com. Initial historic rates are based on data from jsonvat.com.
If you notice an incorrect rate please create an issue or send a pull request. Future VAT changes can also be added to the JSON
file. If you know of an upcoming change that isn't listed yet, please let me know.
Data on historic VAT rates is also appreciated. This can be hard to track down, especially the non-standard rates.
License
VATRates is MIT Licensed