From: Joe Hunt Date: Thu, 30 Aug 2018 21:12:52 +0000 (+0200) Subject: Rerun. Update material cost when quantity on hand is zero. @notrinos. X-Git-Url: https://delta.frontaccounting.com/gitweb/?p=fa-stable.git;a=commitdiff_plain;h=b72c2a0476688017a61969cbc35dd7cffb4ed78e Rerun. Update material cost when quantity on hand is zero. @notrinos. --- diff --git a/manufacturing/includes/db/work_order_costing_db.inc b/manufacturing/includes/db/work_order_costing_db.inc index 7671e7ba..7a0bd413 100644 --- a/manufacturing/includes/db/work_order_costing_db.inc +++ b/manufacturing/includes/db/work_order_costing_db.inc @@ -105,9 +105,9 @@ function update_material_cost($stock_id, $qty, $unit_cost, $date) if ($qty > 0 && ($qoh != -$qty)) { if ($qoh == 0 && $avg_cost != 0) - $avg_cost = ($avg_cost + ($unit_cost*$qty_new)/($qoh+$qty))/2; - else - $avg_cost = ($avg_cost*($qoh+$qty_delayed)+$unit_cost*$qty_new)/($qoh+$qty); + $avg_cost = ($avg_cost + ($unit_cost*$qty_new)/$qty)/2; + else + $avg_cost = ($avg_cost*($qoh+$qty_delayed)+$unit_cost*$qty_new)/($qoh+$qty); } $sql = "UPDATE ".TB_PREF."stock_master SET material_cost=".db_escape($avg_cost)."