mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-17 23:11:29 +01:00
Better error management
This commit is contained in:
@@ -5682,19 +5682,18 @@ function isOnlyOneLocalTax($local)
|
||||
/**
|
||||
* Get values of localtaxes (1 or 2) for company country for the common vat with the highest value
|
||||
*
|
||||
* @param int $local LocalTax to get
|
||||
* @return number Values of localtax
|
||||
* @param int $local LocalTax to get
|
||||
* @return string Values of localtax (Can be '20', '-19:-15:-9')
|
||||
*/
|
||||
function get_localtax_by_third($local)
|
||||
{
|
||||
global $db, $mysoc;
|
||||
|
||||
$sql = " SELECT t.localtax".$local." as localtax";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t inner join ".MAIN_DB_PREFIX."c_country as c ON c.rowid=t.fk_pays";
|
||||
$sql .= " WHERE c.code = '".$db->escape($mysoc->country_code)."' AND t.active = 1 AND t.taux=(";
|
||||
$sql .= " SELECT max(tt.taux) FROM ".MAIN_DB_PREFIX."c_tva as tt inner join ".MAIN_DB_PREFIX."c_country as c ON c.rowid=tt.fk_pays";
|
||||
$sql .= " WHERE c.code = '".$db->escape($mysoc->country_code)."' AND tt.active = 1";
|
||||
$sql .= " ) ";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t INNER JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = t.fk_pays";
|
||||
$sql .= " WHERE c.code = '".$db->escape($mysoc->country_code)."' AND t.active = 1 AND t.taux = (";
|
||||
$sql .= "SELECT MAX(tt.taux) FROM ".MAIN_DB_PREFIX."c_tva as tt INNER JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = tt.fk_pays";
|
||||
$sql .= " WHERE c.code = '".$db->escape($mysoc->country_code)."' AND tt.active = 1)";
|
||||
$sql .= " AND t.localtax".$local."_type > 0";
|
||||
$sql .= " ORDER BY t.rowid DESC";
|
||||
|
||||
@@ -5702,9 +5701,11 @@ function get_localtax_by_third($local)
|
||||
if ($resql) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
return $obj->localtax;
|
||||
} else {
|
||||
return 'Error';
|
||||
}
|
||||
|
||||
return 0;
|
||||
return '0';
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user