Skip to content

Commit

Permalink
Update VatCalculator.php (#182)
Browse files Browse the repository at this point in the history
* Update VatCalculator.php

Added a method to return all tax rates for a given country code

* Update README.md

Updated with the 'getTaxRatesForCountry' method
  • Loading branch information
DonCamillo11 authored Nov 21, 2024
1 parent a294d9b commit 2424d07
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ $netPrice = VatCalculator::getNetPrice(); // 24.00
$taxValue = VatCalculator::getTaxValue(); // 4.56
```

### Receive all tax rates for a given country

To receive an array with all available tax rates for a given country, use the `getTaxRatesForCountry` method.

```php
VatCalculator::getTaxRatesForCountry('DE'); // ["high" => 0.19, "low" => 0.07]
```

### Validate EU VAT numbers

Prior to validating your customers VAT numbers, you can use the `shouldCollectVAT` method to check if the country code requires you to collect VAT
Expand Down
11 changes: 11 additions & 0 deletions src/VatCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,17 @@ public function getTaxRateForCountry($countryCode, $company = false, $type = nul
return $this->getTaxRateForLocation($countryCode, '', $company, $type);
}

/**
* Returns all tax rates for the given country code.
*
* @param string $countryCode
* @return array
*/
public function getTaxRatesForCountry($countryCode)
{
return $this->taxRules[$countryCode]['rates'];
}

/**
* Returns the tax rate for the given country code.
* If a postal code is provided, it will try to lookup the different
Expand Down

0 comments on commit 2424d07

Please sign in to comment.