Fix case of MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS is 'none'

This commit is contained in:
Laurent Destailleur 2022-12-04 12:11:48 +01:00
parent 61bea8630e
commit 24d7a72b06
3 changed files with 20 additions and 6 deletions

View File

@ -6357,12 +6357,16 @@ class Form
}
}
$return .= '>';
//if (!empty($conf->global->MAIN_VAT_SHOW_POSITIVE_RATES))
// Show label of VAT
if ($mysoc->country_code == 'IN' || !empty($conf->global->MAIN_VAT_LABEL_IS_POSITIVE_RATES)) {
// Label with all localtax and code. For example: x.y / a.b / c.d (CODE)'
$return .= $rate['labelpositiverates'];
} else {
// Simple label
$return .= vatrate($rate['label']);
}
//$return.=($rate['code']?' '.$rate['code']:'');
$return .= (empty($rate['code']) && $rate['nprtva']) ? ' *' : ''; // We show the * (old behaviour only if new vat code is not used)

View File

@ -6265,10 +6265,10 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisi
* Return vat rate of a product in a particular country, or default country vat if product is unknown.
* Function called by get_default_tva().
*
* @param int $idprod Id of product or 0 if not a predefined product
* @param Societe $thirdpartytouse Thirdparty with a ->country_code defined (FR, US, IT, ...)
* @param int $idprodfournprice Id product_fournisseur_price (for "supplier" proposal/order/invoice)
* @return float|string Vat rate to use with format 5.0 or '5.0 (XXX)'
* @param int $idprod Id of product or 0 if not a predefined product
* @param Societe $thirdpartytouse Thirdparty with a ->country_code defined (FR, US, IT, ...)
* @param int $idprodfournprice Id product_fournisseur_price (for "supplier" proposal/order/invoice)
* @return float|string Vat rate to use with format 5.0 or '5.0 (XXX)'
* @see get_product_localtax_for_country()
*/
function get_product_vat_for_country($idprod, $thirdpartytouse, $idprodfournprice = 0)
@ -6329,7 +6329,16 @@ function get_product_vat_for_country($idprod, $thirdpartytouse, $idprodfournpric
}
} else {
// 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;
$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);
}*/
$ret = $defaulttx;
}
}

View File

@ -2518,6 +2518,7 @@ if ($action == 'create') {
print '<td class="right inputvat">';
$defaultvat = -1;
if (!empty($conf->global->EXPENSEREPORT_NO_DEFAULT_VAT)) {
// If option to have no default VAT on expense report is on, we force MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS
$conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS = 'none';
}
print $form->load_tva('vatrate', (!empty($vatrate) ? $vatrate : $defaultvat), $mysoc, '', 0, 0, '', false, 1);