Unable to void Work Order. Fixed by @kvvaradha.
[fa-stable.git] / manufacturing / includes / db / work_order_produce_items_db.inc
index 44c93b864d0392bf07dc5bca3562e4e70e4caf7b..cdbd81c0a500d1448aac12ca1c70b09923758919 100644 (file)
@@ -81,10 +81,11 @@ function work_order_produce($woid, $ref, $quantity, $date_, $memo, $close_wo)
 
                $unit_cost = $total_cost/($product['units_issued']+$quantity);
 
+               // first update material cost
+               update_material_cost($product['stock_id'], $product['units_issued']+$quantity, $unit_cost, $date_);
+
                add_stock_move(ST_WORKORDER, $product["stock_id"], $woid,
                        $product["loc_code"], $date_, $ref, $product['units_issued']+$quantity, $unit_cost);
-
-               update_material_cost($product['stock_id'], $product['units_issued']+$quantity, $unit_cost, $date_);
        }
 
        if ($memo)
@@ -160,7 +161,7 @@ function void_work_order_produce($type_no)
                return;
 
        // deduct the quantity of this production from the parent work order
-       work_order_update_finished_quantity($prod["workorder_id"], -$prod["quantity"], false);
+       work_order_update_finished_quantity($prod["workorder_id"], -$prod["quantity"]);
 
        // clear the production record
        $sql = "UPDATE ".TB_PREF."wo_manufacture SET quantity=0 WHERE id=".db_escape($type_no);