Skip to content

Commit

Permalink
Génération des ids de facture
Browse files Browse the repository at this point in the history
  • Loading branch information
stakovicz committed Nov 24, 2023
1 parent c51de10 commit 9313d28
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions sources/Afup/Comptabilite/Facture.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 9313d28

Please sign in to comment.