Skip to content

Instantly share code, notes, and snippets.

@decentraliser
Last active September 18, 2020 08:19
Show Gist options
  • Save decentraliser/250bfa6b331c2c4c2ebd926fb90d0420 to your computer and use it in GitHub Desktop.
Save decentraliser/250bfa6b331c2c4c2ebd926fb90d0420 to your computer and use it in GitHub Desktop.
Calculer un numéro de TVA à partir d'un numéro SIREN
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