PHP code example of feimx / tax

1. Go to this page and download the library: Download feimx/tax library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

feimx / tax example snippets


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

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,
        ],
    ],
];
 php
$taxManager = new FeiMx\Tax\TaxManager($amount = 100);
$taxManager->addTax('iva');
echo $taxManager->total(); // 116.000000
bash
php artisan vendor:publish --provider="FeiMx\Tax\TaxServiceProvider" --tag="config"
bash
php artisan vendor:publish --provider="FeiMx\Tax\TaxServiceProvider" --tag="migrations"
 php
$taxManager = new FeiMx\Tax\TaxManager($amount = 100);
 php
$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);
 php
$iva = new \FeiMx\Tax\Taxes\IVA('free');
$taxManager->addTax($tax = 'iva', 'free');
 php
$taxManager->addTaxes([
    'iva', $isr, $ieps,
]);
 php
$taxManager->total();
// or
$taxManager->total;
 php
$taxManager->get();
 php
[
    'amount' => 100,
    'total' => '105.333300',
    'taxes' => [
        [
            'tax' => 'iva',
            'amount' => '16.000000',
        ],
        [
            'tax' => 'isr',
            'amount' => '-10.666700',
        ],
    ],
];
 php
$product->assignTaxGroup('iva');
$product->assignTaxGroup('iva', 'isr');
$product->assignTaxGroup(['iva', 'isr']);
$product->assignTaxGroup(collect(['iva', $taxGroup]));
 php
$product->syncTaxGroups('iva');
$product->syncTaxGroups('iva', 'isr');
$product->syncTaxGroups(['iva', 'isr']);
 php
$product->removeTaxGroup('iva');
$product->removeTaxGroup($taxGroup);
 php
$product->hasTaxGroup('iva');
$product->hasTaxGroup($taxGroup);
$product->hasTaxGroup([$taxGroup, 'iva']);
 php
$product->total($taxGroup);
 php
$product->getAmounts($taxGroup);