Last active
September 18, 2020 08:19
-
-
Save decentraliser/250bfa6b331c2c4c2ebd926fb90d0420 to your computer and use it in GitHub Desktop.
Calculer un numéro de TVA à partir d'un numéro SIREN
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
function getVatNumberFromSiren($siren) | |
{ | |
$prefix = ((($siren%97)*3)+12)%97; | |
if ($prefix < 10) { | |
$prefix = "0{$prefix}"; | |
} | |
return "FR{$prefix}{$siren}"; | |
} | |
function getSirenFromSiret($siret) | |
{ | |
return substr($siret, 0, 9); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment