Merge branch '11.0' of git@github.com:Dolibarr/dolibarr.git into develop

Conflicts:
	htdocs/compta/accounting-files.php
This commit is contained in:
Laurent Destailleur 2020-04-24 22:49:59 +02:00
commit 54d641020f
4 changed files with 21 additions and 15 deletions

View File

@ -23,7 +23,7 @@
* \brief Page to show portoflio and files of a thirdparty and download it * \brief Page to show portoflio and files of a thirdparty and download it
*/ */
if ($_GET['action'] == 'dl' || $_POST['action'] == 'dl') { // To not replace token when downloading file if ((array_key_exists('action', $_GET) && $_GET['action'] == 'dl') || (array_key_exists('action', $_POST) && $_POST['action'] == 'dl')) { // To not replace token when downloading file
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1');
} }

View File

@ -3068,18 +3068,23 @@ abstract class CommonObject
if (empty($reshook) && $forcedroundingmode == '0') // Check if data on line are consistent. This may solve lines that were not consistent because set with $forcedroundingmode='auto' if (empty($reshook) && $forcedroundingmode == '0') // Check if data on line are consistent. This may solve lines that were not consistent because set with $forcedroundingmode='auto'
{ {
// This part of code is to fix data. We should not call it too often.
$localtax_array = array($obj->localtax1_type,$obj->localtax1_tx,$obj->localtax2_type,$obj->localtax2_tx); $localtax_array = array($obj->localtax1_type,$obj->localtax1_tx,$obj->localtax2_type,$obj->localtax2_tx);
$tmpcal = calcul_price_total($obj->qty, $obj->up, $obj->remise_percent, $obj->vatrate, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $obj->info_bits, $obj->product_type, $seller, $localtax_array, (isset($obj->situation_percent) ? $obj->situation_percent : 100), $multicurrency_tx); $tmpcal = calcul_price_total($obj->qty, $obj->up, $obj->remise_percent, $obj->vatrate, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $obj->info_bits, $obj->product_type, $seller, $localtax_array, (isset($obj->situation_percent) ? $obj->situation_percent : 100), $multicurrency_tx);
$diff = price2num($tmpcal[1] - $obj->total_tva, 'MT', 1);
if ($diff) $diff_when_using_price_ht = price2num($tmpcal[1] - $obj->total_tva, 'MT', 1); // If price was set with tax price adn unit price HT has a low number of digits, then we may have a diff on recalculation from unit price HT.
$diff_on_current_total = price2num($obj->total_ttc - $obj->total_ht - $obj->total_tva - $obj->total_localtax1 - $obj->total_localtax2, 'MT', 1);
//var_dump($obj->total_ht.' '.$obj->total_tva.' '.$obj->total_localtax1.' '.$obj->total_localtax2.' =? '.$obj->total_ttc);
//var_dump($diff_when_using_price_ht.' '.$diff_on_current_total);
if ($diff_when_using_price_ht && $diff_on_current_total)
{ {
$sqlfix = "UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldtva." = ".$tmpcal[1].", total_ttc = ".$tmpcal[2]." WHERE rowid = ".$obj->rowid; $sqlfix = "UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldtva." = ".$tmpcal[1].", total_ttc = ".$tmpcal[2]." WHERE rowid = ".$obj->rowid;
dol_syslog('We found unconsistent data into detailed line (difference of '.$diff.') for line rowid = '.$obj->rowid." (total vat of line calculated=".$tmpcal[1].", database=".$obj->total_tva."). We fix the total_vat and total_ttc of line by running sqlfix = ".$sqlfix); dol_syslog('We found unconsistent data into detailed line (diff_when_using_price_ht = '.$diff_when_using_price_ht.' and diff_on_current_total = '.$diff_on_current_total.') for line rowid = '.$obj->rowid." (total vat of line calculated=".$tmpcal[1].", database=".$obj->total_tva."). We fix the total_vat and total_ttc of line by running sqlfix = ".$sqlfix, LOG_WARNING);
$resqlfix = $this->db->query($sqlfix); $resqlfix = $this->db->query($sqlfix);
if (! $resqlfix) dol_print_error($this->db, 'Failed to update line'); if (! $resqlfix) dol_print_error($this->db, 'Failed to update line');
$obj->total_tva = $tmpcal[1]; $obj->total_tva = $tmpcal[1];
$obj->total_ttc = $tmpcal[2]; $obj->total_ttc = $tmpcal[2];
//
} }
} }

View File

@ -459,7 +459,8 @@ if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) {
// Standard Extrafield feature // Standard Extrafield feature
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) {
$elementype = Contact::$table_element; $contactstatic = new Contact($db);
$elementype = $contactstatic->table_element;
// fetch optionals attributes and labels // fetch optionals attributes and labels
dol_include_once('/core/class/extrafields.class.php'); dol_include_once('/core/class/extrafields.class.php');
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);

View File

@ -2038,7 +2038,7 @@ class FactureFournisseur extends CommonInvoice
$this->errors[] = $line->error; $this->errors[] = $line->error;
} else { } else {
// Update total price into invoice record // Update total price into invoice record
$res = $this->update_price('', 'auto'); $res = $this->update_price('', 'auto', 0, $this->thirdparty);
} }
return $res; return $res;