From c534f5bcd51485747c808c76128b22b60e7cc9f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Wed, 4 Nov 2015 20:34:18 +0100 Subject: [PATCH] Fix #3805 Enhanced Facture::is_last_in_cycle() --- htdocs/compta/facture/class/facture.class.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index eee909645d7..cfbb0491be2 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3672,11 +3672,16 @@ class Facture extends CommonInvoice /** * Checks if the invoice is the last in its cycle * - * @return int 0 or 1 if OK, -1 if error + * @return bool Last of the cycle status * */ function is_last_in_cycle() { + if (empty($this->situation_cycle_ref)) { + // No point in testing anything if we're not inside a cycle + return false; + } + $sql = 'SELECT max(situation_counter) FROM ' . MAIN_DB_PREFIX . 'facture WHERE situation_cycle_ref = ' . $this->situation_cycle_ref; $resql = $this->db->query($sql); @@ -3687,8 +3692,7 @@ class Facture extends CommonInvoice } else { $this->error = $this->db->lasterror(); dol_syslog(get_class($this) . "::select Error " . $this->error, LOG_ERR); - $this->db->rollback(); - return -1; + return false; } }