Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

Added Dutch BTW (vat) Number #861

Merged
merged 3 commits into from
Mar 29, 2016
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/Faker/Provider/nl_NL/Company.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add documentation about these two new formatters in the locale specific section of the Readme?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done :)

{
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();
}
}
34 changes: 34 additions & 0 deletions test/Faker/Provider/nl_NL/CompanyTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace Faker\Test\Provider\nl_NL;

use Faker\Generator;
use Faker\Provider\nl_NL\Company;

class CompanyTest extends \PHPUnit_Framework_TestCase
{
private $faker;

public function setUp()
{
$faker = new Generator();
$faker->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);
}
}