diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php index ec5ff384592..14fbeead6b8 100644 --- a/htdocs/core/lib/price.lib.php +++ b/htdocs/core/lib/price.lib.php @@ -198,8 +198,13 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt } // initialize total (may be HT or TTC depending on price_base_type) - $tot_sans_remise = $pu * $qty * ($progress / 100); - $tot_avec_remise_ligne = $tot_sans_remise * (1 - ((float) $remise_percent_ligne / 100)); + if ($remise_percent_ligne && getDolGlobalString('MAIN_APPLY_DISCOUNT_ON_UNIT_PRICE_THEN_ROUND_BEFORE_MULTIPLICATION_BY_QTY')) { // MAIN_APPLY_DISCOUNT_ON_UNIT_PRICE_THEN_ROUND_BEFORE_MULTIPLICATION_BY_QTY can be 'MU', 2, ... + $tot_sans_remise = $pu * $qty * ($progress / 100); + $tot_avec_remise_ligne = (float) price2num($pu * (1 - ((float) $remise_percent_ligne / 100)), getDolGlobalString('MAIN_APPLY_DISCOUNT_ON_UNIT_PRICE_THEN_ROUND_BEFORE_MULTIPLICATION_BY_QTY')) * $qty * ($progress / 100); + } else { + $tot_sans_remise = $pu * $qty * ($progress / 100); + $tot_avec_remise_ligne = $tot_sans_remise * (1 - ((float) $remise_percent_ligne / 100)); + } $tot_avec_remise = $tot_avec_remise_ligne * (1 - ((float) $remise_percent_global / 100)); // initialize result array