diff --git a/sources/Afup/Comptabilite/Facture.php b/sources/Afup/Comptabilite/Facture.php index 897cf4e3b..b8fbd3de4 100644 --- a/sources/Afup/Comptabilite/Facture.php +++ b/sources/Afup/Comptabilite/Facture.php @@ -278,15 +278,19 @@ function transfertDevis($numero_devis) function genererNumeroFacture() { - // afup_cotisations - $requete = 'SELECT'; - $requete .= " MAX(CAST(SUBSTRING_INDEX(numero_facture, '-', -1) AS UNSIGNED)) + 1 "; - $requete .= 'FROM'; - $requete .= ' afup_compta_facture '; - $requete .= 'WHERE'; - $requete .= ' LEFT(numero_facture, 4)=' . $this->_bdd->echapper(date('Y')); - $index = $this->_bdd->obtenirUn($requete); - return date('Y') . '-' . (is_null($index) ? 1 : $index); + // à partir du 1er janvier 2024 on continue la numérotation + // pour ne plus la réinitialiser chaque année + $sqlYear = $year = (int) date('Y'); + if ($year >= 2024) { + $sqlYear = 2023; + } + + $sql = "SELECT MAX(CAST(SUBSTRING_INDEX(numero_facture, '-', -1) AS UNSIGNED)) + 1 + FROM afup_compta_facture + WHERE LEFT(numero_facture, 4)=$sqlYear"; + $index = $this->_bdd->obtenirUn($sql); + + return $year . '-' . (is_null($index) ? 1 : $index); } function genererNumeroDevis()