diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 52c92160bf8..c69bb060fd4 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -745,12 +745,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'); } } } @@ -1011,16 +1011,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 476430fbe5b..1a0fc9b6851 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1722,12 +1722,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'); } } } @@ -3282,14 +3282,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 703e9623f48..2c114684ebe 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -4339,12 +4339,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'); } } } @@ -4705,14 +4705,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 c903080fa74..df899018fda 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2157,10 +2157,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');