PHPackages                             shankarthiyagaraajan/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. shankarthiyagaraajan/tax

ActiveLibrary

shankarthiyagaraajan/tax
========================

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

v0.7.1(10y ago)09MITPHPPHP &gt;=5.4.0CI failing

Since Feb 7Pushed 10y ago1 watchersCompare

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

READMEChangelogDependencies (7)Versions (4)Used By (0)

tax
===

[](#tax)

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

A PHP 5.4+ 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/resources/documents/taxation/vat/how_vat_works/rates/vat_rates_en.pdf)

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 71% 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 ~97 days

Total

4

Last Release

3821d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/310342f019559d8ee139f94cfbbcb0c83fc577c6cda3ec3373ee7ba81314f32c?d=identicon)[shankarthiyagaraajan](/maintainers/shankarthiyagaraajan)

---

Top Contributors

[![bojanz](https://avatars.githubusercontent.com/u/330162?v=4)](https://github.com/bojanz "bojanz (76 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 (4 commits)")[![bgandon](https://avatars.githubusercontent.com/u/3900563?v=4)](https://github.com/bgandon "bgandon (4 commits)")[![magnusnordlander](https://avatars.githubusercontent.com/u/165002?v=4)](https://github.com/magnusnordlander "magnusnordlander (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)")[![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)")

---

Tags

vattax

###  Code Quality

TestsPHPUnit

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/shankarthiyagaraajan-tax/health.svg)](https://phpackages.com/packages/shankarthiyagaraajan-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)[ddeboer/vatin

Validate VAT identification numbers

1413.0M9](/packages/ddeboer-vatin)[ddeboer/vatin-bundle

Symfony bundle for the VATIN library

29884.1k](/packages/ddeboer-vatin-bundle)[sylius/taxation

Flexible taxation system for PHP ecommerce applications.

11385.3k7](/packages/sylius-taxation)[taxamo/taxamo-php

Taxamo PHP Library

11119.2k](/packages/taxamo-taxamo-php)

PHPackages © 2026

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