Skip to content

Commit

Permalink
Handle code_compta with deprecationhandler
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeweerd committed Oct 10, 2024
1 parent d2c3474 commit 545cb4c
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions htdocs/societe/class/societe.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -663,14 +663,6 @@ class Societe extends CommonObject
*/
public $code_compta_client;

/**
* Duplicate of code_compta_client (for backward compatibility)
* @var string
* @deprecated Use $code_compta_client
* @see $code_compta_client
*/
public $code_compta;

/**
* Accounting general account for customer
* @var string
Expand Down Expand Up @@ -918,6 +910,21 @@ class Societe extends CommonObject
*/
const SUPPLIER = 1;

/**
* Provide list of deprecated properties and replacements
*
* @return array<string,string>
*/
protected function deprecatedProperties()
{
return
array(
'code_compta' => 'code_compta_client',
)
+ parent::deprecatedProperties();
}



/**
* Constructor
Expand Down Expand Up @@ -978,7 +985,7 @@ public function create(User $user, $notrigger = 0)
}
$this->import_key = trim((string) $this->import_key);

$this->code_compta_client = trim(empty($this->code_compta_client) ? $this->code_compta : $this->code_compta_client);
$this->code_compta_client = trim($this->code_compta_client);

$this->accountancy_code_customer_general = trim($this->accountancy_code_customer_general);
$this->accountancy_code_customer = trim((string) $this->code_compta_client);
Expand Down Expand Up @@ -1496,8 +1503,7 @@ public function update($id, User $user, $call_trigger = 1, $allowmodcodeclient =
$this->get_codefournisseur($this, 1);
}

$this->code_compta_client = trim(empty($this->code_compta_client) ? $this->code_compta : $this->code_compta_client);
$this->code_compta = $this->code_compta_client; // for backward compatibility
$this->code_compta_client = trim($this->code_compta_client);
$this->code_compta_fournisseur = (empty($this->code_compta_fournisseur) ? '' : trim($this->code_compta_fournisseur));

// Check parameters. More tests are done later in the ->verify()
Expand Down Expand Up @@ -2051,7 +2057,6 @@ public function fetch($rowid, $ref = '', $ref_ext = '', $barcode = '', $idprof1
$this->code_fournisseur = $obj->code_fournisseur;

$this->accountancy_code_customer_general = $obj->accountancy_code_customer_general;
$this->code_compta = $obj->code_compta; // For backward compatibility
$this->code_compta_client = $obj->code_compta;
$this->code_compta_fournisseur = $obj->code_compta_fournisseur;

Expand Down Expand Up @@ -2946,7 +2951,7 @@ public function getTooltipContentArray($params)
}
if (isModEnabled('accounting') && ($this->client == 1 || $this->client == 3)) {
$langs->load('compta');
$datas['accountancycustomercode'] = '<br><b>'.$langs->trans('CustomerAccountancyCode').':</b> '.($this->code_compta ? $this->code_compta : $this->code_compta_client);
$datas['accountancycustomercode'] = '<br><b>'.$langs->trans('CustomerAccountancyCode').':</b> '.$this->code_compta_client;
}
// show categories for this record only in ajax to not overload lists
if (!$nofetch && isModEnabled('category') && $this->client) {
Expand Down Expand Up @@ -3735,7 +3740,7 @@ public function check_codefournisseur()
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Assigns a accounting code from the accounting code module.
* Computed value is stored into this->code_compta or this->code_compta_fournisseur according to $type.
* Computed value is stored into this->code_compta_client or this->code_compta_fournisseur according to $type.
* May be identical to the one entered or generated automatically. Currently, only the automatic generation is implemented.
*
* @param string $type Type of thirdparty ('customer' or 'supplier')
Expand Down Expand Up @@ -3766,7 +3771,6 @@ public function get_codecompta($type)

if ($type == 'customer') {
$this->code_compta_client = $mod->code;
$this->code_compta = $this->code_compta_client; // For backward compatibility
} elseif ($type == 'supplier') {
$this->code_compta_fournisseur = $mod->code;
}
Expand All @@ -3779,7 +3783,6 @@ public function get_codecompta($type)
} else {
if ($type == 'customer') {
$this->code_compta_client = '';
$this->code_compta = ''; // For backward compatibility
} elseif ($type == 'supplier') {
$this->code_compta_fournisseur = '';
}
Expand Down

0 comments on commit 545cb4c

Please sign in to comment.