Debug v23 - fix code for rounding

This commit is contained in:
Laurent Destailleur
2026-01-29 13:01:49 +01:00
parent ca017aa342
commit 285371f49e
4 changed files with 21 additions and 18 deletions

View File

@@ -1719,12 +1719,12 @@ class Commande extends CommonOrder
$result = $tmpproduct->fetch($fk_product);
if (abs($qty) < $tmpproduct->packaging) {
$qty = (float) $tmpproduct->packaging;
setEventMessages($langs->trans('QtyRecalculatedWithPackaging'), null, 'mesgs');
setEventMessages($langs->trans('QtyRecalculatedWithPackaging'), null, 'warnings');
} else {
if (!empty($tmpproduct->packaging) && $qty > $tmpproduct->packaging) {
if (!empty($tmpproduct->packaging) && (float) price2num(fmod((float) $qty, (float) $tmpproduct->packaging), 'MS')) {
$coeff = intval(abs($qty) / $tmpproduct->packaging) + 1;
$qty = price2num((float) $tmpproduct->packaging * $coeff, 'MS');
setEventMessages($langs->trans('QtyRecalculatedWithPackaging'), null, 'mesgs');
setEventMessages($langs->trans('QtyRecalculatedWithPackaging'), null, 'warnings');
}
}
}
@@ -3280,14 +3280,15 @@ class Commande extends CommonOrder
if (getDolGlobalString('PRODUCT_USE_CUSTOMER_PACKAGING')) {
if ($qty < $this->line->packaging) {
$qty = $this->line->packaging;
setEventMessage($langs->trans('QtyRecalculatedWithPackaging'), 'warnings');
} else {
if (!empty($this->line->packaging)
&& is_numeric($this->line->packaging)
&& (float) $this->line->packaging > 0
&& fmod((float) $qty, (float) $this->line->packaging) > 0) {
&& (float) price2num(fmod((float) $qty, (float) $this->line->packaging), 'MS')) {
$coeff = intval($qty / $this->line->packaging) + 1;
$qty = $this->line->packaging * $coeff;
setEventMessage($langs->trans('QtyRecalculatedWithPackaging'), 'mesgs');
setEventMessage($langs->trans('QtyRecalculatedWithPackaging'), 'warnings');
}
}
}