PHP code example of viddyoze-engineering / vat-calculator
1. Go to this page and download the library: Download viddyoze-engineering/vat-calculator 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/ */
viddyoze-engineering / vat-calculator example snippets
// Easy to use!
$countryCode = VatCalculator::getIPBasedCountry();
VatCalculator::calculate( 24.00, $countryCode );
VatCalculator::calculate( 24.00, $countryCode, $postalCode );
VatCalculator::calculate( 71.00, 'DE', '41352', $isCompany = true );
VatCalculator::getTaxRateForLocation( 'NL' );
// Check validity of a VAT number
VatCalculator::isValidVATNumber('NL123456789B01');
use Mpociot\VatCalculator\VatCalculator;
$vatCalculator = new VatCalculator();
$vatCalculator->setBusinessCountryCode('DE');
$countryCode = $vatCalculator->getIPBasedCountry();
$grossPrice = $vatCalculator->calculate( 49.99, 'LU' );
use Laravel\Cashier\Billable;
use Mpociot\VatCalculator\Traits\BillableWithinTheEU;
use Laravel\Cashier\Contracts\Billable as BillableContract;
class User extends Model implements BillableContract
{
use Billable, BillableWithinTheEU {
BillableWithinTheEU::taxPercentage insteadof Billable;
}
protected $dates = ['trial_ends_at', 'subscription_ends_at'];
}
$user = User::find(1);
// For individuals use:
$user->useTaxFrom('NL');
// For business customers with a valid VAT ID, use:
$user->useTaxFrom('NL')->asBusiness();
$user->subscription('monthly')->create($creditCardToken);