Merged latest changes from stable branch.
[fa-stable.git] / manufacturing / includes / db / work_orders_db.inc
index e63aae816441fc0e0f7852c7117aee8bb5ef66f0..c9a352e1f9b93408dd460a25527c4d66f1cc25e3 100644 (file)
@@ -173,7 +173,7 @@ function release_work_order($woid, $releaseDate, $memo_)
        create_wo_requirements($woid, $stock_id);
 
        add_comments(ST_WORKORDER, $woid, $releaseDate, $memo_);
-       add_audit_trail(ST_WORKORDER, $woid, $myrow['date_'], _("Released."));
+       add_audit_trail(ST_WORKORDER, $woid, sql2date($myrow['date_']), _("Released."));
 
        commit_transaction();
 }
@@ -252,10 +252,11 @@ function void_work_order($woid)
                        // clear the production record
                        $sql = "UPDATE ".TB_PREF."wo_manufacture SET quantity=0 WHERE id=".$$row['id'];
                        db_query($sql, "Cannot void a wo production");
-                       
+
                        void_stock_move(ST_MANURECEIVE, $row['id']); // and void the stock moves; 
                }
-               $result = get_additional_issues($woid); // check the issued quantities
+
+               $result = get_work_order_issues($woid);
                $cost = 0;
                $issue_no = 0;
                while ($row = db_fetch($result))
@@ -275,10 +276,13 @@ function void_work_order($woid)
                if ($cost != 0)
                        add_issue_cost($work_order['stock_id'], -$qty, $date, $cost);
 
-               $cost = get_gl_wo_cost($woid, WO_LABOUR); // get the labour cost and reduce avg cost
+               //Adust avg labour cost
+               $cost = get_gl_wo_cost($woid, WO_LABOUR); 
                if ($cost != 0)
-                       add_labour_cost($work_order['stock_id'], -$qty, $date, $cost);
-               $cost = get_gl_wo_cost($woid, WO_OVERHEAD); // get the overhead cost and reduce avg cost
+                       add_labour_cost($work_order['stock_id'], 1, $date, -$cost, true);
+                       
+               //Adust avg overhead cost
+               $cost = get_gl_wo_cost($woid, WO_OVERHEAD); 
                if ($cost != 0)
                        add_overhead_cost($work_order['stock_id'], -$qty, $date, $cost);