kusabi/tax

A library for calculating tax in PHP

1.0.1 2021-06-27 12:42 UTC

This package is auto-updated.

Last update: 2024-04-27 19:16:37 UTC


README

Tests codecov Licence Badge Release Badge Tag Badge Issues Badge Code Size

A library for calculating tax in PHP

Compatibility and dependencies

This library is compatible with PHP version 5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0 and 8.1.

This library has no dependencies.

Installation

Installation is simple using composer.

composer require kusabi/tax

Or simply add it to your composer.json file

{
    "require": {
        "kusabi/tax": "^1.0"
    }
}

PHPBench Benchmark Results

Below are the latest benchmark results taken on my local machine for PHP 5.4.

benchmark subject mean diff
TaxBench benchTaxFromNet 1.026μs 0.00%
TaxBench benchGrossFromNet 1.053μs +2.58%
TaxBench benchNetFromTax 1.084μs +5.57%
TaxBench benchGrossFromTax 1.086μs +5.77%
TaxBench benchTaxFromGross 1.091μs +6.29%
TaxBench benchNetFromGross 1.098μs +6.94%
TaxBench benchRateFromNetAndTax 1.228μs +19.64%
TaxBench benchRateFromGrossAndTax 1.275μs +24.25%
TaxBench benchRateFromNetAndGross 1.279μs +24.60%

Functions

This library adds a number of functions to calculate tax.

Below you can find links to the documentation for the new features.

Function Description
gross_from_net Calculate the gross amount from the net amount and tax rate
gross_from_tax Calculate the gross amount from the tax amount and tax rate
net_from_gross Calculate the net amount from the gross amount and tax rate
net_from_tax Calculate the net amount from the tax amount and tax rate
rate_from_gross_and_tax Calculate the tax rate from the gross amount and tax amount
rate_from_net_and_gross Calculate the tax rate from the net amount and gross amount
rate_from_net_and_tax Calculate the tax rate from the net amount and tax amount
tax_from_gross Calculate the tax amount from the gross amount and tax rate
tax_from_net Calculate the tax amount from the net amount and tax rate