diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index cd945513d2b..d389d28e39f 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -744,12 +744,12 @@ class Propal extends CommonObject if (getDolGlobalString('PRODUCT_USE_CUSTOMER_PACKAGING')) { $tmpproduct = new Product($this->db); $result = $tmpproduct->fetch($fk_product); - if (abs($qty) < $tmpproduct->packaging) { + if (abs((float) $qty) < $tmpproduct->packaging) { $qty = (float) $tmpproduct->packaging; setEventMessages($langs->trans('QtyRecalculatedWithPackaging'), null, 'warnings'); } else { if (!empty($tmpproduct->packaging) && (float) price2num(fmod((float) $qty, (float) $tmpproduct->packaging), 'MS')) { - $coeff = intval(abs($qty) / $tmpproduct->packaging) + 1; + $coeff = intval(abs((float) $qty) / $tmpproduct->packaging) + 1; $qty = price2num((float) $tmpproduct->packaging * $coeff, 'MS'); setEventMessages($langs->trans('QtyRecalculatedWithPackaging'), null, 'warnings'); } @@ -1013,7 +1013,7 @@ class Propal extends CommonObject } if (getDolGlobalString('PRODUCT_USE_CUSTOMER_PACKAGING')) { - if (abs($qty) < $this->line->packaging) { + if (abs((float) $qty) < $this->line->packaging) { $qty = $this->line->packaging; setEventMessage($langs->trans('QtyRecalculatedWithPackaging'), 'warnings'); } else { @@ -1021,7 +1021,7 @@ class Propal extends CommonObject && is_numeric($this->line->packaging) && (float) $this->line->packaging > 0 && (float) price2num(fmod((float) $qty, (float) $this->line->packaging), 'MS')) { - $coeff = intval($qty / $this->line->packaging) + 1; + $coeff = intval(abs((float) $qty) / $this->line->packaging) + 1; $qty = $this->line->packaging * $coeff; setEventMessage($langs->trans('QtyRecalculatedWithPackaging'), 'warnings'); } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 920060177fe..0ae0014a309 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1717,12 +1717,12 @@ class Commande extends CommonOrder if (getDolGlobalString('PRODUCT_USE_CUSTOMER_PACKAGING')) { $tmpproduct = new Product($this->db); $result = $tmpproduct->fetch($fk_product); - if (abs($qty) < $tmpproduct->packaging) { + if (abs((float) $qty) < $tmpproduct->packaging) { $qty = (float) $tmpproduct->packaging; setEventMessages($langs->trans('QtyRecalculatedWithPackaging'), null, 'warnings'); } else { if (!empty($tmpproduct->packaging) && (float) price2num(fmod((float) $qty, (float) $tmpproduct->packaging), 'MS')) { - $coeff = intval(abs($qty) / $tmpproduct->packaging) + 1; + $coeff = intval(abs((float) $qty) / $tmpproduct->packaging) + 1; $qty = price2num((float) $tmpproduct->packaging * $coeff, 'MS'); setEventMessages($langs->trans('QtyRecalculatedWithPackaging'), null, 'warnings'); } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index a8d60c16d00..2632d97c520 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -4324,12 +4324,12 @@ class Facture extends CommonInvoice if (getDolGlobalString('PRODUCT_USE_CUSTOMER_PACKAGING')) { $tmpproduct = new Product($this->db); $result = $tmpproduct->fetch($fk_product); - if (abs($qty) < $tmpproduct->packaging) { + if (abs((float) $qty) < $tmpproduct->packaging) { $qty = (float) $tmpproduct->packaging; setEventMessages($langs->trans('QtyRecalculatedWithPackaging'), null, 'warnings'); } else { if (!empty($tmpproduct->packaging) && (float) price2num(fmod((float) $qty, (float) $tmpproduct->packaging), 'MS')) { - $coeff = intval(abs($qty) / $tmpproduct->packaging) + 1; + $coeff = intval(abs((float) $qty) / $tmpproduct->packaging) + 1; $qty = price2num((float) $tmpproduct->packaging * $coeff, 'MS'); setEventMessages($langs->trans('QtyRecalculatedWithPackaging'), null, 'warnings'); } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 93a14484318..fa754f358b7 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2149,11 +2149,11 @@ class CommandeFournisseur extends CommonOrder $prod = new Product($this->db); $prod->get_buyprice($fk_prod_fourn_price, (float) $qty, $fk_product, 'none', (empty($this->fk_soc) ? $this->socid : $this->fk_soc)); - if (abs($qty) < $prod->packaging) { + if (abs((float) $qty) < $prod->packaging) { $qty = (float) $prod->packaging; } else { if (!empty($prod->packaging) && (float) price2num(fmod((float) $qty, (float) $prod->packaging), 'MS')) { - $coeff = intval((float) $qty / $prod->packaging) + 1; + $coeff = intval(abs((float) $qty) / $prod->packaging) + 1; $qty = (float) $prod->packaging * $coeff; setEventMessages($langs->trans('QtyRecalculatedWithPackaging'), null, 'mesgs'); }