From 7ae607cdf0e0f3683c7ffbeec35125921d5e2b1c Mon Sep 17 00:00:00 2001 From: Laurens Laman Date: Tue, 22 Mar 2016 23:57:24 +0100 Subject: [PATCH 1/3] Added Dutch BTW (vat) Number Added tests --- src/Faker/Provider/nl_NL/Company.php | 24 ++++++++++++++++ test/Faker/Provider/nl_NL/CompanyTest.php | 34 +++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 test/Faker/Provider/nl_NL/CompanyTest.php diff --git a/src/Faker/Provider/nl_NL/Company.php b/src/Faker/Provider/nl_NL/Company.php index 2eeb93ea98..2a3356c904 100644 --- a/src/Faker/Provider/nl_NL/Company.php +++ b/src/Faker/Provider/nl_NL/Company.php @@ -12,4 +12,28 @@ class Company extends \Faker\Provider\Company ); protected static $companySuffix = array('VOF', 'CV', 'LLP', 'BV', 'NV', 'IBC', 'CSL', 'EESV', 'SE', 'CV', 'Stichting', '& Zonen', '& Zn'); + + /** + * Belasting Toegevoegde Waarde (BTW) = VAT + * + * @example 'NL123456789B01' + * + * @see (dutch) http://www.belastingdienst.nl/wps/wcm/connect/bldcontentnl/belastingdienst/zakelijk/btw/administratie_bijhouden/btw_nummers_controleren/uw_btw_nummer + * + * + * @return string VAT Number + */ + public static function vat() + { + return sprintf("%s%d%s%d", 'NL', self::randomNumber(9, true),'B', self::randomNumber(2, true)); + + } + + /** + * Alias dutch vat number format + */ + public static function btw() + { + return self::vat(); + } } diff --git a/test/Faker/Provider/nl_NL/CompanyTest.php b/test/Faker/Provider/nl_NL/CompanyTest.php new file mode 100644 index 0000000000..4775b14e61 --- /dev/null +++ b/test/Faker/Provider/nl_NL/CompanyTest.php @@ -0,0 +1,34 @@ +addProvider(new Company($faker)); + $this->faker = $faker; + } + + public function testGenerateValidVatNumber() + { + $vatNo = $this->faker->vat(); + + $this->assertEquals(14, strlen($vatNo)); + $this->assertRegExp('/^NL[0-9]{9}B[0-9]{2}$/', $vatNo); + } + + public function testGenerateValidBtwNumberAlias() + { + $btwNo = $this->faker->btw(); + + $this->assertEquals(14, strlen($btwNo)); + $this->assertRegExp('/^NL[0-9]{9}B[0-9]{2}$/', $btwNo); + } +} From f1779892f891193ce74defd1f5bdccc2af0a7206 Mon Sep 17 00:00:00 2001 From: Laurens Laman Date: Wed, 23 Mar 2016 00:07:17 +0100 Subject: [PATCH 2/3] missing space --- src/Faker/Provider/nl_NL/Company.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Faker/Provider/nl_NL/Company.php b/src/Faker/Provider/nl_NL/Company.php index 2a3356c904..3185b89452 100644 --- a/src/Faker/Provider/nl_NL/Company.php +++ b/src/Faker/Provider/nl_NL/Company.php @@ -25,7 +25,7 @@ class Company extends \Faker\Provider\Company */ public static function vat() { - return sprintf("%s%d%s%d", 'NL', self::randomNumber(9, true),'B', self::randomNumber(2, true)); + return sprintf("%s%d%s%d", 'NL', self::randomNumber(9, true), 'B', self::randomNumber(2, true)); } From 1c9b50743dfc190ff50c0970d59acf0f9bd7f06d Mon Sep 17 00:00:00 2001 From: Laurens Laman Date: Fri, 25 Mar 2016 18:40:43 +0100 Subject: [PATCH 3/3] Update readme.md --- readme.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/readme.md b/readme.md index 86316b5e09..cd14e2d16a 100644 --- a/readme.md +++ b/readme.md @@ -1039,6 +1039,14 @@ echo $faker->district; echo $faker->cityName; ``` +### `Faker\Provider\nl_NL\Company` + +```php +vat; // "NL123456789B01" - Dutch Value Added Tax number +echo $faker->btw; // "NL123456789B01" - Dutch Value Added Tax number (alias) +``` + ### `Faker\Provider\no_NO\Payment` ```php