Merge branch '16.0' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
0cd0314369
@ -3561,7 +3561,7 @@ abstract class CommonObject
|
||||
|
||||
$forcedroundingmode = $roundingadjust;
|
||||
if ($forcedroundingmode == 'auto' && isset($conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND)) {
|
||||
$forcedroundingmode = $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND;
|
||||
$forcedroundingmode = getDolGlobalString('MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND');
|
||||
} elseif ($forcedroundingmode == 'auto') {
|
||||
$forcedroundingmode = '0';
|
||||
}
|
||||
@ -3699,14 +3699,17 @@ abstract class CommonObject
|
||||
}
|
||||
$sqlfix = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldtva." = ".price2num($obj->total_tva - $diff).", total_ttc = ".price2num($obj->total_ttc - $diff)." WHERE rowid = ".((int) $obj->rowid);
|
||||
dol_syslog('We found a difference of '.$diff.' for line rowid = '.$obj->rowid.". We fix the total_vat and total_ttc of line by running sqlfix = ".$sqlfix);
|
||||
$resqlfix = $this->db->query($sqlfix);
|
||||
|
||||
$resqlfix = $this->db->query($sqlfix);
|
||||
|
||||
if (!$resqlfix) {
|
||||
dol_print_error($this->db, 'Failed to update line');
|
||||
}
|
||||
$this->total_tva -= $diff;
|
||||
$this->total_ttc -= $diff;
|
||||
$total_tva_by_vats[$obj->vatrate] -= $diff;
|
||||
$total_ttc_by_vats[$obj->vatrate] -= $diff;
|
||||
|
||||
$this->total_tva = (float) price2num($this->total_tva - $diff, '', 1);
|
||||
$this->total_ttc = (float) price2num($this->total_ttc - $diff, '', 1);
|
||||
$total_tva_by_vats[$obj->vatrate] = (float) price2num($total_tva_by_vats[$obj->vatrate] - $diff, '', 1);
|
||||
$total_ttc_by_vats[$obj->vatrate] = (float) price2num($total_ttc_by_vats[$obj->vatrate] - $diff, '', 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3733,6 +3736,13 @@ abstract class CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
// Clean total
|
||||
$this->total_ht = (float) price2num($this->total_ht);
|
||||
$this->total_tva = (float) price2num($this->total_tva);
|
||||
$this->total_localtax1 = (float) price2num($this->total_localtax1);
|
||||
$this->total_localtax2 = (float) price2num($this->total_localtax2);
|
||||
$this->total_ttc = (float) price2num($this->total_ttc);
|
||||
|
||||
$this->db->free($resql);
|
||||
|
||||
// Now update global fields total_ht, total_ttc, total_tva, total_localtax1, total_localtax2, multicurrency_total_* of main object
|
||||
@ -3766,11 +3776,11 @@ abstract class CommonObject
|
||||
|
||||
if (empty($nodatabaseupdate)) {
|
||||
$sql = "UPDATE ".$this->db->prefix().$this->table_element.' SET';
|
||||
$sql .= " ".$fieldht." = ".((float) price2num($this->total_ht)).",";
|
||||
$sql .= " ".$fieldtva." = ".((float) price2num($this->total_tva)).",";
|
||||
$sql .= " ".$fieldlocaltax1." = ".((float) price2num($this->total_localtax1)).",";
|
||||
$sql .= " ".$fieldlocaltax2." = ".((float) price2num($this->total_localtax2)).",";
|
||||
$sql .= " ".$fieldttc." = ".((float) price2num($this->total_ttc));
|
||||
$sql .= " ".$fieldht." = ".((float) price2num($this->total_ht, 'MT', 1)).",";
|
||||
$sql .= " ".$fieldtva." = ".((float) price2num($this->total_tva, 'MT', 1)).",";
|
||||
$sql .= " ".$fieldlocaltax1." = ".((float) price2num($this->total_localtax1, 'MT', 1)).",";
|
||||
$sql .= " ".$fieldlocaltax2." = ".((float) price2num($this->total_localtax2, 'MT', 1)).",";
|
||||
$sql .= " ".$fieldttc." = ".((float) price2num($this->total_ttc, 'MT', 1));
|
||||
$sql .= ", multicurrency_total_ht = ".((float) price2num($this->multicurrency_total_ht, 'MT', 1));
|
||||
$sql .= ", multicurrency_total_tva = ".((float) price2num($this->multicurrency_total_tva, 'MT', 1));
|
||||
$sql .= ", multicurrency_total_ttc = ".((float) price2num($this->multicurrency_total_ttc, 'MT', 1));
|
||||
|
||||
@ -372,16 +372,16 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
|
||||
// If rounding is not using base 10 (rare)
|
||||
if (!empty($conf->global->MAIN_ROUNDING_RULE_TOT)) {
|
||||
if ($price_base_type == 'HT') {
|
||||
$result[0] = round($result[0] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT;
|
||||
$result[1] = round($result[1] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT;
|
||||
$result[9] = round($result[9] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT;
|
||||
$result[10] = round($result[10] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT;
|
||||
$result[0] = price2num(round($result[0] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT, 'MT');
|
||||
$result[1] = price2num(round($result[1] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT, 'MT');
|
||||
$result[9] = price2num(round($result[9] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT, 'MT');
|
||||
$result[10] = price2num(round($result[10] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT, 'MT');
|
||||
$result[2] = price2num($result[0] + $result[1] + $result[9] + $result[10], 'MT');
|
||||
} else {
|
||||
$result[1] = round($result[1] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT;
|
||||
$result[2] = round($result[2] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT;
|
||||
$result[9] = round($result[9] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT;
|
||||
$result[10] = round($result[10] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT;
|
||||
$result[1] = price2num(round($result[1] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT, 'MT');
|
||||
$result[2] = price2num(round($result[2] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT, 'MT');
|
||||
$result[9] = price2num(round($result[9] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT, 'MT');
|
||||
$result[10] = price2num(round($result[10] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT, 'MT');
|
||||
$result[0] = price2num($result[2] - $result[1] - $result[9] - $result[10], 'MT');
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user