0000272: Manufacturing Bugs. Issue GL items moved to wo_work_order_issues.inc
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Tue, 26 Oct 2010 11:35:30 +0000 (11:35 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Tue, 26 Oct 2010 11:35:30 +0000 (11:35 +0000)
Layout improvements in work order inquiry and various work order forms

CHANGELOG.txt
manufacturing/includes/db/work_order_issues_db.inc
manufacturing/includes/db/work_order_produce_items_db.inc
manufacturing/includes/db/work_orders_quick_db.inc
manufacturing/search_work_orders.php
manufacturing/work_order_add_finished.php
manufacturing/work_order_costs.php
manufacturing/work_order_issue.php
manufacturing/work_order_release.php

index f967533b4638b4e8d3e60da4824a5fb2e6d59c28..e771d41bd09c1e4cdeb26ab4aea54df129ec704e 100644 (file)
@@ -20,12 +20,24 @@ Legend:
 $ -> Affected files
 
 ------------------------------- Release 2.3 RC3 --------------------------------
+26-Oct-2010 Janusz Dobrowolski
 ! Release 2.3RC3
-25-Oct-2010 Janusz Dobrowolski
 $ version.php
 # Small fix to tabbed_content behaviour.
 $ /includes/ui/ui_controls.inc
 
+26-Oct-2010 Joe Hunt
+# 0000272: Manufacturing Bugs. Issue GL items moved to wo_work_order_issues.inc
+$ /manufacturing/includes/db/work_orders_quick_db.inc
+  /manufacturing/includes/db/work_order_issues_db.inc
+  /manufacturing/includes/db/work_order_produce_items.inc
+! Layout improvements in work order inquiry and various work order forms
+$ /manufacturing/search_work_orders.php
+  /manufacturing/work_order_add_finished.php
+  /manufacturing/work_order_costs.php
+  /manufacturing/work_order_issue.php
+  /manufacturing/work_order_release.php
+  
 22-Oct-2010 Janusz Dobrowolski
 + Added greek installer translation by Kyriakos Tsoukalas
 $ /install/isession.inc
index 2bdffa266b61306c8d0afd7e614ad71a65c0bd1e..b9cb6e55fb8541470a53e63a5939b6358e3ae52b 100644 (file)
@@ -42,6 +42,8 @@ function add_work_order_issue($woid, $ref, $to_work_order, $items, $location, $w
 
        $number = db_insert_id();
 
+       $issue_total = $total_cost = 0;
+
        foreach ($items as $item)
        {
 
@@ -56,7 +58,21 @@ function add_work_order_issue($woid, $ref, $to_work_order, $items, $location, $w
                        VALUES (".db_escape($number).", ".db_escape($item->stock_id).", "
                        .db_escape($item->quantity).")";
                db_query($sql,"A work order issue item could not be added");
-       }
+
+               $standard_cost = get_standard_cost($item->stock_id);
+               $issue_cost = $standard_cost * $item->quantity;
+               $issue = get_stock_gl_code($item->stock_id);
+        $stockitem = get_item($item->stock_id);
+        $total_cost += add_gl_trans_std_cost(ST_WORKORDER, $woid, $date_, $issue["inventory_account"], 0, 0,
+                $date_.": "._("Issue of")." ".$stockitem["description"], -$issue_cost);                        
+               $issue_total += $issue_cost;
+       }       
+       if ($issue_total != 0)
+               add_issue_cost($details['stock_id'], $details['units_reqd'], $date_, $issue_total);
+       $issue = get_stock_gl_code($details['stock_id']);
+    $stockitem = get_item($details['stock_id']);
+    add_gl_trans_std_cost(ST_WORKORDER, $woid, $date_, $issue["inventory_account"],
+        0, 0, $date_.": "._("Issue to")." ".$stockitem["description"], -$total_cost);  
 
        if ($memo_)
                add_comments(ST_MANUISSUE, $number, $date_, $memo_);
index b9fd16f0e9198ad61d94b74a281e21b4aebc84b8..8102c197963b6bdc97e26750cfc5ba09221d6097 100644 (file)
@@ -48,7 +48,7 @@ function work_order_produce($woid, $ref, $quantity, $date_, $memo_, $close_wo)
        // insert a +ve stock move for the item being manufactured
        // negative means "unproduce" or unassemble
        add_stock_move(ST_MANURECEIVE, $details["stock_id"], $id,
-               $details["loc_code"], $date_, $memo_, $quantity, 0);
+               $details["loc_code"], $date_, $ref, $quantity, 0);
        // update wo quantity and close wo if requested
        work_order_update_finished_quantity($woid, $quantity, $close_wo);
 
index 5dfc8635a923b0a2758f0590e79e9e21d060d81b..fe4caa51ba3c43a43bab7eee6d18556eac254ecc 100644 (file)
@@ -100,23 +100,27 @@ function work_order_quick_costs($woid, $stock_id, $units_reqd, $date_, $advanced
                $bom_accounts = get_stock_gl_code($bom_item["component"]);
 
                $bom_cost = $bom_item["ComponentCost"] * $units_reqd;
-
+               
+               $memo = $bom_item["quantity"] ." * ".$bom_item["description"];
                if ($advanced)
                {
+                       $memo = $date_.": ".$memo; 
                        update_wo_requirement_issued($woid, $bom_item['component'], $bom_item["quantity"] * $units_reqd);                       
                        // insert a -ve stock move for each item
                        add_stock_move(ST_MANURECEIVE, $bom_item["component"], $advanced,
                                $bom_item["loc_code"], $date_, "", -$bom_item["quantity"] * $units_reqd, 0);
                }
                $total_cost += add_gl_trans_std_cost(ST_WORKORDER, $woid, $date_, $bom_accounts["inventory_account"], 0, 0,
-                       $bom_item["quantity"] ." * ".$bom_item["description"], -$bom_cost);
+                       $memo, -$bom_cost);
 
        }
        if ($advanced)
        {
+               $wo = get_work_order($woid);
                // also take the additional issues
+               // moved to work_order_issues_db.inc
+               /*
                $res = get_additional_issues($woid);
-               $wo = get_work_order($woid);
                $issue_total = 0;
                while ($item = db_fetch($res))
                {
@@ -125,11 +129,12 @@ function work_order_quick_costs($woid, $stock_id, $units_reqd, $date_, $advanced
                        $issue = get_stock_gl_code($item['stock_id']);
             $stockitem = get_item($item['stock_id']);
             $total_cost += add_gl_trans_std_cost(ST_WORKORDER, $woid, $date_, $issue["inventory_account"], 0, 0,
-                _("Issue of")." ".$stockitem["description"], -$issue_cost);                    
+                $date_.": "._("Issue of")." ".$stockitem["description"], -$issue_cost);                        
                        $issue_total += $issue_cost;
                }
                if ($issue_total != 0)
                        add_issue_cost($stock_id, $units_reqd, $date_, $issue_total);
+               */      
                $lcost = get_gl_wo_cost($woid, WO_LABOUR);
                add_labour_cost($stock_id, $units_reqd, $date_, $lcost * $units_reqd / $wo['units_reqd']);
                $ocost = get_gl_wo_cost($woid, WO_OVERHEAD);
@@ -171,8 +176,11 @@ function work_order_quick_costs($woid, $stock_id, $units_reqd, $date_, $advanced
        }
        // debit total components $total_cost
        $stockitem = get_item($stock_id);
+       $memo = _("Produced")." ".$units_reqd. " * ".$stockitem["description"];
+       if ($advanced)
+               $memo = $date_.": ".$memo;
     add_gl_trans_std_cost(ST_WORKORDER, $woid, $date_, $item_accounts["inventory_account"],
-        0, 0, _("Produced")." ".$units_reqd. " * ".$stockitem["description"], -$total_cost);   
+        0, 0, $memo, -$total_cost);    
 }
 
 //--------------------------------------------------------------------------------------
