diff --git a/ChangeLog_Koesio.md b/ChangeLog_Koesio.md index 2b797edecd507..1fc80b9ca1f51 100644 --- a/ChangeLog_Koesio.md +++ b/ChangeLog_Koesio.md @@ -1,4 +1,5 @@ ## Backported from 17.0 : +- Backport 17.0 PR #31623 : Suspend facture rec when nb gen max is reached - *2024-10-29* - Backport 21.0 PR #31463 : Tab to see generated invoices on recurring supplier or customer invoice cards - *2024-10-23* - Backport 17.0 PR #31445 : Follow ExtraFields between model invoice and classic invoice - *2024-10-18* diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 68b7c3c75aa09..6d1e804ba3c9f 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -1905,6 +1905,16 @@ public function setNextDate($date, $increment_nb_gen_done = 0, $notrigger = 0) $this->date_when = $date; if ($increment_nb_gen_done > 0) { $this->nb_gen_done++; + + // Backport 17.0 #31623 + if (getDolGlobalInt('MAIN_SUSPEND_FACTURE_REC_ON_MAX_GEN_REACHED') && $this->isMaxNbGenReached()) { + $resSuspend = $this->setValueFrom('suspended', 1); + + if ($resSuspend <= 0) { + dol_syslog(__METHOD__ . '::setValueFrom Error : ' . $this->error, LOG_ERR); + return -1; + } + } } if (!$notrigger) {