diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index e0e89b7b978..d6277d7c668 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -193,7 +193,7 @@ if (empty($reshook)) $result = $object->fetch($id); if ($object->statut == Facture::STATUS_CLOSED || ($object->statut == Facture::STATUS_ABANDONED && ($object->close_code != 'replaced' || $object->getIdReplacingInvoice() == 0)) || ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 1)) { // ($object->statut == 1 && $object->paye == 1) should not happened but can be found when data are corrupted - $result = $object->set_unpaid($user); + $result = $object->setUnpaid($user); if ($result > 0) { header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); exit(); diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 316f43bc011..97342af0d94 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -960,7 +960,7 @@ class Invoices extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $result = $this->invoice->set_unpaid(DolibarrApiAccess::$user); + $result = $this->invoice->setUnpaid(DolibarrApiAccess::$user); if ($result == 0) { throw new RestException(304, 'Nothing done'); } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 26c40c2c45e..bd19293ae43 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2301,6 +2301,21 @@ class Facture extends CommonInvoice public function set_paid($user, $close_code = '', $close_note = '') { // phpcs:enable + dol_syslog(get_class($this)."::set_paid is deprecated, use setPaid instead", LOG_NOTICE); + $this->setPaid($user, $close_code, $close_note); + } + + /** + * Tag the invoice as paid completely (if close_code is filled) => this->fk_statut=2, this->paye=1 + * or partialy (if close_code filled) + appel trigger BILL_PAYED => this->fk_statut=2, this->paye stay 0 + * + * @param User $user Object user that modify + * @param string $close_code Code renseigne si on classe a payee completement alors que paiement incomplet (cas escompte par exemple) + * @param string $close_note Commentaire renseigne si on classe a payee alors que paiement incomplet (cas escompte par exemple) + * @return int <0 if KO, >0 if OK + */ + public function setPaid($user, $close_code = '', $close_note = '') + { $error = 0; if ($this->paye != 1) @@ -2352,12 +2367,28 @@ class Facture extends CommonInvoice * Fonction utilisee quand un paiement prelevement est refuse, * ou quand une facture annulee et reouverte. * + * @deprecated + * @see setUnpaid() * @param User $user Object user that change status * @return int <0 if KO, >0 if OK */ public function set_unpaid($user) { // phpcs:enable + dol_syslog(get_class($this)."::set_unpaid is deprecated, use setUnpaid instead", LOG_NOTICE); + $this->setUnpaid($user); + } + + /** + * Tag la facture comme non payee completement + appel trigger BILL_UNPAYED + * Fonction utilisee quand un paiement prelevement est refuse, + * ou quand une facture annulee et reouverte. + * + * @param User $user Object user that change status + * @return int <0 if KO, >0 if OK + */ + public function setUnpaid($user) + { $error = 0; $this->db->begin(); diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 4e22d8f141a..9c685bcce1d 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -788,7 +788,7 @@ class RemiseCheque extends CommonObject { $invoice = new Facture($this->db); $invoice->fetch($obj->fk_facture); - $invoice->set_unpaid($user); + $invoice->setUnpaid($user); $rejectedPayment->amounts[$obj->fk_facture] = price2num($obj->amount) * -1; } diff --git a/htdocs/compta/prelevement/class/rejetprelevement.class.php b/htdocs/compta/prelevement/class/rejetprelevement.class.php index 8b7d21d221f..28a3b1e4efa 100644 --- a/htdocs/compta/prelevement/class/rejetprelevement.class.php +++ b/htdocs/compta/prelevement/class/rejetprelevement.class.php @@ -184,7 +184,7 @@ class RejetPrelevement //Tag invoice as unpaid dol_syslog("RejetPrelevement::Create set_unpaid fac ".$fac->ref); - $fac->set_unpaid($user); + $fac->setUnpaid($user); //TODO: Must be managed by notifications module // Send email to sender of the standing order request