Reverted invalid changes in manufacturing accounts back to cogs_account for BOM servi...
[fa-stable.git] / manufacturing / includes / db / work_order_produce_items_db.inc
index b37dd23c122fea83d8d3efa844784b425e1e4d23..d67d2e9048dce7891e853f813b9ed290434c0077 100644 (file)
@@ -53,12 +53,25 @@ function work_order_produce($woid, $ref, $quantity, $date_, $memo_, $close_wo)
 
        // Chaitanya: stamp BOM cost to finished item
        $m_cost = 0;
-    $result = get_bom($details["stock_id"]);
+       $result = get_bom($details["stock_id"]);
        while ($bom_item = db_fetch($result))
        {
                $standard_cost = get_standard_cost($bom_item['component']);
                $m_cost += ($bom_item['quantity'] * $standard_cost);
-       }       
+       }
+       // new Joe Hunt 2015.10.15      
+       // additilnal costs.
+       if (work_order_has_issues($woid))
+       {
+               $res = get_additional_issues($woid);
+               while ($issue = db_fetch($res))
+               {
+                       $standard_cost = get_standard_cost($issue['stock_id']);
+                       $m_cost += ($issue['qty_issued'] * $standard_cost) / $quantity;
+               }
+       }
+       $m_cost += (get_gl_wo_cost($woid, WO_LABOUR) / $quantity);
+       $m_cost += (get_gl_wo_cost($woid, WO_OVERHEAD) / $quantity);
 
        // insert a +ve stock move for the item being manufactured
        // negative means "unproduce" or unassemble
@@ -150,8 +163,7 @@ function void_work_order_produce($type_no)
                if (!is_service($issue["mb_flag"]))
                        $ivaccount = $issue["inventory_account"];
                else
-                       //$ivaccount = $issue["cogs_account"];          
-                       $ivaccount = $issue["assembly_account"]; // changed 2015.10.14 by Petros .              
+                       $ivaccount = $issue["cogs_account"];            
                
                if ($issue_cost != 0)
                {