diff --git a/htdocs/loan/class/loan.class.php b/htdocs/loan/class/loan.class.php index 1a888375bf3..cf4a0c876ea 100644 --- a/htdocs/loan/class/loan.class.php +++ b/htdocs/loan/class/loan.class.php @@ -379,12 +379,26 @@ class Loan extends CommonObject /** * Tag loan as paid completely * + * @deprecated + * @see setPaid() * @param User $user Object user making change * @return int <0 if KO, >0 if OK */ public function set_paid($user) { // phpcs:enable + dol_syslog(get_class($this)."::set_paid is deprecated, use setPaid instead", LOG_NOTICE); + $this->setPaid($user); + } + + /** + * Tag loan as paid completely + * + * @param User $user Object user making change + * @return int <0 if KO, >0 if OK + */ + public function setPaid($user) + { $sql = "UPDATE ".MAIN_DB_PREFIX."loan SET"; $sql .= " paid = ".$this::STATUS_PAID; $sql .= " WHERE rowid = ".$this->id; @@ -399,14 +413,28 @@ class Loan extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Tag loan as payement started + * Tag loan as payment started * + * @deprecated + * @see setStarted() * @param User $user Object user making change * @return int <0 if KO, >0 if OK */ public function set_started($user) { // phpcs:enable + dol_syslog(get_class($this)."::set_started is deprecated, use setStarted instead", LOG_NOTICE); + $this->setStarted($user); + } + + /** + * Tag loan as payment started + * + * @param User $user Object user making change + * @return int <0 if KO, >0 if OK + */ + public function setStarted($user) + { $sql = "UPDATE ".MAIN_DB_PREFIX."loan SET"; $sql .= " paid = ".$this::STATUS_STARTED; $sql .= " WHERE rowid = ".$this->id; @@ -422,13 +450,26 @@ class Loan extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Tag loan as payement as unpaid - * + * @deprecated + * @see setUnpaid() * @param User $user Object user making change * @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 loan as payement as unpaid + * + * @param User $user Object user making change + * @return int <0 if KO, >0 if OK + */ + public function setUnpaid($user) + { $sql = "UPDATE ".MAIN_DB_PREFIX."loan SET"; $sql .= " paid = ".$this::STATUS_UNPAID; $sql .= " WHERE rowid = ".$this->id; diff --git a/htdocs/loan/class/paymentloan.class.php b/htdocs/loan/class/paymentloan.class.php index 34acb06f9ce..3e32456fb28 100644 --- a/htdocs/loan/class/paymentloan.class.php +++ b/htdocs/loan/class/paymentloan.class.php @@ -377,8 +377,7 @@ class PaymentLoan extends CommonObject if ($sum_payment == 0) { dol_syslog(get_class($this)."::delete : set loan to unpaid", LOG_DEBUG); - if ($loan->set_unpaid($user) < 1) - { + if ($loan->setUnpaid($user) < 1) { $error++; dol_print_error($this->db); }