deprecate set_as_client

This commit is contained in:
Frédéric FRANCE 2023-09-06 13:58:08 +02:00
parent 4ae9cea409
commit 26dff90658
7 changed files with 22 additions and 8 deletions

View File

@ -2702,7 +2702,7 @@ class Propal extends CommonObject
// The connected company is classified as a client
$soc=new Societe($this->db);
$soc->id = $this->socid;
$result = $soc->set_as_client();
$result = $soc->setAsCustomer();
if ($result < 0) {
$this->error=$this->db->lasterror();

View File

@ -505,7 +505,7 @@ class Commande extends CommonOrder
$soc->fetch($this->socid);
// Class of company linked to order
$result = $soc->set_as_client();
$result = $soc->setAsCustomer();
// Define new ref
if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life

View File

@ -3372,7 +3372,7 @@ class Facture extends CommonInvoice
if (!$error) {
// Define third party as a customer
$result = $this->thirdparty->set_as_client();
$result = $this->thirdparty->setAsCustomer();
// If active we decrement the main product and its components at invoice validation
if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_BILL) && $idwarehouse > 0) {

View File

@ -499,7 +499,7 @@ class Contrat extends CommonObject
// A contract is validated so we can move thirdparty to status customer
if (empty($conf->global->CONTRACT_DISABLE_AUTOSET_AS_CLIENT_ON_CONTRACT_VALIDATION)) {
$result = $this->thirdparty->set_as_client();
$result = $this->thirdparty->setAsCustomer();
}
// Define new ref

View File

@ -725,7 +725,7 @@ class Expedition extends CommonObject
$soc->fetch($this->socid);
// Class of company linked to order
$result = $soc->set_as_client();
$result = $soc->setAsCustomer();
// Define new ref
if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life

View File

@ -2171,16 +2171,30 @@ class Societe extends CommonObject
* Define third party as a customer
*
* @return int <0 if KO, >0 if OK
* @deprecated
* @see setAsCustomer()
*/
public function set_as_client()
{
// phpcs:enable
dol_syslog(get_class($this)."::set_as_client is deprecated use setAsCustomer instead", LOG_NOTICE);
return $this->setAsCustomer();
}
/**
* Define third party as a customer
*
* @return int <0 if KO, >0 if OK
* @since dolibarr v19
*/
public function setAsCustomer()
{
if ($this->id) {
$newclient = 1;
if (($this->client == 2 || $this->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) {
if (($this->client == 2 || $this->client == 3) && !getDolGlobalInt('SOCIETE_DISABLE_PROSPECTSCUSTOMERS')) {
$newclient = 3; //If prospect, we keep prospect tag
}
$sql = "UPDATE ".MAIN_DB_PREFIX."societe";
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql .= " SET client = ".((int) $newclient);
$sql .= " WHERE rowid = ".((int) $this->id);

View File

@ -337,7 +337,7 @@ class SocieteTest extends PHPUnit\Framework\TestCase
$langs=$this->savlangs;
$db=$this->savdb;
$result=$localobject->set_as_client();
$result=$localobject->setAsCustomer();
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0);