diff --git a/src/VatCalculator.php b/src/VatCalculator.php index 0acf51b..c82b302 100644 --- a/src/VatCalculator.php +++ b/src/VatCalculator.php @@ -449,12 +449,12 @@ class VatCalculator ], 'PT' => [ [ - 'postalCode' => '/^9[0-4]\d{2,}$/', + 'postalCode' => '/^9[0-4]\d{2,}(?:-\d+)*$/', 'code' => 'PT', 'name' => 'Madeira', ], [ - 'postalCode' => '/^9[5-9]\d{2,}$/', + 'postalCode' => '/^9[5-9]\d{2,}(?:-\d+)*$/', 'code' => 'PT', 'name' => 'Azores', ], diff --git a/tests/VatCalculatorTest.php b/tests/VatCalculatorTest.php index cb51bcb..c252ba8 100644 --- a/tests/VatCalculatorTest.php +++ b/tests/VatCalculatorTest.php @@ -540,6 +540,12 @@ public function testChecksPostalCodeForVATExceptions() $this->assertEquals(29.28, $result); $this->assertEquals(0.22, $vatCalculator->getTaxRate()); $this->assertEquals(5.28, $vatCalculator->getTaxValue()); + + $postalCode = '9500-339'; // Azores + $result = $vatCalculator->calculate($net, 'PT', $postalCode, false); + $this->assertEquals(27.84, $result); + $this->assertEquals(0.16, $vatCalculator->getTaxRate()); + $this->assertEquals(3.84, $vatCalculator->getTaxValue()); } public function testPostalCodesWithoutExceptionsGetStandardRate()