Fix: SIRET syntax check - Handle the specific case of "La Poste" businesses (#27418)

* fix: SIRET syntax check - Handle the specific case of "La Poste" businesses

* phpcs

* phpcs

* typo
This commit is contained in:
thibdrev 2024-01-11 12:49:39 +01:00 committed by GitHub
parent 31ff426762
commit d3416b864c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -84,6 +84,16 @@ function isValidSiret($siret)
return false;
}
// TODO: handle the exception of "La Poste" (356 000 000 #####)
return isValidLuhn($siret);
if (isValidLuhn($siret)) {
return true;
} elseif ( (substr($siret, 0, 9) == "356000000") && (array_sum(str_split($siret)) %5 == 0) ) {
/**
* Specific case of "La Poste" businesses (SIRET such as "356 000 000 XXXXX"),
* for which the rule becomes: the sum of the 14 digits must be a multiple of 5.
* See https://fr.wikipedia.org/wiki/SIRET for details.
*/
return true;
} else {
return false;
}
}