mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-07 16:41:48 +01:00
NEW : Rounding unit price - line discount before applying quantity - option MAIN_APPLY_DISCOUNT_ON_UNIT_PRICE_THEN_ROUND_BEFORE_MULTIPLICATION_BY_QTY (#33690)
* Rounding unit price - line discount before applying quantity On some systems, the line total price is calculated based on the discount applied on the unit price first, giving a new rounded unit price, and then multiplied by the quantity. Whereas the current way Dolibarr acts is to apply the discount on the subtotal (unit price * quantity). Using an extra OTHER SETUP constant 'MAIN_ROUND_UNIT_PRICE_BEFORE_QTY', we can choose between the two ways. * Update price.lib.php * Update price.lib.php --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user