index 6d52e5f5ff57ba08bd000754a35cb30aa867099c..05892e3ec90cb9cdb78db41f2cf37280422b4c1c 100644 (file)
@@ -143,8 +143,8 @@ function costs_link($row)
 
 function view_gl_link($row)
 {
-       if ($row['closed'] == 0)
-               return '';
+       //if ($row['closed'] == 0)
+       //      return '';
        return get_gl_view_str(ST_WORKORDER, $row['id']);
 }
 
@@ -163,7 +163,7 @@ $cols = array(
        _("Item") => array('fun'=>'view_stock'),
        _("Required") => array('fun'=>'dec_amount', 'align'=>'right'),
        _("Manufactured") => array('fun'=>'dec_amount', 'align'=>'right'),
-       _("Date") => 'date'
+       _("Date") => array('name'=>'date_', 'type'=>'date', 'ord'=>'desc')
        _("Required By") => array('type'=>'date', 'ord'=>''),
        array('insert'=>true, 'fun'=> 'edit_link'),
        array('insert'=>true, 'fun'=> 'release_link'),
index 953e863f7d0fecb5e3631bfdf1e6f703b2cd4808..acf67f73e197ef7e0621795772b40b17426a1893 100644 (file)
@@ -50,6 +50,7 @@ if (isset($_GET['AddedID']))
        display_note(print_link(_("Print the GL Journal Entries for this Work Order"), 702, $ar), 1);
 
        hyperlink_no_params("search_work_orders.php", _("Select another &Work Order to Process"));
+       br();
 
        end_page();
        exit;
@@ -110,7 +111,13 @@ function can_process()
                set_focus('date_');
                return false;
        }
