From d3416b864c47efbad5f3704eaef7a295ccc9b034 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Thu, 11 Jan 2024 12:49:39 +0100 Subject: [PATCH] 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 --- htdocs/core/lib/profid.lib.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/profid.lib.php b/htdocs/core/lib/profid.lib.php index 6c9974f7574..a2610078a7f 100644 --- a/htdocs/core/lib/profid.lib.php +++ b/htdocs/core/lib/profid.lib.php @@ -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; + } }