From ae3112a828ed602de3cb1f012d9188b44d9d8381 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Wed, 27 Sep 2023 11:28:37 +0200 Subject: [PATCH] HAR-132 Fix double closing Reception when classified billed. --- htdocs/reception/class/reception.class.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 72852e1694b..8518709eddd 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -1530,6 +1530,12 @@ class Reception extends CommonObject $error = 0; + // Protection + if ($this->statut == Reception::STATUS_CLOSED) { + dol_syslog(get_class($this)."::Already in closed status", LOG_WARNING); + return 0; + } + $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'reception SET fk_statut='.self::STATUS_CLOSED; @@ -1664,7 +1670,10 @@ class Reception extends CommonObject $this->db->begin(); - $this->setClosed(); + if ($this->statut == Reception::STATUS_VALIDATED) { + // do not close if already closed + $this->setClosed(); + } $sql = 'UPDATE '.MAIN_DB_PREFIX.'reception SET billed=1'; $sql .= " WHERE rowid = ".((int) $this->id).' AND fk_statut > 0';