1. Go to this page and download the library: Download cboxdk/laravel-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/ */
cboxdk / laravel-tax example snippets
use Cbox\Tax\Contracts\TaxCalculator;
use Cbox\Tax\ValueObjects\TaxQuery;
use Cbox\Tax\ValueObjects\SellerRegistrations;
use Cbox\Tax\Enums\{CustomerType, Pricing};
use Cbox\Geo\ValueObjects\CountryCode;
use Brick\Money\Money;
$assessment = app(TaxCalculator::class)->assess(new TaxQuery(
amount: Money::of('100.00', 'EUR'),
pricing: Pricing::Exclusive,
place: $geo->find(new CountryCode('FR')), // buyer jurisdiction (from laravel-geo)
customer: CustomerType::Business,
seller: new SellerRegistrations(new CountryCode('DE')),
customerTaxIdValidated: true, // VIES-validated
));
$assessment->treatment; // TaxTreatment::ReverseCharge — intra-EU B2B, buyer self-accounts
$assessment->tax; // Money 0.00 EUR
$assessment->reason; // human-readable explanation for the audit trail
$assessment = app(OrderTaxCalculator::class)->assessOrder(new TaxOrder(
place: $geo->find(new CountryCode('DK')),
customer: CustomerType::Consumer,
seller: new SellerRegistrations(new CountryCode('DK')),
pricing: Pricing::Exclusive,
lines: [
new SupplyLine('subscription', Money::of('100.00', 'DKK'), TaxCategory::DigitalService),
new SupplyLine('usage', Money::of('37.50', 'DKK'), TaxCategory::DigitalService),
new SupplyLine('onboarding', Money::of('2500.00','DKK'), TaxCategory::ServicesProfessional),
],
));
$assessment->tax(); // summed from the rounded lines, never recomputed
$assessment->forLine('usage'); // that line's own assessment
$assessment->taxByAuthority(); // per-jurisdiction totals for remittance, or null
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.