From 749814617084bac60ec8724b2e0d36f665ba9273 Mon Sep 17 00:00:00 2001 From: Marco Vito Moscaritolo Date: Sat, 16 Jun 2018 21:35:18 +0200 Subject: [PATCH] Improve vat ID generated for Italy to follow the official rules --- src/Faker/Provider/it_IT/Company.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Faker/Provider/it_IT/Company.php b/src/Faker/Provider/it_IT/Company.php index f27499a31f..6acb6daa3b 100644 --- a/src/Faker/Provider/it_IT/Company.php +++ b/src/Faker/Provider/it_IT/Company.php @@ -2,6 +2,8 @@ namespace Faker\Provider\it_IT; +use Faker\Calculator\Luhn; + class Company extends \Faker\Provider\Company { protected static $formats = array( @@ -69,6 +71,8 @@ public function bs() */ public static function vatId() { - return static::numerify('IT###########'); + $code = sprintf('%s%03d', static::numerify('#######'), static::numberBetween(1, 121)); + + return sprintf('IT%s%d', $code, Luhn::computeCheckDigit($code)); } }