Move isInEEC from common to thirdparty class.

This commit is contained in:
Laurent Destailleur 2018-04-09 14:25:02 +02:00
parent aa01afc0d5
commit 24f4d5040a
3 changed files with 66 additions and 54 deletions

View File

@ -3576,19 +3576,6 @@ abstract class CommonObject
} }
/**
* Return if a country is inside the EEC (European Economic Community)
* @deprecated Use function isInEEC function instead
*
* @return boolean true = country inside EEC, false = country outside EEC
*/
function isInEEC()
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
return isInEEC($this);
}
// -------------------- // --------------------
// TODO: All functions here must be redesigned and moved as they are not business functions but output functions // TODO: All functions here must be redesigned and moved as they are not business functions but output functions
// -------------------- // --------------------

View File

@ -635,17 +635,15 @@ function getFormeJuridiqueLabel($code)
} }
} }
/** /**
* Return if a country of an object is inside the EEC (European Economic Community) * Return list of countries that are inside the EEC (European Economic Community)
* TODO Add a field into country dictionary. * TODO Add a field into country dictionary.
* *
* @param Object $object Object * @return array Array of countries code in EEC
* @return boolean true = country inside EEC, false = country outside EEC
*/ */
function isInEEC($object) function getCountriesInEEC()
{ {
if (empty($object->country_code)) return false;
// List of all country codes that are in europe for european vat rules // List of all country codes that are in europe for european vat rules
// List found on http://ec.europa.eu/taxation_customs/common/faq/faq_1179_en.htm#9 // List found on http://ec.europa.eu/taxation_customs/common/faq/faq_1179_en.htm#9
$country_code_in_EEC=array( $country_code_in_EEC=array(
@ -683,6 +681,22 @@ function isInEEC($object)
'UK', // United Kingdom 'UK', // United Kingdom
//'CH', // Switzerland - No. Swizerland in not in EEC //'CH', // Switzerland - No. Swizerland in not in EEC
); );
return $country_code_in_EEC;
}
/**
* Return if a country of an object is inside the EEC (European Economic Community)
*
* @param Object $object Object
* @return boolean true = country inside EEC, false = country outside EEC
*/
function isInEEC($object)
{
if (empty($object->country_code)) return false;
$country_code_in_EEC = getCountriesInEEC();
//print "dd".$this->country_code; //print "dd".$this->country_code;
return in_array($object->country_code, $country_code_in_EEC); return in_array($object->country_code, $country_code_in_EEC);
} }

View File

@ -3145,6 +3145,17 @@ class Societe extends CommonObject
return $isacompany; return $isacompany;
} }
/**
* Return if a company is inside the EEC (European Economic Community)
*
* @return boolean true = country inside EEC, false = country outside EEC
*/
function isInEEC()
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
return isInEEC($this);
}
/** /**
* Charge la liste des categories fournisseurs * Charge la liste des categories fournisseurs
* *