diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index c87c1d90b0d..8e5cdbe8067 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1749,7 +1749,7 @@ class Adherent extends CommonObject if (!$error) { // Set invoice as paid - $invoice->set_paid($user); + $invoice->setPaid($user); } } diff --git a/htdocs/cashdesk/validation_verif.php b/htdocs/cashdesk/validation_verif.php index 1df6f805ff6..da320c7d855 100644 --- a/htdocs/cashdesk/validation_verif.php +++ b/htdocs/cashdesk/validation_verif.php @@ -319,7 +319,7 @@ switch ($action) && $obj_facturation->getSetPaymentMode() != 'DIFF') { // We set status to paid - $result = $invoice->set_paid($user); + $result = $invoice->setPaid($user); //print 'set paid';exit; } } diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index d6277d7c668..e84274a2cbd 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -747,7 +747,7 @@ if (empty($reshook)) elseif ($action == 'confirm_paid' && $confirm == 'yes' && $usercanissuepayment) { $object->fetch($id); - $result = $object->set_paid($user); + $result = $object->setPaid($user); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } // Classif "paid partialy" elseif ($action == 'confirm_paid_partially' && $confirm == 'yes' && $usercanissuepayment) @@ -756,7 +756,7 @@ if (empty($reshook)) $close_code = GETPOST("close_code", 'restricthtml'); $close_note = GETPOST("close_note", 'restricthtml'); if ($close_code) { - $result = $object->set_paid($user, $close_code, $close_note); + $result = $object->setPaid($user, $close_code, $close_note); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } else { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Reason")), null, 'errors'); @@ -921,7 +921,7 @@ if (empty($reshook)) { if ($object->type != Facture::TYPE_DEPOSIT) { // Classe facture - $result = $object->set_paid($user); + $result = $object->setPaid($user); if ($result >= 0) { $db->commit(); diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 97342af0d94..444fca3155a 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -910,7 +910,7 @@ class Invoices extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $result = $this->invoice->set_paid(DolibarrApiAccess::$user, $close_code, $close_note); + $result = $this->invoice->setPaid(DolibarrApiAccess::$user, $close_code, $close_note); if ($result == 0) { throw new RestException(304, 'Error nothing done. May be object is already validated'); } @@ -1167,7 +1167,7 @@ class Invoices extends DolibarrApi { if ($this->invoice->type != Facture::TYPE_DEPOSIT) { // Classe facture - $result = $this->invoice->set_paid(DolibarrApiAccess::$user); + $result = $this->invoice->setPaid(DolibarrApiAccess::$user); if ($result >= 0) { $this->db->commit(); diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index fcc27276628..5d87203af4f 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -398,7 +398,7 @@ class Paiement extends CommonObject // Set invoice to paid if (!$error) { - $result = $invoice->set_paid($user, '', ''); + $result = $invoice->setPaid($user, '', ''); if ($result < 0) { $this->error = $invoice->error; diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 961ebe96a7a..22737fcfbfe 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -375,7 +375,7 @@ class BonPrelevement extends CommonObject dol_syslog(get_class($this)."::set_credite set_paid fac ".$facs[$i]); $fac = new Facture($this->db); $fac->fetch($facs[$i]); - $result = $fac->set_paid($user); + $result = $fac->setPaid($user); } } @@ -482,7 +482,7 @@ class BonPrelevement extends CommonObject // @TODO Move this after creation of payment if (price2num($alreadypayed + $facs[$i][1], 'MT') == $fac->total_ttc) { - $result = $fac->set_paid($user); + $result = $fac->setPaid($user); if ($result < 0) { $this->error = $fac->error; $this->errors = $fac->errors; diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index cfe938ce974..07f3424ba60 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -74,14 +74,14 @@ $object = new ChargeSociales($db); if ($action == 'confirm_paid' && $user->rights->tax->charges->creer && $confirm == 'yes') { $object->fetch($id); - $result = $object->set_paid($user); + $result = $object->setPaid($user); } if ($action == 'reopen' && $user->rights->tax->charges->creer) { $result = $object->fetch($id); if ($object->paye) { - $result = $object->set_unpaid($user); + $result = $object->setUnpaid($user); if ($result > 0) { header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index 57c169d6180..ec4e945f922 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -432,12 +432,26 @@ class ChargeSociales extends CommonObject /** * Tag social contribution as paid completely * - * @param User $user Object user making change - * @return int <0 if KO, >0 if OK + * @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); + return $this->setPaid($user); + } + + /** + * Tag social contribution 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."chargesociales SET"; $sql .= " paye = 1"; $sql .= " WHERE rowid = ".$this->id; @@ -450,12 +464,26 @@ class ChargeSociales extends CommonObject /** * Remove tag paid on social contribution * - * @param User $user Object user making change - * @return int <0 if KO, >0 if OK + * @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); + return $this->setUnpaid($user); + } + + /** + * Remove tag paid on social contribution + * + * @param User $user Object user making change + * @return int <0 if KO, >0 if OK + */ + public function setUnpaid($user) + { $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales SET"; $sql .= " paye = 0"; $sql .= " WHERE rowid = ".$this->id; diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index e821bae2dd9..9258ff63fc3 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -197,7 +197,7 @@ class PaymentSocialContribution extends CommonObject $remaintopay = price2num($contrib->amount - $paiement - $creditnotes - $deposits, 'MT'); if ($remaintopay == 0) { - $result = $contrib->set_paid($user); + $result = $contrib->setPaid($user); } else dol_syslog("Remain to pay for conrib ".$contribid." not null. We do nothing."); } } diff --git a/htdocs/don/card.php b/htdocs/don/card.php index cd3175cdce0..1f0835ee80b 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -255,7 +255,7 @@ if ($action == 'set_cancel') { } if ($action == 'set_paid') { $object->fetch($id); - if ($object->set_paid($id, $modepayment) >= 0) { + if ($object->setPaid($id, $modepayment) >= 0) { $action = ''; } else { setEventMessages($object->error, $object->errors, 'errors'); diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index be9426415fe..7e9b913312a 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -761,13 +761,28 @@ class Don extends CommonObject /** * Classify the donation as paid, the donation was received * - * @param int $id id of donation - * @param int $modepayment mode of payment - * @return int <0 if KO, >0 if OK + * @deprecated + * @see setPaid() + * @param int $id id of donation + * @param int $modepayment mode of payment + * @return int <0 if KO, >0 if OK */ public function set_paid($id, $modepayment = 0) { // phpcs:enable + dol_syslog(get_class($this)."::set_paid is deprecated, use setPaid instead", LOG_NOTICE); + return $this->setPaid($id, $modepayment); + } + + /** + * Classify the donation as paid, the donation was received + * + * @param int $id id of donation + * @param int $modepayment mode of payment + * @return int <0 if KO, >0 if OK + */ + public function setPaid($id, $modepayment = 0) + { $sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 2"; if ($modepayment) { diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 62cfa8e37f6..6ff4c418988 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -981,7 +981,7 @@ if (empty($reshook)) $object = new ExpenseReport($db); $object->fetch($id); - $result = $object->set_paid($id, $user); + $result = $object->setPaid($id, $user); if ($result > 0) { diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 3bed33e7781..60390a62933 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -634,6 +634,23 @@ class ExpenseReport extends CommonObject } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Classify the expense report as paid + * + * @deprecated + * @see setPaid() + * @param int $id Id of expense report + * @param user $fuser User making change + * @param int $notrigger Disable triggers + * @return int <0 if KO, >0 if OK + */ + public function set_paid($id, $fuser, $notrigger = 0) + { + // phpcs:enable + dol_syslog(get_class($this)."::set_paid is deprecated, use setPaid instead", LOG_NOTICE); + return $this->setPaid($id, $fuser, $notrigger); + } + /** * Classify the expense report as paid * @@ -642,9 +659,8 @@ class ExpenseReport extends CommonObject * @param int $notrigger Disable triggers * @return int <0 if KO, >0 if OK */ - public function set_paid($id, $fuser, $notrigger = 0) + public function setPaid($id, $fuser, $notrigger = 0) { - // phpcs:enable $error = 0; $this->db->begin(); diff --git a/htdocs/expensereport/payment/payment.php b/htdocs/expensereport/payment/payment.php index fdaeaf68977..b66103f38f5 100644 --- a/htdocs/expensereport/payment/payment.php +++ b/htdocs/expensereport/payment/payment.php @@ -144,7 +144,7 @@ if ($action == 'add_payment') if (!$error) { $payment->fetch($paymentid); if ($expensereport->total_ttc - $payment->amount == 0) { - $result = $expensereport->set_paid($expensereport->id, $user); + $result = $expensereport->setPaid($expensereport->id, $user); if (!$result > 0) { setEventMessages($payment->error, $payment->errors, 'errors'); $error++; diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index bb0ecbcfa7c..cd172d08345 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -241,7 +241,7 @@ class PaiementFourn extends Paiement $remaintopay = price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT'); if ($remaintopay == 0) { - $result = $invoice->set_paid($user, '', ''); + $result = $invoice->setPaid($user, '', ''); } else dol_syslog("Remain to pay for invoice ".$facid." not null. We do nothing."); } diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index 29cae07e11d..1143fbcd474 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -67,7 +67,7 @@ if (empty($reshook)) if ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->loan->write) { $object->fetch($id); - $result = $object->set_paid($user); + $result = $object->setPaid($user); if ($result > 0) { setEventMessages($langs->trans('LoanPaid'), null, 'mesgs'); diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 33c00190655..8ca516288c1 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -270,7 +270,7 @@ if ($action == 'valid' && $user->rights->facture->creer) if ($remaintopay == 0) { dol_syslog("Invoice is paid, so we set it to status Paid"); - $result = $invoice->set_paid($user); + $result = $invoice->setPaid($user); if ($result > 0) $invoice->paye = 1; // set payment method $invoice->setPaymentMethods($paiementid); diff --git a/htdocs/webservices/server_invoice.php b/htdocs/webservices/server_invoice.php index 7397b8ca2a6..a3b327d35fc 100644 --- a/htdocs/webservices/server_invoice.php +++ b/htdocs/webservices/server_invoice.php @@ -778,7 +778,7 @@ function updateInvoice($authentication, $invoice) } } if ($invoice['status'] == Facture::STATUS_CLOSED) { - $result = $object->set_paid($fuser, $invoice['close_code'], $invoice['close_note']); + $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']); diff --git a/test/phpunit/ChargeSocialesTest.php b/test/phpunit/ChargeSocialesTest.php index 386aa84a38b..705d21ed95d 100644 --- a/test/phpunit/ChargeSocialesTest.php +++ b/test/phpunit/ChargeSocialesTest.php @@ -174,7 +174,7 @@ class ChargeSocialesTest extends PHPUnit\Framework\TestCase /** * testChargeSocialesValid * - * @param Object $localobject Social contribution + * @param ChargeSociales $localobject Social contribution * @return void * * @depends testChargeSocialesFetch @@ -188,7 +188,7 @@ class ChargeSocialesTest extends PHPUnit\Framework\TestCase $langs=$this->savlangs; $db=$this->savdb; - $result=$localobject->set_paid($user); + $result=$localobject->setPaid($user); print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0); @@ -198,7 +198,7 @@ class ChargeSocialesTest extends PHPUnit\Framework\TestCase /** * testChargeSocialesOther * - * @param Object $localobject Social contribution + * @param ChargeSociales $localobject Social contribution * @return void * * @depends testChargeSocialesValid diff --git a/test/phpunit/LoanTest.php b/test/phpunit/LoanTest.php index 653af07bc2b..3dba569c4e9 100644 --- a/test/phpunit/LoanTest.php +++ b/test/phpunit/LoanTest.php @@ -189,7 +189,7 @@ class LoanTest extends PHPUnit\Framework\TestCase $langs=$this->savlangs; $db=$this->savdb; - $result=$localobject->set_paid($user); + $result=$localobject->setPaid($user); print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0);