diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index e84274a2cbd..8082ad1ff43 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -767,7 +767,7 @@ if (empty($reshook)) $close_code = GETPOST("close_code", 'restricthtml'); $close_note = GETPOST("close_note", 'restricthtml'); if ($close_code) { - $result = $object->set_canceled($user, $close_code, $close_note); + $result = $object->setCanceled($user, $close_code, $close_note); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } else { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Reason")), null, 'errors'); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index e768552d8f4..d0519627d4b 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2432,6 +2432,8 @@ class Facture extends CommonInvoice * Warning, if option to decrease stock on invoice was set, this function does not change stock (it might be a cancel because * of no payment even if merchandises were sent). * + * @deprecated + * @see setCanceled() * @param User $user Object user making change * @param string $close_code Code of closing invoice (CLOSECODE_REPLACED, CLOSECODE_...) * @param string $close_note Comment @@ -2440,8 +2442,23 @@ class Facture extends CommonInvoice public function set_canceled($user, $close_code = '', $close_note = '') { // phpcs:enable + dol_syslog(get_class($this)."::set_canceled is deprecated, use setCanceled instead", LOG_NOTICE); + return $this->setCanceled($user, $close_code, $close_note); + } - dol_syslog(get_class($this)."::set_canceled rowid=".$this->id, LOG_DEBUG); + /** + * Tag invoice as canceled, with no payment on it (example for replacement invoice or payment never received) + call trigger BILL_CANCEL + * Warning, if option to decrease stock on invoice was set, this function does not change stock (it might be a cancel because + * of no payment even if merchandises were sent). + * + * @param User $user Object user making change + * @param string $close_code Code of closing invoice (CLOSECODE_REPLACED, CLOSECODE_...) + * @param string $close_note Comment + * @return int <0 if KO, >0 if OK + */ + public function setCanceled($user, $close_code = '', $close_note = '') + { + dol_syslog(get_class($this)."::setCanceled rowid=".$this->id, LOG_DEBUG); $this->db->begin(); @@ -2575,7 +2592,7 @@ class Facture extends CommonInvoice return -12; } - $result = $facreplaced->set_canceled($user, self::CLOSECODE_REPLACED, ''); + $result = $facreplaced->setCanceled($user, self::CLOSECODE_REPLACED, ''); if ($result < 0) { $this->error = $facreplaced->error; diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index dac1368b8f4..d4bd29838e8 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -307,7 +307,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers dol_syslog("Amount of linked proposals = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht), LOG_DEBUG); if ($totalonlinkedelements == $object->total_ht) { foreach ($object->linkedObjects['reception'] as $element) { - $ret = $element->set_billed(); + $ret = $element->setBilled(); } } } diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 9e08673f4a7..c13206e9450 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -523,7 +523,7 @@ if (empty($reshook)) } elseif ($action == 'classifybilled') { $object->fetch($id); - $result = $object->set_billed(); + $result = $object->setBilled(); if ($result >= 0) { header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit(); diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index aa2402a432b..f32a70e69fd 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -2307,11 +2307,24 @@ class Expedition extends CommonObject /** * Classify the shipping as invoiced (used when WORKFLOW_BILL_ON_SHIPMENT is on) * + * @deprecated + * @see setBilled() * @return int <0 if ko, >0 if ok */ public function set_billed() { // phpcs:enable + dol_syslog(get_class($this)."::set_billed is deprecated, use setBilled instead", LOG_NOTICE); + return $this->setBilled(); + } + + /** + * Classify the shipping as invoiced (used when WORKFLOW_BILL_ON_SHIPMENT is on) + * + * @return int <0 if ko, >0 if ok + */ + public function setBilled() + { global $user; $error = 0; diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 0cf53b7dd4f..27ba05f24bb 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -506,7 +506,7 @@ if (empty($reshook)) } elseif ($action == 'classifybilled') { $object->fetch($id); - $result = $object->set_billed(); + $result = $object->setBilled(); if ($result >= 0) { header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit(); diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index ef12d844ddc..f53c2bc466d 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -1551,11 +1551,24 @@ class Reception extends CommonObject /** * Classify the reception as invoiced (used when WORKFLOW_BILL_ON_RECEPTION is on) * + * @deprecated + * @see setBilled() * @return int <0 if ko, >0 if ok */ public function set_billed() { // phpcs:enable + dol_syslog(get_class($this)."::set_billed is deprecated, use setBilled instead", LOG_NOTICE); + return $this->setBilled(); + } + + /** + * Classify the reception as invoiced (used when WORKFLOW_BILL_ON_RECEPTION is on) + * + * @return int <0 if ko, >0 if ok + */ + public function setBilled() + { global $user; $error = 0; diff --git a/htdocs/webservices/server_invoice.php b/htdocs/webservices/server_invoice.php index a3b327d35fc..e696258e5d9 100644 --- a/htdocs/webservices/server_invoice.php +++ b/htdocs/webservices/server_invoice.php @@ -780,13 +780,13 @@ function updateInvoice($authentication, $invoice) if ($invoice['status'] == Facture::STATUS_CLOSED) { $result = $object->setPaid($fuser, $invoice['close_code'], $invoice['close_note']); } - if ($invoice['status'] == Facture::STATUS_ABANDONED) - $result = $object->set_canceled($fuser, $invoice['close_code'], $invoice['close_note']); + if ($invoice['status'] == Facture::STATUS_ABANDONED) { + $result = $object->setCanceled($fuser, $invoice['close_code'], $invoice['close_note']); + } } } - if ((!$error) && ($objectfound)) - { + if ((!$error) && ($objectfound)) { $db->commit(); $objectresp = array( 'result'=>array('result_code'=>'OK', 'result_label'=>''), @@ -794,9 +794,7 @@ function updateInvoice($authentication, $invoice) 'ref'=>$object->ref, 'ref_ext'=>$object->ref_ext ); - } - elseif ($objectfound) - { + } elseif ($objectfound) { $db->rollback(); $error++; $errorcode = 'KO';