PHP code example of omaralalwi / laravel-taxify

1. Go to this page and download the library: Download omaralalwi/laravel-taxify 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/ */

    

omaralalwi / laravel-taxify example snippets


php artisan vendor:publish --tag=laravel-taxify-config

$amount = 250;
$taxAmount = calculateTax($amount,'profileName')->tax_amount; // 37.5

$amount = 250;
$tax = calculateTax($amount,'profileName');

 $tax = {
    "amount_with_tax": 287.5,
    "tax_amount": 37.5,
    "tax_rate": 0.15,
  }

// you can pass number as float or integer
$productAmount = 250;
$featureAmount = 70.5;
$warrantyAmount = 30.60;
$chargeAmount = 90;

$tax = calculateTaxForCollection([$productAmount,$featureAmount, $warrantyAmount, $chargeAmount]);

$tax = {
    "amount_with_tax": 507.265,
    "tax_amount": 66.165,
    "tax_rate": 0.15,
  }

$taxAmount = $tax->tax_amount // 66.165

$amount = 250;
getTaxAmount($amount); // Result 25

getTaxRate()
// Result 0.15

getTaxRate('sales') // fore specific profile
// Result 50 , here the result is fixed number because the profile type is fixed amount Not percentage

getTaxType('profileName')
// Result: fixed or percentage // depend on profile settings
 
getTaxRateAsPercentage();  // Result '10.00%'
bash
php artisan test --filter TaxifyTest