Merged changes up to 2.3.16 into unstable
[fa-stable.git] / manufacturing / includes / db / work_orders_quick_db.inc
index bcf9688f0ef015e1d5270a564042ed5b91c95664..33350aeb11c2197ff3ae5c2269e23854db729e56 100644 (file)
@@ -67,7 +67,17 @@ function add_work_order_quick($wo_ref, $loc_code, $units_reqd, $stock_id, $type,
 
                // insert a -ve stock move for each item
                add_stock_move(ST_WORKORDER, $bom_item["component"], $woid,
-                       $bom_item["loc_code"], $date_, $wo_ref, -$item_quantity, 0);
+                       $bom_item["loc_code"], $date_, $wo_ref, -$item_quantity, $UnitCost, 0, 1, $UnitCost);
+       }
+       
+       // -------------------------------------------------------------------------
+       //Negative Stock Handling
+       $qoh = get_qoh_on_date($stock_id);
+       $cost_adjust = false;
+       if ($qoh < 0)
+       {
+               if ($qoh + $units_reqd >= 0)
+                       $cost_adjust = true;
        }