Refactored isACompany method

This commit is contained in:
William Mead 2024-01-26 08:49:08 +01:00
parent d17b6712e6
commit 6facd01c48

View file

@ -3996,20 +3996,20 @@ class Societe extends CommonObject
public function isACompany()
{
// Define if third party is treated as company (or not) when nature is unknown
$isACompany = !getDolGlobalString('MAIN_UNKNOWN_CUSTOMERS_ARE_COMPANIES') ? false : true;
$isACompany = getDolGlobalInt('MAIN_UNKNOWN_CUSTOMERS_ARE_COMPANIES');
if (!empty($this->tva_intra)) {
$isACompany = true;
$isACompany = 1;
} elseif (!empty($this->idprof1) || !empty($this->idprof2) || !empty($this->idprof3) || !empty($this->idprof4) || !empty($this->idprof5) || !empty($this->idprof6)) {
$isACompany = true;
$isACompany = 1;
} elseif (!empty($this->typent_code) && $this->typent_code != 'TE_UNKNOWN') {
// TODO Add a field is_a_company into dictionary
if (preg_match('/^TE_PRIVATE/', $this->typent_code)) {
$isACompany = false;
$isACompany = 0;
} else {
$isACompany = true;
$isACompany = 1;
}
}
return $isACompany;
return boolval($isACompany);
}
/**