mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-14 08:54:21 +01:00
Fix bug on stock calculation for replenishment: wrong order in ifsql.
This commit is contained in:
committed by
Laurent Destailleur
parent
795dcad59f
commit
6d4a9833e2
@@ -176,7 +176,7 @@ $sql = 'SELECT p.rowid, p.ref, p.label, p.price,';
|
||||
$sql.= ' p.price_ttc, p.price_base_type,p.fk_product_type,';
|
||||
$sql.= ' p.tms as datem, p.duration, p.tobuy, p.seuil_stock_alerte,';
|
||||
$sql.= ' p.desiredstock,';
|
||||
$sql.= ' SUM('.$db->ifsql("s.reel IS NULL", "s.reel", "0").') as stock_physique';
|
||||
$sql.= ' SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").') as stock_physique';
|
||||
$sql.= ' FROM ' . MAIN_DB_PREFIX . 'product as p';
|
||||
$sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product_stock as s';
|
||||
$sql.= ' ON p.rowid = s.fk_product';
|
||||
@@ -219,7 +219,7 @@ $sql.= ' HAVING p.desiredstock > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel
|
||||
$sql.= ' AND p.desiredstock > 0';
|
||||
if ($salert == 'on') // Option to see when stock is lower than alert
|
||||
{
|
||||
$sql .= ' AND SUM('.$db->ifsql("s.reel IS NULL", "s.reel", "0").') < p.seuil_stock_alerte AND p.seuil_stock_alerte is not NULL';
|
||||
$sql .= ' AND SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").') < p.seuil_stock_alerte AND p.seuil_stock_alerte is not NULL';
|
||||
$alertchecked = 'checked="checked"';
|
||||
}
|
||||
$sql.= $db->order($sortfield,$sortorder);
|
||||
|
||||
Reference in New Issue
Block a user