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

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

feimx/tax
=========

This Package allow calculate Tax to an amount

1.1.3(8y ago)31542MITPHPPHP ^7.1

Since Mar 15Pushed 8y ago1 watchersCompare

[ Source](https://github.com/feimx/tax)[ Packagist](https://packagist.org/packages/feimx/tax)[ Docs](https://github.com/feimx/tax)[ RSS](/packages/feimx-tax/feed)WikiDiscussions master Synced yesterday

READMEChangelog (2)Dependencies (5)Versions (6)Used By (0)

Calculate taxes for a given amount
==================================

[](#calculate-taxes-for-a-given-amount)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d633eddcc83dc5e576e281e3f686b8bc8ad8f8bc62ca5e1ae465fc121c7200da/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6665696d782f7461782e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/feimx/tax)[![Build Status](https://camo.githubusercontent.com/85e222f27282d622fb6ba3385c9e02b18f976c7b2e2a07fa3bba8001ef9aae16/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6665696d782f7461782f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/feimx/tax)[![Quality Score](https://camo.githubusercontent.com/113983d1c58a99dbf61dab29825f872af0aba1017340b883987096e5ec7297a0/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6665696d782f7461782e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/feimx/tax)[![Total Downloads](https://camo.githubusercontent.com/ba00750f6e2343c70bbb383fc1f177f22a41a28258eee1c3756bef58752f4438/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6665696d782f7461782e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/feimx/tax)

The `feimx/tax` package provide a simple way for calculate taxes of an amount.

Basic Usage
-----------

[](#basic-usage)

```
$taxManager = new FeiMx\Tax\TaxManager($amount = 100);
$taxManager->addTax('iva');
echo $taxManager->total(); // 116.000000
```

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require feimx/tax
```

```
// config/app.php
'providers' => [
    FeiMx\Tax\TaxServiceProvider::class,
];
```

*Note:* If your Laravel versions is `>=5.5` you don't need register providers.

*Note:* This is not necesary if you are not using Laravel

You can optionally publish the config file with:

```
php artisan vendor:publish --provider="FeiMx\Tax\TaxServiceProvider" --tag="config"
```

This is the contents of the published config file:

```
return [
    /**
     * Used The fallback type determines the type to use when the current one
     * is not available. You may change the value to correspond to any of
     * provided types
     */
    'fallback' => 'default',
    /**
     * List of taxes with their types ans percentages
     * You can add more types and percentages.
     */
    'taxes' => [
        'iva' => [
            'default' => 0.16,
            'retention' => -0.106667,
        ],
        'isr' => [
            'default' => -0.106667,
        ],
        'ieps' => [
            'default' => 0.08,
            'retention' => -0.08,
            'primary' => 0.11,
            'secondary' => 0.13,
        ],
    ],
];
```

*Note:* This is not necesary if you are not using Laravel

You can optionally publish the migrations file with:

```
php artisan vendor:publish --provider="FeiMx\Tax\TaxServiceProvider" --tag="migrations"
```

*Note:* This is not necesary if you are not using Laravel

Usage
-----

[](#usage)

Firt need create a new instance of `TaxManager`:

```
$taxManager = new FeiMx\Tax\TaxManager($amount = 100);
```

Second you need to add the taxes for calculate the final amount: The first parameter could be a tax name `['iva', 'ieps', 'isr']` or an instance of `FeiMx\Tax\Contracts\TaxContract`. Exist 3 Tax Objects:

```
$iva = new \FeiMx\Tax\Taxes\IVA($retention = false);
$isr = new \FeiMx\Tax\Taxes\ISR($retention = false);
$ieps = new \FeiMx\Tax\Taxes\IEPS($retention = false);

$taxManager->addTax($tax = 'iva', $retention = false);
$taxManager->addTax($iva);
```

*Note:* You can pass a string for a tax type of given config file instead the retention boolean param.

```
$iva = new \FeiMx\Tax\Taxes\IVA('free');
$taxManager->addTax($tax = 'iva', 'free');
```

You can add multiple taxes at once:

```
$taxManager->addTaxes([
    'iva', $isr, $ieps,
]);
```

Now you can get the final amount:

```
$taxManager->total();
// or
$taxManager->total;
```

You can get a list for given data:

```
$taxManager->get();
```

This is the contents of get method:

```
[
    'amount' => 100,
    'total' => '105.333300',
    'taxes' => [
        [
            'tax' => 'iva',
            'amount' => '16.000000',
        ],
        [
            'tax' => 'isr',
            'amount' => '-10.666700',
        ],
    ],
];
```

Models
------

[](#models)

You can assign Taxable trait to your models.

```
use FeiMx\Tax\Traits\Taxable;

class Product extends Model
{
    use Taxable;

    protected $fillable = ['price'];
}
```

You can assign tax groups to your model:

```
$product = Product::first();
$taxGroup = \FeiMx\Tax\Models\TaxGroup::first();

$product->assignTaxGroup($taxGroup);
```

You can pass a name and multiples tax groups:

```
$product->assignTaxGroup('iva');
$product->assignTaxGroup('iva', 'isr');
$product->assignTaxGroup(['iva', 'isr']);
$product->assignTaxGroup(collect(['iva', $taxGroup]));
```

You can sync too:

```
$product->syncTaxGroups('iva');
$product->syncTaxGroups('iva', 'isr');
$product->syncTaxGroups(['iva', 'isr']);
```

And you can remove:

```
$product->removeTaxGroup('iva');
$product->removeTaxGroup($taxGroup);
```

You can verify if a model has a TaxGroup:

```
$product->hasTaxGroup('iva');
$product->hasTaxGroup($taxGroup);
$product->hasTaxGroup([$taxGroup, 'iva']);
```

For get the total amount after taxes, must need to know what column use, for defaul we use `price` column, but you can use another one:

```
class Product extends Model
{
    use Taxable;

    protected $fillable = ['price'];

    public static function priceColumn()
    {
        return 'price';
    }
}
```

Now you can get the total of a given TaxGroup:

```
$product->total($taxGroup);
```

And you can obtain the content of the get method of the TaxManager:

```
$product->getAmounts($taxGroup);
```

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Jorge Andrade](https://github.com/Yorchi)
- [All Contributors](../../contributors)

Support us
----------

[](#support-us)

FEI is a Digital Invoicing startup based in Yucatán, México. You'll find an overview of all our open source projects [on our website](https://fei.com.mx/opensource).

Does your business depend on our contributions? Reach out and support us on [Patreon](https://www.patreon.com/jorge_andrade). All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~11 days

Total

4

Last Release

2996d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5d0f7ef298a8212f962af789337d790ba61cf2d849609c66618ec86ad2422bb7?d=identicon)[Yorchi](/maintainers/Yorchi)

---

Top Contributors

[![Yorchi](https://avatars.githubusercontent.com/u/4969895?v=4)](https://github.com/Yorchi "Yorchi (25 commits)")

---

Tags

cfdicfdi-3-3cfdi-mexicoiepsisrivalaravelmexicophptaxfacturacion-electronicacfdiivafeimxisrieps

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[flarum/core

Delightfully simple forum software.

201.4M2.2k](/packages/flarum-core)[erlandmuchasaj/laravel-gzip

Gzip your responses.

40140.4k2](/packages/erlandmuchasaj-laravel-gzip)

PHPackages © 2026

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