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

Tax Id for companies and new formats for es_VE #1287

Merged
merged 4 commits into from
Sep 4, 2017
Merged
Show file tree
Hide file tree
Changes from all 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
18 changes: 18 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,24 @@ echo $faker->vat; // "BE 0123456789" - Belgian Value Added Tax number
echo $faker->vat(false); // "BE0123456789" - unspaced Belgian Value Added Tax number
```

### `Faker\Provider\es_VE\Person`

```php
<?php

// Generate a Cédula de identidad number, you can pass one argument to add separator
echo $faker->nationalId; // 'V11223344'
```

### `Faker\Provider\es_VE\Company`

```php
<?php

// Generates a R.I.F. number, you can pass one argument to add separators
echo $faker->taxpayerIdentificationNumber; // 'J1234567891'
```

### `Faker\Provider\fr_FR\Address`

```php
Expand Down
10 changes: 10 additions & 0 deletions src/Faker/Provider/es_VE/Company.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,14 @@ public static function companyPrefix()
{
return static::randomElement(static::$companyPrefix);
}

/**
* Generate random Taxpayer Identification Number (RIF in Venezuela). Ex J-123456789-1
* @param string $separator
* @return string
*/
public function taxpayerIdentificationNumber($separator = '')
{
return static::randomElement(array('J', 'G', 'V', 'E', 'P', 'C')) . $separator . static::numerify('########') . $separator . static::numerify('#');
}
}
11 changes: 6 additions & 5 deletions src/Faker/Provider/es_VE/Person.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,18 +149,19 @@ public static function suffix()
}

/**
* Generate random national identification number including nationalized foreigns. Ex V-8756432 or E-82803827
* @return string
* Generate random national identification number (cédula de identidad). Ex V-8756432
* @param string $separator
* @return string CNE is the official national election registry org.
* CNE is the official national election registry org.
* @link http://www.cne.gob.ve/web/registro_electoral/ciudadanos_111_129_2011.php
*/
public function nationalId()
public function nationalId($separator = '')
{
$id = static::randomElement(static::$nationalityId);
if ($id == 'V') {
return $id.$this->numberBetween(10000, 100000000);
return $id . $separator . $this->numberBetween(10000, 100000000);
} else {
return $id.$this->numberBetween(80000000, 100000000);
return $id . $separator . $this->numberBetween(80000000, 100000000);
}
}
}
43 changes: 43 additions & 0 deletions test/Faker/Provider/es_VE/CompanyTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
/**
* Created by Domingo Oropeza <dioh_@hotmail.com> for Faker
* Date: 01/09/2017
* Time: 09:45 PM
*/

namespace Faker\Test\Provider\es_VE;


use Faker\Generator;
use Faker\Provider\es_VE\Company;

class CompanyTest extends \PHPUnit_Framework_TestCase
{
/**
* @var Generator
*/
private $faker;

public function setUp()
{
$faker = new Generator();
$faker->seed(1);
$faker->addProvider(new Company($faker));
$this->faker = $faker;
}

/**
* national Id format validator
*/
public function testNationalId()
{
$pattern = '/^[VJGECP]-?\d{8}-?\d$/';
$rif = $this->faker->taxpayerIdentificationNumber;
$this->assertRegExp($pattern, $rif);

$rif = $this->faker->taxpayerIdentificationNumber('-');
$this->assertRegExp($pattern, $rif);
}


}
43 changes: 43 additions & 0 deletions test/Faker/Provider/es_VE/PersonTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
/**
* Created by Domingo Oropeza for Faker
* Date: 01/09/2017
* Time: 11:02 PM
*/

namespace Faker\Test\Provider\es_VE;


use Faker\Generator;
use Faker\Provider\es_VE\Person;

class PersonTest extends \PHPUnit_Framework_TestCase
{

/**
* @var Generator
*/
private $faker;

public function setUp()
{
$faker = new Generator();
$faker->seed(1);
$faker->addProvider(new Person($faker));
$this->faker = $faker;
}

/**
* national Id format validator
*/
public function testNationalId()
{
$pattern = '/(?:^V-?\d{5,9}$)|(?:^E-?\d{8,9}$)/';

$cedula = $this->faker->nationalId;
$this->assertRegExp($pattern, $cedula);

$cedula = $this->faker->nationalId('-');
$this->assertRegExp($pattern, $cedula);
}
}