diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 6bcc3a71ebb..cd945513d2b 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -746,12 +746,12 @@ class Propal extends CommonObject $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'); } } } @@ -1013,16 +1013,17 @@ class Propal extends CommonObject } if (getDolGlobalString('PRODUCT_USE_CUSTOMER_PACKAGING')) { - if ($qty < $this->line->packaging) { + if (abs($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'); } } } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 9a3ecaa9aab..920060177fe 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -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'); } } } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index d291eafbfe6..a8d60c16d00 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -4326,12 +4326,12 @@ class Facture extends CommonInvoice $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'); } } } @@ -4693,14 +4693,15 @@ class Facture extends CommonInvoice 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'); } } } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index ce9908469f4..996b043b0e3 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2148,10 +2148,10 @@ 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 ($qty < $prod->packaging) { + if (abs($qty) < $prod->packaging) { $qty = (float) $prod->packaging; } else { - if (!empty($prod->packaging) && (fmod((float) $qty, (float) $prod->packaging) > 0.000001)) { + if (!empty($prod->packaging) && (float) price2num(fmod((float) $qty, (float) $prod->packaging), 'MS')) { $coeff = intval((float) $qty / $prod->packaging) + 1; $qty = (float) $prod->packaging * $coeff; setEventMessages($langs->trans('QtyRecalculatedWithPackaging'), null, 'mesgs');