Rerun of Update Material Cost Function. $notrinos.
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Fri, 11 Jan 2019 07:29:58 +0000 (08:29 +0100)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Fri, 11 Jan 2019 07:29:58 +0000 (08:29 +0100)
manufacturing/includes/db/work_order_costing_db.inc

index 48cb7f3b2d811fdc18c478f26c5dc5f57801920e..5d39a8a9ea3bb8630676f6cafefe703b0ba5ff2d 100644 (file)
@@ -103,12 +103,8 @@ function update_material_cost($stock_id, $qty, $unit_cost, $date)
                write_journal_entries($cart);
        }
 
-       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);
-       }
+       if ($qty > 0 && ($qoh != -$qty))
+        $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)."
                    WHERE stock_id=".db_escape($stock_id);