Fixed correct calculation of stock_moves standard_cost when producing an Advanced...
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Thu, 15 Oct 2015 08:28:09 +0000 (10:28 +0200)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Thu, 15 Oct 2015 08:28:09 +0000 (10:28 +0200)
manufacturing/includes/db/work_order_produce_items_db.inc
manufacturing/includes/db/work_orders_quick_db.inc

index b37dd23c122fea83d8d3efa844784b425e1e4d23..21dfc3e35984f760e03f8b982044727ddd170802 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);
+               }
+       }
+       $m_cost += get_gl_wo_cost($woid, WO_LABOUR);
+       $m_cost += get_gl_wo_cost($woid, WO_OVERHEAD);
 
        // insert a +ve stock move for the item being manufactured
        // negative means "unproduce" or unassemble
index 63c69475d388955c42ef2bf11e30c397abfd9d10..72b5c8df7e0d873a5b2ed3371df46105f21f66ea 100644 (file)
@@ -225,8 +225,11 @@ function work_order_quick_costs($woid, $stock_id, $units_reqd, $date_, $advanced
         0, 0, $memo, -$total_cost);    
                
        //Chaitanya : Update cost of the manufactured item in stock moves table
-       $UnitWOCost = ($total_material_cost + $costs + $labour)/$units_reqd;
-       update_stock_move(ST_WORKORDER, $woid, $stock_id, $UnitWOCost);         
+       if (!$advanced)
+       {
+               $UnitWOCost = ($total_material_cost + $costs + $labour)/$units_reqd;
+               update_stock_move(ST_WORKORDER, $woid, $stock_id, $UnitWOCost); 
+       }       
 }
 
 //--------------------------------------------------------------------------------------