From 9a4dbbda763486152d2e98485a7a2a699426141d Mon Sep 17 00:00:00 2001 From: Joe Date: Sun, 16 Apr 2023 10:06:09 +0200 Subject: [PATCH] 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. --- purchasing/includes/db/grn_db.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); } -- 2.30.2