Skip to content

Commit

Permalink
Update postal code exceptions for Portugal (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
toyi authored May 14, 2024
1 parent 1e7ad12 commit d678f79
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/VatCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
Expand Down
6 changes: 6 additions & 0 deletions tests/VatCalculatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit d678f79

Please sign in to comment.