From 5f8b70b772409b41ca66f5e17bc1f94be5d6165a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 9 Feb 2021 09:03:29 +0100 Subject: [PATCH 1/8] use camelCaps name --- htdocs/compta/tva/card.php | 4 ++-- htdocs/compta/tva/class/paymentvat.class.php | 2 +- htdocs/compta/tva/class/tva.class.php | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index 37ef7d689ab..a961d4f1994 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -111,14 +111,14 @@ if ($action == 'setbankaccount' && $user->rights->tax->charges->creer) { 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/tva/class/paymentvat.class.php b/htdocs/compta/tva/class/paymentvat.class.php index 35178dbc0ee..9c1e7f6f32e 100644 --- a/htdocs/compta/tva/class/paymentvat.class.php +++ b/htdocs/compta/tva/class/paymentvat.class.php @@ -194,7 +194,7 @@ class PaymentVAT 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/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index 8a817e6575f..a39a00d8b01 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -246,14 +246,14 @@ class Tva extends CommonObject * @param User $user Object user making change * @return int <0 if KO, >0 if OK */ - public function set_paid($user) + public function setPaid($user) { // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX."tva SET"; $sql .= " paye = 1"; $sql .= " WHERE rowid = ".$this->id; - $return = $this->db->query($sql); - if ($return) return 1; + $resql = $this->db->query($sql); + if ($resql) return 1; else return -1; } @@ -263,14 +263,14 @@ class Tva extends CommonObject * @param User $user Object user making change * @return int <0 if KO, >0 if OK */ - public function set_unpaid($user) + public function setUnpaid($user) { // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX."tva SET"; $sql .= " paye = 0"; $sql .= " WHERE rowid = ".$this->id; - $return = $this->db->query($sql); - if ($return) return 1; + $resql = $this->db->query($sql); + if ($resql) return 1; else return -1; } From a3e7c9d4b08dd3f1e3aa928e0dcdf54ee88cc302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 9 Feb 2021 09:30:00 +0100 Subject: [PATCH 2/8] deprecate non camelCaps functions --- htdocs/loan/class/loan.class.php | 45 +++++++++++++++++++++++-- htdocs/loan/class/paymentloan.class.php | 3 +- 2 files changed, 44 insertions(+), 4 deletions(-) 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); } From 6d961a1f792673747846e1c20138b455715f6d74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 9 Feb 2021 09:40:07 +0100 Subject: [PATCH 3/8] deprecate non camelCaps functions --- htdocs/compta/facture/card.php | 2 +- .../facture/class/api_invoices.class.php | 2 +- htdocs/compta/facture/class/facture.class.php | 31 +++++++++++++++++++ .../cheque/class/remisecheque.class.php | 2 +- .../class/rejetprelevement.class.php | 2 +- 5 files changed, 35 insertions(+), 4 deletions(-) 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 From fe9ee5a39856bbb266e3a938d81c01eeca3514be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 9 Feb 2021 09:49:37 +0100 Subject: [PATCH 4/8] deprecate non camelCaps functions --- htdocs/compta/facture/class/facture.class.php | 6 ++- .../fourn/class/fournisseur.facture.class.php | 37 +++++++++++++++++-- htdocs/loan/class/loan.class.php | 6 +-- htdocs/loan/class/paymentloan.class.php | 2 +- 4 files changed, 42 insertions(+), 9 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index bd19293ae43..e768552d8f4 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2293,6 +2293,8 @@ class Facture extends CommonInvoice * 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 * + * @deprecated + * @see setPaid() * @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) @@ -2302,7 +2304,7 @@ class Facture extends CommonInvoice { // phpcs:enable dol_syslog(get_class($this)."::set_paid is deprecated, use setPaid instead", LOG_NOTICE); - $this->setPaid($user, $close_code, $close_note); + return $this->setPaid($user, $close_code, $close_note); } /** @@ -2376,7 +2378,7 @@ class Facture extends CommonInvoice { // phpcs:enable dol_syslog(get_class($this)."::set_unpaid is deprecated, use setUnpaid instead", LOG_NOTICE); - $this->setUnpaid($user); + return $this->setUnpaid($user); } /** diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 83408d9ba6c..56151d661f9 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1250,6 +1250,8 @@ class FactureFournisseur extends CommonInvoice /** * Tag invoice as a paid invoice * + * @deprecated + * @see setPaid() * @param User $user Object user * @param string $close_code Code indicates whether the class has paid in full while payment is incomplete. Not implementd yet. * @param string $close_note Comment informs if the class has been paid while payment is incomplete. Not implementd yet. @@ -1258,6 +1260,20 @@ class FactureFournisseur 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 invoice as a paid invoice + * + * @param User $user Object user + * @param string $close_code Code indicates whether the class has paid in full while payment is incomplete. Not implementd yet. + * @param string $close_note Comment informs if the class has been paid while payment is incomplete. Not implementd yet. + * @return int <0 si ko, >0 si ok + */ + public function setPaid($user, $close_code = '', $close_note = '') + { global $conf, $langs; $error = 0; @@ -1291,8 +1307,24 @@ class FactureFournisseur extends CommonInvoice } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Tag the invoice as not fully paid + trigger call BILL_UNPAYED + * Function used when a direct debit payment is refused, + * or when the invoice was canceled and reopened. + * + * @deprecated + * @see setUnpaid() + * @param User $user Object user that change status + * @return int <0 si ok, >0 si 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 the invoice as not fully paid + trigger call BILL_UNPAYED * Function used when a direct debit payment is refused, @@ -1301,9 +1333,8 @@ class FactureFournisseur extends CommonInvoice * @param User $user Object user that change status * @return int <0 si ok, >0 si ok */ - public function set_unpaid($user) + public function setUnpaid($user) { - // phpcs:enable global $conf, $langs; $error = 0; diff --git a/htdocs/loan/class/loan.class.php b/htdocs/loan/class/loan.class.php index cf4a0c876ea..9f2d8297edc 100644 --- a/htdocs/loan/class/loan.class.php +++ b/htdocs/loan/class/loan.class.php @@ -388,7 +388,7 @@ class Loan extends CommonObject { // phpcs:enable dol_syslog(get_class($this)."::set_paid is deprecated, use setPaid instead", LOG_NOTICE); - $this->setPaid($user); + return $this->setPaid($user); } /** @@ -424,7 +424,7 @@ class Loan extends CommonObject { // phpcs:enable dol_syslog(get_class($this)."::set_started is deprecated, use setStarted instead", LOG_NOTICE); - $this->setStarted($user); + return $this->setStarted($user); } /** @@ -459,7 +459,7 @@ class Loan extends CommonObject { // phpcs:enable dol_syslog(get_class($this)."::set_unpaid is deprecated, use setUnpaid instead", LOG_NOTICE); - $this->setUnpaid($user); + return $this->setUnpaid($user); } /** diff --git a/htdocs/loan/class/paymentloan.class.php b/htdocs/loan/class/paymentloan.class.php index 3e32456fb28..aa3f895f314 100644 --- a/htdocs/loan/class/paymentloan.class.php +++ b/htdocs/loan/class/paymentloan.class.php @@ -531,7 +531,7 @@ class PaymentLoan extends CommonObject if ($loan->paid == $loan::STATUS_UNPAID) { dol_syslog(get_class($this)."::addPaymentToBank : set loan payment to started", LOG_DEBUG); - if ($loan->set_started($user) < 1) + if ($loan->setStarted($user) < 1) { $error++; dol_print_error($this->db); From 0da942210fb90e52bf9f293ba5cb7f063acac350 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 9 Feb 2021 09:55:48 +0100 Subject: [PATCH 5/8] deprecate non camelCaps functions --- htdocs/expensereport/card.php | 2 +- .../expensereport/class/expensereport.class.php | 15 +++++++++++++++ htdocs/fourn/class/fournisseur.facture.class.php | 4 ++-- htdocs/fourn/facture/card.php | 6 +++--- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index e61a0a12281..62cfa8e37f6 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -953,7 +953,7 @@ if (empty($reshook)) $object = new ExpenseReport($db); $object->fetch($id); - $result = $object->set_unpaid($user); + $result = $object->setUnpaid($user); if ($result > 0) { diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 7ac1924fec8..3bed33e7781 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1492,6 +1492,8 @@ class ExpenseReport extends CommonObject /** * set_unpaid * + * @deprecated + * @see setUnpaid() * @param User $fuser User * @param int $notrigger Disable triggers * @return int <0 if KO, >0 if OK @@ -1499,6 +1501,19 @@ class ExpenseReport extends CommonObject public function set_unpaid($fuser, $notrigger = 0) { // phpcs:enable + dol_syslog(get_class($this)."::set_unpaid is deprecated, use setUnpaid instead", LOG_NOTICE); + return $this->setUnpaid($fuser, $notrigger); + } + + /** + * set_unpaid + * + * @param User $fuser User + * @param int $notrigger Disable triggers + * @return int <0 if KO, >0 if OK + */ + public function setUnpaid($fuser, $notrigger = 0) + { $error = 0; if ($this->paid) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 56151d661f9..67070b99c57 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1261,7 +1261,7 @@ class FactureFournisseur extends CommonInvoice { // phpcs:enable dol_syslog(get_class($this)."::set_paid is deprecated, use setPaid instead", LOG_NOTICE); - $this->setPaid($user, $close_code, $close_note); + return $this->setPaid($user, $close_code, $close_note); } /** @@ -1322,7 +1322,7 @@ class FactureFournisseur extends CommonInvoice { // phpcs:enable dol_syslog(get_class($this)."::set_unpaid is deprecated, use setUnpaid instead", LOG_NOTICE); - $this->setUnpaid($user); + return $this->setUnpaid($user); } /** diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index c2c4a91ea36..a8f7fa2cc42 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -277,7 +277,7 @@ if (empty($reshook)) $discount->unlink_invoice(); } elseif ($action == 'confirm_paid' && $confirm == 'yes' && $usercancreate) { $object->fetch($id); - $result = $object->set_paid($user); + $result = $object->setPaid($user); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } @@ -605,7 +605,7 @@ if (empty($reshook)) { if ($object->type != FactureFournisseur::TYPE_DEPOSIT) { // Classe facture - $result = $object->set_paid($user); + $result = $object->setPaid($user); if ($result >= 0) { $db->commit(); @@ -1545,7 +1545,7 @@ if (empty($reshook)) if ($object->statut == FactureFournisseur::STATUS_CLOSED || ($object->statut == FactureFournisseur::STATUS_ABANDONED && $object->close_code != 'replaced')) { - $result = $object->set_unpaid($user); + $result = $object->setUnpaid($user); if ($result > 0) { header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); From f394e55ade4e5c0570f1a81b51bc84953a118412 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 9 Feb 2021 10:26:17 +0100 Subject: [PATCH 6/8] deprecate non camelCaps functions --- htdocs/adherents/class/adherent.class.php | 2 +- htdocs/cashdesk/validation_verif.php | 2 +- htdocs/compta/facture/card.php | 6 ++-- .../facture/class/api_invoices.class.php | 4 +-- .../compta/paiement/class/paiement.class.php | 2 +- .../class/bonprelevement.class.php | 4 +-- htdocs/compta/sociales/card.php | 4 +-- .../sociales/class/chargesociales.class.php | 36 ++++++++++++++++--- .../class/paymentsocialcontribution.class.php | 2 +- htdocs/don/card.php | 2 +- htdocs/don/class/don.class.php | 21 +++++++++-- htdocs/expensereport/card.php | 2 +- .../class/expensereport.class.php | 20 +++++++++-- htdocs/expensereport/payment/payment.php | 2 +- htdocs/fourn/class/paiementfourn.class.php | 2 +- htdocs/loan/card.php | 2 +- htdocs/takepos/invoice.php | 2 +- htdocs/webservices/server_invoice.php | 2 +- test/phpunit/ChargeSocialesTest.php | 6 ++-- test/phpunit/LoanTest.php | 2 +- 20 files changed, 92 insertions(+), 33 deletions(-) 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); From 04c25a01af7fccf6c4cde88219e99e9af329e0b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 9 Feb 2021 13:10:11 +0100 Subject: [PATCH 7/8] deprecate non camelCaps functions --- htdocs/compta/facture/card.php | 2 +- htdocs/compta/facture/class/facture.class.php | 21 +++++++++++++++++-- ...e_20_modWorkflow_WorkflowManager.class.php | 2 +- htdocs/expedition/card.php | 2 +- htdocs/expedition/class/expedition.class.php | 13 ++++++++++++ htdocs/reception/card.php | 2 +- htdocs/reception/class/reception.class.php | 13 ++++++++++++ htdocs/webservices/server_invoice.php | 12 +++++------ 8 files changed, 54 insertions(+), 13 deletions(-) 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'; From e2d204852228cff91f383481256f9d6d6305e813 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 9 Feb 2021 13:25:55 +0100 Subject: [PATCH 8/8] deprecate non camelCaps functions --- htdocs/commande/card.php | 4 ++-- htdocs/commande/class/commande.class.php | 16 ++++++++++++++++ htdocs/compta/facture/card.php | 2 +- htdocs/compta/facture/class/facture.class.php | 16 ++++++++++++++++ 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index a4177a72f86..152ad8a22e0 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -501,7 +501,7 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } elseif ($action == 'setremise' && $usercancreate) { - $result = $object->set_remise($user, GETPOST('remise')); + $result = $object->setDiscount($user, GETPOST('remise')); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -607,7 +607,7 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } elseif ($action == 'setremisepercent' && $usercancreate) { - $result = $object->set_remise($user, price2num(GETPOST('remise_percent'), 2)); + $result = $object->setDiscount($user, price2num(GETPOST('remise_percent'), 2)); } elseif ($action == 'setremiseabsolue' && $usercancreate) { $result = $object->set_remise_absolue($user, price2num(GETPOST('remise_absolue'), 'MU')); } elseif ($action == 'addline' && GETPOST('submitforalllines', 'alpha') && GETPOST('vatforalllines', 'alpha')) { diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 3d359ca6563..4cdff4afbf4 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -2359,6 +2359,8 @@ class Commande extends CommonOrder /** * Applique une remise relative * + * @deprecated + * @see setDiscount() * @param User $user User qui positionne la remise * @param float $remise Discount (percent) * @param int $notrigger 1=Does not execute triggers, 0= execute triggers @@ -2367,6 +2369,20 @@ class Commande extends CommonOrder public function set_remise($user, $remise, $notrigger = 0) { // phpcs:enable + dol_syslog(get_class($this)."::set_remise is deprecated, use setDiscount instead", LOG_NOTICE); + return $this->setDiscount($user, $remise, $notrigger); + } + + /** + * Applique une remise relative + * + * @param User $user User qui positionne la remise + * @param float $remise Discount (percent) + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int <0 if KO, >0 if OK + */ + public function setDiscount($user, $remise, $notrigger = 0) + { $remise = trim($remise) ?trim($remise) : 0; if ($user->rights->commande->creer) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 8082ad1ff43..befbca0bc26 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -483,7 +483,7 @@ if (empty($reshook)) $result = $object->setBankAccount(GETPOST('fk_account', 'int')); } elseif ($action == 'setremisepercent' && $usercancreate) { $object->fetch($id); - $result = $object->set_remise($user, price2num(GETPOST('remise_percent'), 2)); + $result = $object->setDiscount($user, price2num(GETPOST('remise_percent'), 2)); } elseif ($action == "setabsolutediscount" && $usercancreate) { // POST[remise_id] or POST[remise_id_for_payment] diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index d0519627d4b..929ce01236a 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3617,6 +3617,8 @@ class Facture extends CommonInvoice /** * Set percent discount * + * @deprecated + * @see setDiscount() * @param User $user User that set discount * @param double $remise Discount * @param int $notrigger 1=Does not execute triggers, 0= execute triggers @@ -3625,6 +3627,20 @@ class Facture extends CommonInvoice public function set_remise($user, $remise, $notrigger = 0) { // phpcs:enable + dol_syslog(get_class($this)."::set_remise is deprecated, use setDiscount instead", LOG_NOTICE); + return $this->setDiscount($user, $remise, $notrigger); + } + + /** + * Set percent discount + * + * @param User $user User that set discount + * @param double $remise Discount + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int <0 if ko, >0 if ok + */ + public function setDiscount($user, $remise, $notrigger = 0) + { // Clean parameters if (empty($remise)) $remise = 0;