The average material cost test for either qoh > 0 and qoh + qty > 0 has changed to...
[fa-stable.git] / purchasing / includes / db / grn_db.inc
index 6b74148968899bc197c4728301e461e6c9fd86d4..b12c102809aa0793e0ec6170e0b46236f45d591a 100644 (file)
@@ -51,7 +51,7 @@ function update_average_material_cost($supplier, $stock_id, $price, $qty, $date,
 
        if ($adj_only)
        {
-               if ($qoh > 0)
+               if ($qoh > .0000000001) // avoid very small values 
                        $material_cost = ($qoh * $material_cost + $qty * $price_in_home_currency) /     $qoh;
        }
        else
@@ -62,7 +62,7 @@ function update_average_material_cost($supplier, $stock_id, $price, $qty, $date,
                                $cost_adjust = true;
                        $qoh = 0;
                }
-               if ($qoh + $qty > 0)
+               if ($qoh + $qty > .0000000001) // avoid very small values
                        $material_cost = ($qoh * $material_cost + $qty * $price_in_home_currency) /     ($qoh + $qty);
        }