This repository has been archived by the owner on Dec 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #470 from ronanguilloux/ronan2
+1 per-country VAT number, for at_AT
- Loading branch information
Showing
4 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace Faker\Provider\at_AT; | ||
|
||
/** | ||
* Class Payment | ||
* | ||
* @package Faker\Provider\at_AT | ||
*/ | ||
class Payment extends \Faker\Provider\Payment | ||
{ | ||
/** | ||
* Value Added Tax (VAT) | ||
* | ||
* @example 'ATU12345678', ('spaced') 'AT U12345678' | ||
* | ||
* @see http://ec.europa.eu/taxation_customs/vies/faq.html?locale=en#item_11 | ||
* @see http://www.iecomputersystems.com/ordering/eu_vat_numbers.htm | ||
* @see http://en.wikipedia.org/wiki/VAT_identification_number | ||
* | ||
* @param bool $spacedNationalPrefix | ||
* | ||
* @return string VAT Number | ||
*/ | ||
public static function vat($spacedNationalPrefix = true) | ||
{ | ||
$prefix = ($spacedNationalPrefix) ? "AT U" : "ATU"; | ||
|
||
return sprintf("%s%d", $prefix, self::randomNumber(8, true)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace Faker\Test\Provider\at_AT; | ||
|
||
use Faker\Generator; | ||
use Faker\Provider\at_AT\Payment; | ||
|
||
class PaymentTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
|
||
/** | ||
* @var Generator | ||
*/ | ||
private $faker; | ||
|
||
public function setUp() | ||
{ | ||
$faker = new Generator(); | ||
$faker->addProvider(new Payment($faker)); | ||
$this->faker = $faker; | ||
} | ||
|
||
public function testVatIsValid() | ||
{ | ||
$vat = $this->faker->vat(); | ||
$unspacedVat = $this->faker->vat(false); | ||
$this->assertRegExp('/^(AT U\d{8})$/', $vat); | ||
$this->assertRegExp('/^(ATU\d{8})$/', $unspacedVat); | ||
} | ||
} |