PHPackages                             pavkatar/tax - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. pavkatar/tax

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

pavkatar/tax
============

Tax library with a flexible data model, predefined tax rates, powerful resolving logic.

v0.8.7(5y ago)0313MITPHPPHP &gt;=5.5.0

Since Feb 7Pushed 3y agoCompare

[ Source](https://github.com/pavkatar/tax)[ Packagist](https://packagist.org/packages/pavkatar/tax)[ RSS](/packages/pavkatar-tax/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (13)Used By (0)

tax
===

[](#tax)

[![Build Status](https://camo.githubusercontent.com/fc7fe9b147bfdc80e4dc46ef531e5524239b95a6865d2835b2afd08da063acbc/68747470733a2f2f7472617669732d63692e6f72672f636f6d6d65726365677579732f7461782e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/commerceguys/tax)

A PHP 5.5+ tax management library.

Features:

- Smart data model designed for fluctuating tax rate amounts ("19% -&gt; 21% on January 1st")
- Predefined tax rates for EU countries and Switzerland. More to come.
- Tax resolvers with logic for all major use cases.

Requires [commerceguys/zone](https://github.com/commerceguys/zone).

The backstory behind the library design can be found in [this blog post](https://drupalcommerce.org/blog/31036/commerce-2x-stories-taxes).

Don't see your country's tax types and rates in the dataset? Send us a PR!

Data model
==========

[](#data-model)

[Zone](https://github.com/commerceguys/zone/blob/master/src/Model/ZoneInterface.php) 1-1 [TaxType](https://github.com/commerceguys/tax/blob/master/src/Model/TaxTypeInterface.php) 1-n [TaxRate](https://github.com/commerceguys/tax/blob/master/src/Model/TaxRateInterface.php) 1-n [TaxRateAmount](https://github.com/commerceguys/tax/blob/master/src/Model/TaxRateAmountInterface.php)

Each tax type has a zone and one or more tax rates. Each tax rate has one or more tax rate amounts.

Example:

- Tax type: French VAT
- Zone: "France (VAT)" (covers "France without Corsica" and "Monaco")
- Tax rates: Standard, Intermediate, Reduced, Super Reduced
- Tax rate amounts for Standard: 19.6% (until January 1st 2014), 20% (from January 1st 2014)

The base interfaces don't impose setters, since they aren't needed by the service classes. Extended interfaces ([TaxTypeEntityInterface](https://github.com/commerceguys/tax/blob/master/src/Model/TaxTypeEntityInterface.php), ([TaxRateEntityInterface](https://github.com/commerceguys/tax/blob/master/src/Model/TaxRateEntityInterface.php), ([TaxRateAmountEntityInterface](https://github.com/commerceguys/tax/blob/master/src/Model/TaxRateAmountEntityInterface.php)) are provided for that purpose, as well as matching [TaxType](https://github.com/commerceguys/tax/blob/master/src/Model/TaxType.php), [TaxRate](https://github.com/commerceguys/tax/blob/master/src/Model/TaxRate.php) and [TaxRateAmount](https://github.com/commerceguys/tax/blob/master/src/Model/TaxRateAmount.php) classes that can be used as examples or mapped by Doctrine.

Tax resolvers
=============

[](#tax-resolvers)

The process of finding the most suitable tax type/rate/amount for the given taxable object is called resolving. Along with the [Taxable object](https://github.com/commerceguys/tax/blob/master/src/TaxableInterface.php), a [Context object](https://github.com/commerceguys/tax/blob/master/src/Resolver/Context.php) containing customer and store information is also passed to the system.

Tax is resolved in three steps:

1. Resolve the tax types.
2. Resolve the tax rate for each resolved tax type.
3. Get the tax rate amount for each resolved tax rate (by calling `$rate->getAmount($date)`).

Tax types and tax rates are resolved by invoking registered resolvers (sorted by priority) until one of them returns a result.

Included tax type resolvers:

- [CanadaTaxTypeResolver](https://github.com/commerceguys/tax/blob/master/src/Resolver/TaxType/CanadaTaxTypeResolver.php) (Canada specific logic)

    The store charges the tax defined by the customer’s home province/territory.

    `If selling from a store in Quebec to a customer in Ontario, apply the Ontario HST.`
- [EuTaxTypeResolver](https://github.com/commerceguys/tax/blob/master/src/Resolver/TaxType/EuTaxTypeResolver.php) (EU specific logic)

    `A French store selling physical products (e.g. t-shirts) will charge French VAT to EU customers.`

    `A French store selling digital products (e.g. ebooks) from Jan 1st 2015 will apply the EU customer's tax rates (German customer - German VAT, etc)`

    `A French store will charge the 0% Intra-Community rate if the EU customer has provided a VAT number.`
- [DefaultTaxTypeResolver](https://github.com/commerceguys/tax/blob/master/src/Resolver/TaxType/DefaultTaxTypeResolver.php) (logic valid for most countries)

    If both the customer and the store belong to the same zone, returns the matched tax type.

    `The Serbian store is selling to a Serbian customer, use Serbian VAT.`

Included tax rate resolvers:

- [DefaultTaxRateResolver](https://github.com/commerceguys/tax/blob/master/src/Resolver/TaxRate/DefaultTaxRateResolver.php) - Returns a tax type's default tax rate.

Users would create a custom resolver for:

- "No tax in New York for t-shirts under 200$"
- "No tax for school supplies on september 1st (US tax holiday)"
- "Reduced rate for ebooks in France and other countries".
- "Return the tax type / rate referenced by the $taxable object" (explicit place of supply, e.g. "French company providing a training in Spain")

Usage example:

```
use CommerceGuys\Tax\Repository\TaxTypeRepository;
use CommerceGuys\Tax\Resolver\TaxType\ChainTaxTypeResolver;
use CommerceGuys\Tax\Resolver\TaxType\CanadaTaxTypeResolver;
use CommerceGuys\Tax\Resolver\TaxType\EuTaxTypeResolver;
use CommerceGuys\Tax\Resolver\TaxType\DefaultTaxTypeResolver;
use CommerceGuys\Tax\Resolver\TaxRate\ChainTaxRateResolver;
use CommerceGuys\Tax\Resolver\TaxRate\DefaultTaxRateResolver;
use CommerceGuys\Tax\Resolver\TaxResolver;

// The repository, and the resolvers are usualy initialized by the
// container, this is just a verbose example.
$taxTypeRepository = new TaxTypeRepository();
$chainTaxTypeResolver = new ChainTaxTypeResolver();
$chainTaxTypeResolver->addResolver(new CanadaTaxTypeResolver($taxTypeRepository));
$chainTaxTypeResolver->addResolver(new EuTaxTypeResolver($taxTypeRepository));
$chainTaxTypeResolver->addResolver(new DefaultTaxTypeResolver($taxTypeRepository));
$chainTaxRateResolver = new ChainTaxRateResolver();
$chainTaxRateResolver->addResolver(new DefaultTaxRateResolver());
$resolver = new TaxResolver($chainTaxTypeResolver, $chainTaxRateResolver);

// You can also provide the customer's tax number (e.g. VAT number needed
// to trigger Intra-Community supply rules in EU), list of additional countries
// where the store is registered to collect tax, a different calculation date.
$context = new Context($customerAddress, $storeAddress);

$amounts = $resolver->resolveAmounts($taxable, $context);
// More rarely, if only the types or rates are needed:
$rates = $resolver->resolveRates($taxable, $context);
$types = $resolver->resolveTypes($taxable, $context);
```

Credits
=======

[](#credits)

- [Source for EU data](http://ec.europa.eu/taxation_customs/sites/taxation/files/resources/documents/taxation/vat/how_vat_works/rates/vat_rates_en.pdf)

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 63.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~202 days

Recently: every ~68 days

Total

12

Last Release

1880d ago

PHP version history (2 changes)v0.5PHP &gt;=5.4.0

v0.8PHP &gt;=5.5.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/bff9b29b16c0843e6119b393fbe29e6be567c6c9bb06dd0f41a4681a246c6e39?d=identicon)[pavkatar](/maintainers/pavkatar)

---

Top Contributors

[![bojanz](https://avatars.githubusercontent.com/u/330162?v=4)](https://github.com/bojanz "bojanz (90 commits)")[![dwkitchen](https://avatars.githubusercontent.com/u/1096557?v=4)](https://github.com/dwkitchen "dwkitchen (17 commits)")[![brettflorio](https://avatars.githubusercontent.com/u/34131?v=4)](https://github.com/brettflorio "brettflorio (5 commits)")[![dmnc](https://avatars.githubusercontent.com/u/144790?v=4)](https://github.com/dmnc "dmnc (5 commits)")[![bgandon](https://avatars.githubusercontent.com/u/3900563?v=4)](https://github.com/bgandon "bgandon (4 commits)")[![el-seirh](https://avatars.githubusercontent.com/u/2971625?v=4)](https://github.com/el-seirh "el-seirh (4 commits)")[![Iandenh](https://avatars.githubusercontent.com/u/2911923?v=4)](https://github.com/Iandenh "Iandenh (2 commits)")[![pavkatar](https://avatars.githubusercontent.com/u/259746?v=4)](https://github.com/pavkatar "pavkatar (2 commits)")[![pjcarly](https://avatars.githubusercontent.com/u/2808694?v=4)](https://github.com/pjcarly "pjcarly (1 commits)")[![rquadling](https://avatars.githubusercontent.com/u/12801?v=4)](https://github.com/rquadling "rquadling (1 commits)")[![schtr4jh](https://avatars.githubusercontent.com/u/385801?v=4)](https://github.com/schtr4jh "schtr4jh (1 commits)")[![sparkos72](https://avatars.githubusercontent.com/u/10269598?v=4)](https://github.com/sparkos72 "sparkos72 (1 commits)")[![AndyD328](https://avatars.githubusercontent.com/u/11844373?v=4)](https://github.com/AndyD328 "AndyD328 (1 commits)")[![vasike](https://avatars.githubusercontent.com/u/514846?v=4)](https://github.com/vasike "vasike (1 commits)")[![Archanium](https://avatars.githubusercontent.com/u/295426?v=4)](https://github.com/Archanium "Archanium (1 commits)")[![dariuszz123](https://avatars.githubusercontent.com/u/2358146?v=4)](https://github.com/dariuszz123 "dariuszz123 (1 commits)")[![jnicola](https://avatars.githubusercontent.com/u/669333?v=4)](https://github.com/jnicola "jnicola (1 commits)")[![JulienD](https://avatars.githubusercontent.com/u/408389?v=4)](https://github.com/JulienD "JulienD (1 commits)")[![magnusnordlander](https://avatars.githubusercontent.com/u/165002?v=4)](https://github.com/magnusnordlander "magnusnordlander (1 commits)")[![magudb](https://avatars.githubusercontent.com/u/1316630?v=4)](https://github.com/magudb "magudb (1 commits)")

---

Tags

vattax

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/pavkatar-tax/health.svg)

```
[![Health](https://phpackages.com/badges/pavkatar-tax/health.svg)](https://phpackages.com/packages/pavkatar-tax)
```

###  Alternatives

[commerceguys/tax

Tax library with a flexible data model, predefined tax rates, powerful resolving logic.

286763.3k](/packages/commerceguys-tax)[mpociot/vat-calculator

EU VAT calculation, the way it should be.

1.3k3.9M18](/packages/mpociot-vat-calculator)[ibericode/vat-bundle

Bundle for using ibericode/vat in a Symfony environment

21254.5k](/packages/ibericode-vat-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
