NEW update price with auto to use const for rounding prices (#29350)
* NEW update price with auto to use MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND const for rounding prices * Update price forced rounding mode redundant
This commit is contained in:
parent
fad3e2d2bf
commit
b64df30cc6
1 changed files with 12 additions and 4 deletions
|
|
@ -3763,7 +3763,7 @@ abstract class CommonObject
|
|||
* @param Societe $seller If roundingadjust is '0' or '1' or maybe 'auto', it means we recalculate total for lines before calculating total for object and for this, we need seller object (used to analyze lines to check corrupted data).
|
||||
* @return int Return integer <0 if KO, >0 if OK
|
||||
*/
|
||||
public function update_price($exclspec = 0, $roundingadjust = 'none', $nodatabaseupdate = 0, $seller = null)
|
||||
public function update_price($exclspec = 0, $roundingadjust = 'auto', $nodatabaseupdate = 0, $seller = null)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $conf, $hookmanager, $action;
|
||||
|
|
@ -3777,6 +3777,8 @@ abstract class CommonObject
|
|||
} // reshook = 0 => execute normal code
|
||||
|
||||
// Some external module want no update price after a trigger because they have another method to calculate the total (ex: with an extrafield)
|
||||
$isElementForSupplier = false;
|
||||
$roundTotalConstName = 'MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND'; // const for customer by default
|
||||
$MODULE = "";
|
||||
if ($this->element == 'propal') {
|
||||
$MODULE = "MODULE_DISALLOW_UPDATE_PRICE_PROPOSAL";
|
||||
|
|
@ -3785,12 +3787,18 @@ abstract class CommonObject
|
|||
} elseif ($this->element == 'facture' || $this->element == 'invoice') {
|
||||
$MODULE = "MODULE_DISALLOW_UPDATE_PRICE_INVOICE";
|
||||
} elseif ($this->element == 'facture_fourn' || $this->element == 'supplier_invoice' || $this->element == 'invoice_supplier' || $this->element == 'invoice_supplier_rec') {
|
||||
$isElementForSupplier = true;
|
||||
$MODULE = "MODULE_DISALLOW_UPDATE_PRICE_SUPPLIER_INVOICE";
|
||||
} elseif ($this->element == 'order_supplier' || $this->element == 'supplier_order') {
|
||||
$isElementForSupplier = true;
|
||||
$MODULE = "MODULE_DISALLOW_UPDATE_PRICE_SUPPLIER_ORDER";
|
||||
} elseif ($this->element == 'supplier_proposal') {
|
||||
$isElementForSupplier = true;
|
||||
$MODULE = "MODULE_DISALLOW_UPDATE_PRICE_SUPPLIER_PROPOSAL";
|
||||
}
|
||||
if ($isElementForSupplier === true) {
|
||||
$roundTotalConstName = 'MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND_SUPPLIER'; // const for supplier
|
||||
}
|
||||
|
||||
if (!empty($MODULE)) {
|
||||
if (getDolGlobalString($MODULE)) {
|
||||
|
|
@ -3806,8 +3814,8 @@ abstract class CommonObject
|
|||
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
|
||||
|
||||
$forcedroundingmode = $roundingadjust;
|
||||
if ($forcedroundingmode == 'auto' && isset($conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND)) {
|
||||
$forcedroundingmode = getDolGlobalString('MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND');
|
||||
if ($forcedroundingmode == 'auto' && isset($conf->global->{$roundTotalConstName})) {
|
||||
$forcedroundingmode = getDolGlobalString($roundTotalConstName);
|
||||
} elseif ($forcedroundingmode == 'auto') {
|
||||
$forcedroundingmode = '0';
|
||||
}
|
||||
|
|
@ -3898,7 +3906,7 @@ abstract class CommonObject
|
|||
}
|
||||
$obj->total_tva = $tmpcal[1];
|
||||
$obj->total_ttc = $tmpcal[2];
|
||||
} elseif ($diff_when_using_price_ht && $roundingadjust == '0') {
|
||||
} elseif ($diff_when_using_price_ht) {
|
||||
// After calculation from HT, total is consistent but we have found a difference between VAT part in calculation and into database and
|
||||
// we ask to force the use of rounding on line (like done on calculation) so we force update of line
|
||||
$sqlfix = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldtva." = ".price2num((float) $tmpcal[1]).", total_ttc = ".price2num((float) $tmpcal[2])." WHERE rowid = ".((int) $obj->rowid);
|
||||
|
|
|
|||
Loading…
Reference in a new issue