Skip to content

Commit 2424d07

Browse files
authored
Update VatCalculator.php (#182)
* Update VatCalculator.php Added a method to return all tax rates for a given country code * Update README.md Updated with the 'getTaxRatesForCountry' method
1 parent a294d9b commit 2424d07

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ $netPrice = VatCalculator::getNetPrice(); // 24.00
8787
$taxValue = VatCalculator::getTaxValue(); // 4.56
8888
```
8989

90+
### Receive all tax rates for a given country
91+
92+
To receive an array with all available tax rates for a given country, use the `getTaxRatesForCountry` method.
93+
94+
```php
95+
VatCalculator::getTaxRatesForCountry('DE'); // ["high" => 0.19, "low" => 0.07]
96+
```
97+
9098
### Validate EU VAT numbers
9199

92100
Prior to validating your customers VAT numbers, you can use the `shouldCollectVAT` method to check if the country code requires you to collect VAT

src/VatCalculator.php

+11
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,17 @@ public function getTaxRateForCountry($countryCode, $company = false, $type = nul
728728
return $this->getTaxRateForLocation($countryCode, '', $company, $type);
729729
}
730730

731+
/**
732+
* Returns all tax rates for the given country code.
733+
*
734+
* @param string $countryCode
735+
* @return array
736+
*/
737+
public function getTaxRatesForCountry($countryCode)
738+
{
739+
return $this->taxRules[$countryCode]['rates'];
740+
}
741+
731742
/**
732743
* Returns the tax rate for the given country code.
733744
* If a postal code is provided, it will try to lookup the different

0 commit comments

Comments
 (0)