From: Joe Date: Sun, 16 Apr 2023 08:06:09 +0000 (+0200) Subject: The average material cost test for either qoh > 0 and qoh + qty > 0 has changed to... X-Git-Url: https://delta.frontaccounting.com/gitweb/?p=fa-stable.git;a=commitdiff_plain;h=9a4dbbda763486152d2e98485a7a2a699426141d The average material cost test for either qoh > 0 and qoh + qty > 0 has changed to 0.0000000001 to avoid strange php results for very small values. --- diff --git a/purchasing/includes/db/grn_db.inc b/purchasing/includes/db/grn_db.inc index 6b741489..b12c1028 100644 --- a/purchasing/includes/db/grn_db.inc +++ b/purchasing/includes/db/grn_db.inc @@ -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); }