FIX: Prevent total discount rounding error on standard lines (#39044)
* FIX: Prevent total discount rounding error on standard lines Added a missing check in pdfGetLineTotalDiscountAmount() to skip the discount math entirely on lines without a discount. This prevents subprice rounding discrepancies on standard items from incorrectly altering the document's total discount. * FIX: Resolve rounding discrepancy in PDF line total discount calculation Ensured `pdfGetLineTotalDiscountAmount()` applies `price2num()` rounding to the theoretical line total `(subprice * qty)` *before* subtracting `total_ht`. This identically matches the database insertion logic, preventing false 1-cent rounding discrepancies from bleeding into the total document discount pool.
This commit is contained in:
parent
52c9dd944c
commit
113716f2a0
1 changed files with 4 additions and 2 deletions
|
|
@ -2917,9 +2917,11 @@ function pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, $hidedetails =
|
|||
|
||||
if (empty($hidedetails) || $hidedetails > 1) {
|
||||
if (empty($multicurrency)) {
|
||||
return (float) price2num($sign * (($object->lines[$i]->subprice * (float) $object->lines[$i]->qty) - $object->lines[$i]->total_ht), 'MT', 1);
|
||||
$diff = (float) price2num($sign * $object->lines[$i]->subprice * (float) $object->lines[$i]->qty, 'MT', 1) - $object->lines[$i]->total_ht;
|
||||
return (float) price2num($diff, 'MT', 1);
|
||||
} else {
|
||||
return (float) price2num($sign * (($object->lines[$i]->multicurrency_subprice * (float) $object->lines[$i]->qty) - $object->lines[$i]->multicurrency_total_ht), 'MT', 1);
|
||||
$diff = (float) price2num($sign * $object->lines[$i]->multicurrency_subprice * (float) $object->lines[$i]->qty, 'MT', 1) - $object->lines[$i]->multicurrency_total_ht;
|
||||
return (float) price2num($diff, 'MT', 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue