Download the PHP package jakubjachym/vat-calculator without Composer

On this page you can find all versions of the php package jakubjachym/vat-calculator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package vat-calculator

VatCalculator

PHP Tests

Handle all the hard stuff related to EU MOSS tax/vat regulations, the way it should be. This is a revived fork of spaze/vat-calculator which was a "modernized" fork of mpociot/vat-calculator without Laravel/Cashier support, with some new features, that requires PHP 7.3+.

Contents

Installation

In order to install the VAT Calculator, just run

Standalone

This package is designed for standalone usage. Simply create a new instance of the VAT calculator and use it.

Example:

Usage

Calculate the gross price

To calculate the gross price (price with VAT added) use the calculate method with a net price, a country code, a postal code (null if unknown) and whether you're calculating VAT for a customer that's a company as parameters.

The third parameter is the postal code of the customer, pass null if unknown.

As a fourth parameter, you can pass in a boolean indicating whether the customer is a company or a private person. If the customer is a company, which you should check by validating the VAT number, the net price gets returned.

Fifth optional parameter defines which VAT rate to use if there are more defined for the particular country (VatRates::HIGH, VatRates::LOW, VatRates::GENERAL is the default when just one rate is defined).

The sixth parameter, optional, specifies the date to use the VAT rate for. This is needed when a country changes its VAT rate and you want to calculate a price with the previous rate. Pass DateTime or DateTimeImmutable object. Current date used when not specified.

Returns VatPrice object:

Validate EU VAT numbers

Prior to validating your customers VAT numbers, you can use the shouldCollectVat method to check if the country code requires you to collect VAT in the first place. This method will return true even for non-EU countries added manually with addRateForCountry (see below).

To ignore those manually added non-EU countries and return true only for EU member states, you can use shouldCollectEuVat.

To validate your customers VAT numbers, you can use the isValidVatNumber method. The VAT number should be in a format specified by the VIES. The given VAT numbers will be truncated and non relevant characters (-, ., ,, whitespace) will automatically be removed. If there are any invalid characters left, like non-latin letters for example, InvalidCharsInVatNumberException will be thrown.

This service relies on a third party SOAP API provided by the EU. If, for whatever reason, this API is unavailable a VatCheckUnavailableException will be thrown.

If a VAT number from an unsupported/non-EU country is provided, UnsupportedCountryException will be thrown.

Get EU VAT number details

To get the details of a VAT number, you can use the getVatDetails method. The VAT number should be in a format specified by the VIES. The given VAT numbers will be truncated and non relevant characters / whitespace will automatically be removed.

This service relies on a third party SOAP API provided by the EU. If, for whatever reason, this API is unavailable a VatCheckUnavailableException will be thrown.

If a VAT number from an unsupported/non-EU country is provided, UnsupportedCountryException will be thrown.

Get all known rates for a country

Get all known rates (current, high & low, historical & future, exceptions) for a country by:

The returned array of rates is unsorted. This method can be useful when you want to prefill a selectbox with known VAT rates for a country for example, or when you want to validate user-provided rates.

Countries

EU countries are supported as well as some non-EU countries that use VAT. Some countries are not supported even though they also have VAT. Currently, that's the case for the following countries:

These can be added manually with VatRates::addRateForCountry():

Please keep in mind that with these countries you cannot validate VAT ids with isValidVatNumber() because it uses VIES, the EU VAT number validation service, and as these countries are not part of the EU, it will always come back as invalid.

License

This library is licensed under the MIT license. Please see License file for more information.

Contributing

Run PHPUnit tests and static analysis with composer test, see scripts in composer.json. Tests are also run on GitHub with Actions on each push.

Disclaimer

While this repository tries to provide up-to-date VAT rates, it is possible that it will fail to do so. Please keep in mind that author cannot be held responsible for any damage done to you or anyone for using this repository. It is your responsibility to check that used VAT rate is valid.


All versions of vat-calculator with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3 || ^8.0
ext-soap Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package jakubjachym/vat-calculator contains the following files

Loading the files please wait ....