PHP code example of laudis / fiscal

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

    

laudis / fiscal example snippets


$repository = new \Laudis\Fiscal\FiscalRepository(new PDO(getenv('PDO_DSN'), getenv('USERNAME'), getenv('PASSWORD')));

// The date argument can either be a string in the Y-m-d format, an integer representing a timestamp, or an object implementing \DateTimeInterface.
$values = $repository->loadIndexedValuesWithSlugs('2010-01-01', ['cpi', 'euribor', 'protected-property-car-amount-AUS']);

$euribor = $values->get('euribor'); // Returns the euribor of that day
$cpi = $values->get('cpi'); // Throws OutOfBoundsException if it wasn't found for that day
$protected = $values->get('protected-property-car-amount-AUS', null); // Will return null instead of throwing when it wasn't found on that day.

$scale = $repository->loadScaleWithSlugs(DateTime::createFromFormat('Y-m-d', '2020-01-01'), ['personal-tax'])->first();

echo $scale->calculate(50000); // echos 13 250.00
echo $scale->calculate(8000); // echos 2000

$explanation = $scale->explain(50000);