-
+       // don't produce more that required. Otherwise change the Work Order.
+       if (input_num('quantity') > ($wo_details["units_reqd"] - $wo_details["units_issued"]))
+       {
+               display_error(_("The production exceeds the quantity needed. Please change the Work Order."));
+               set_focus('quantity');
+               return false;
+       }
        // if unassembling we need to check the qoh
        if (($_POST['ProductionType'] == 0) && !$SysPrefs->allow_negative_stock())
        {
index 0603dc1559c5f7aa65ea680fa97981912fc5211d..50e7f7feaf9309922c60f650c768439d95775ca0 100644 (file)
@@ -49,6 +49,7 @@ if (isset($_GET['AddedID']))
        hyperlink_params("work_order_costs.php", _("Enter another additional cost."), "trans_no=$id");
  
        hyperlink_no_params("search_work_orders.php", _("Select another &Work Order to Process"));
+       br();
 
        end_page();
        exit;
@@ -103,9 +104,10 @@ function can_process()
 
 if (isset($_POST['process']) && can_process() == true)
 {
+       $date = $_POST['date_'];
        begin_transaction();
        add_gl_trans_std_cost(ST_WORKORDER, $_POST['selected_id'], $_POST['date_'], $_POST['cr_acc'],
-               0, 0, $wo_cost_types[$_POST['PaymentType']], -input_num('costs'), PT_WORKORDER, $_POST['PaymentType']);
+               0, 0, $date.": ".$wo_cost_types[$_POST['PaymentType']], -input_num('costs'), PT_WORKORDER, $_POST['PaymentType']);
        $is_bank_to = is_bank_account($_POST['cr_acc']);
        if ($is_bank_to)
        {
@@ -115,7 +117,7 @@ if (isset($_POST['process']) && can_process() == true)
        }
 
        add_gl_trans_std_cost(ST_WORKORDER, $_POST['selected_id'], $_POST['date_'], $_POST['db_acc'],
-               $_POST['dim1'], $_POST['dim2'], $wo_cost_types[$_POST['PaymentType']], input_num('costs'), PT_WORKORDER, 
+               $_POST['dim1'], $_POST['dim2'], $date.": ".$wo_cost_types[$_POST['PaymentType']], input_num('costs'), PT_WORKORDER, 
                        $_POST['PaymentType']);
        commit_transaction();   
 
index e126bf96b4d0cbe7eb26235dba0aab78b6c826b8..dc2a4380737d304d4c1062768f13907ad6ffe31c 100644 (file)
@@ -32,9 +32,12 @@ page(_($help_context = "Issue Items to Work Order"), false, false, "", $js);
 
 if (isset($_GET['AddedID'])) 
 {
+       $id = $_GET['AddedID'];
        display_notification(_("The work order issue has been entered."));
 
-    display_note(get_trans_view_str(ST_WORKORDER, $_GET['AddedID'], _("View this Work Order")));
+    display_note(get_trans_view_str(ST_WORKORDER, $id, _("View this Work Order")));
+
+       display_note(get_gl_view_str(ST_WORKORDER, $id, _("View the GL Journal Entries for this Work Order")), 1);
 
        hyperlink_no_params("search_work_orders.php", _("Select another &Work Order to Process"));
 
index edacd995bed8565b87362381f265450be3f15aba..0e9273ed3a2c9790bdbdca7f87a91e3bf193e1d5 100644 (file)
@@ -72,6 +72,7 @@ if (isset($_POST['release']))
     display_note(get_trans_view_str(ST_WORKORDER, $selected_id, _("View this Work Order")));
 
        hyperlink_no_params("search_work_orders.php", _("Select another &work order"));
+       br();
 
        $Ajax->activate('_page_body');
        end_page();