Debug v17
This commit is contained in:
parent
5125e42a0c
commit
7627bba443
@ -6279,8 +6279,10 @@ class Form
|
||||
// Definition du taux a pre-selectionner (si defaulttx non force et donc vaut -1 ou '')
|
||||
if ($defaulttx < 0 || dol_strlen($defaulttx) == 0) {
|
||||
$tmpthirdparty = new Societe($this->db);
|
||||
|
||||
$defaulttx = get_default_tva($societe_vendeuse, (is_object($societe_acheteuse) ? $societe_acheteuse : $tmpthirdparty), $idprod);
|
||||
$defaultnpr = get_default_npr($societe_vendeuse, (is_object($societe_acheteuse) ? $societe_acheteuse : $tmpthirdparty), $idprod);
|
||||
|
||||
if (preg_match('/\((.*)\)/', $defaulttx, $reg)) {
|
||||
$defaultcode = $reg[1];
|
||||
$defaulttx = preg_replace('/\s*\(.*\)/', '', $defaulttx);
|
||||
@ -6290,13 +6292,22 @@ class Form
|
||||
}
|
||||
}
|
||||
|
||||
// Si taux par defaut n'a pu etre determine, on prend dernier de la liste.
|
||||
// Comme ils sont tries par ordre croissant, dernier = plus eleve = taux courant
|
||||
// If we fails to find a default vat rate, we take the last one in list
|
||||
// Because they are sorted in ascending order, the last one will be the higher one (we suppose the higher one is the current rate)
|
||||
if ($defaulttx < 0 || dol_strlen($defaulttx) == 0) {
|
||||
if (empty($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS)) {
|
||||
// We take the last one found in list
|
||||
$defaulttx = $this->cache_vatrates[$num - 1]['txtva'];
|
||||
} else {
|
||||
$defaulttx = ($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS == 'none' ? '' : $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS);
|
||||
// We will use the rate defined into MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS
|
||||
$defaulttx = '';
|
||||
if ($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS != 'none') {
|
||||
$defaulttx = $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS;
|
||||
}
|
||||
if (preg_match('/\((.*)\)/', $defaulttx, $reg)) {
|
||||
$defaultcode = $reg[1];
|
||||
$defaulttx = preg_replace('/\s*\(.*\)/', '', $defaulttx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -6306,11 +6306,11 @@ function get_product_vat_for_country($idprod, $thirdpartytouse, $idprodfournpric
|
||||
|
||||
if (!$found) {
|
||||
if (empty($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS)) {
|
||||
// If vat of product for the country not found or not defined, we return the first higher vat of country.
|
||||
// If vat of product for the country not found or not defined, we return the first found (sorting on use_default then higher vat of country).
|
||||
$sql = "SELECT t.taux as vat_rate, t.code as default_vat_code";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c";
|
||||
$sql .= " WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$db->escape($thirdpartytouse->country_code)."'";
|
||||
$sql .= " ORDER BY t.taux DESC, t.code ASC, t.recuperableonly ASC";
|
||||
$sql .= " WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code = '".$db->escape($thirdpartytouse->country_code)."'";
|
||||
$sql .= " ORDER BY t.use_default DESC, t.taux DESC, t.code ASC, t.recuperableonly ASC";
|
||||
$sql .= $db->plimit(1);
|
||||
|
||||
$resql = $db->query($sql);
|
||||
@ -6327,7 +6327,8 @@ function get_product_vat_for_country($idprod, $thirdpartytouse, $idprodfournpric
|
||||
dol_print_error($db);
|
||||
}
|
||||
} else {
|
||||
$ret = $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS; // Forced value if autodetect fails
|
||||
// Forced value if autodetect fails. MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS can be '1.23' or '1.23 (CODE)'
|
||||
$ret = $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -413,7 +413,7 @@ if (empty($reshook)) {
|
||||
|
||||
// Add a product line
|
||||
if ($action == 'addline' && GETPOST('submitforalllines', 'aZ09') && GETPOST('vatforalllines', 'alpha') && $usercancreate) {
|
||||
// Define vat_rate
|
||||
// Define new vat_rate for all lines
|
||||
$vat_rate = (GETPOST('vatforalllines') ? GETPOST('vatforalllines') : 0);
|
||||
$vat_rate = str_replace('*', '', $vat_rate);
|
||||
$localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty, $mysoc);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user