Inventory Adjustment: removed obsolete increase/descrease selector from entry form...
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Sun, 5 Apr 2015 22:27:10 +0000 (00:27 +0200)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Tue, 7 Apr 2015 19:34:35 +0000 (21:34 +0200)
doc/api_changes.txt
inventory/adjustments.php
inventory/includes/db/items_adjust_db.inc
inventory/includes/item_adjustments_ui.inc

index dca83c273526a7542284b4bd8664c82d961136e8..cab0d50b45517f125df1941fcf83cd3a53a5e639 100644 (file)
@@ -21,7 +21,7 @@ Changed functions:
  items_transfer_db.inc:
        add_stock_transfer($Items, $location_from, $location_to, $date_, $reference, $memo_)
  items_adjust_db.inc:
-    add_stock_adjustment($items, $location, $date_, $increase, $reference, $memo_)
+       add_stock_adjustment($items, $location, $date_, $reference, $memo_)
 
 Before 2.4:
        get_tax_type_default_rate($type_id)
@@ -113,6 +113,6 @@ Description:
 Before 2.4:
        add_stock_adjustment($items, $location, $date_, $type, $increase, $reference, $memo_)
 Now:
-        add_stock_adjustment($items, $location, $date_, $increase, $reference, $memo_)
+       add_stock_adjustment($items, $location, $date_, $reference, $memo_)
 Description:
-       Removed obsolete $type argument.
+       Removed obsolete $type and $increase arguments.
index bacfa377d9c0ffd2666c4e885a089084add3e0c2..9a9a09d1b482de09f5ee9edc18e6eb68163a456e 100644 (file)
@@ -115,7 +115,7 @@ function can_process()
        }
        elseif (!$SysPrefs->allow_negative_stock())
        {
-               $low_stock = $adj->check_qoh($_POST['StockLocation'], $_POST['AdjDate'], !$_POST['Increase']);
+               $low_stock = $adj->check_qoh($_POST['StockLocation'], $_POST['AdjDate']);
 
                if ($low_stock)
                {
@@ -132,8 +132,7 @@ function can_process()
 if (isset($_POST['Process']) && can_process()){
 
        $trans_no = add_stock_adjustment($_SESSION['adj_items']->line_items,
-               $_POST['StockLocation'], $_POST['AdjDate'], $_POST['Increase'],
-               $_POST['ref'], $_POST['memo_']);
+               $_POST['StockLocation'], $_POST['AdjDate'],     $_POST['ref'], $_POST['memo_']);
        new_doc_date($_POST['AdjDate']);
        $_SESSION['adj_items']->clear_items();
        unset($_SESSION['adj_items']);
@@ -146,9 +145,9 @@ if (isset($_POST['Process']) && can_process()){
 
 function check_item_data()
 {
-       if (!check_num('qty',0) || input_num('qty') == 0)
+       if (input_num('qty') == 0)
        {
-               display_error(_("The quantity entered is negative or invalid."));
+               display_error(_("The quantity entered is invalid."));
                set_focus('qty');
                return false;
        }
index ce108d629b6d0812d4a5ebc825c3a85b8ecd5e49..205b782e700f67a58b55a8ccb493cdaa325488aa 100644 (file)
     See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
 ***********************************************************************/
 
-function add_stock_adjustment($items, $location, $date_, $increase, $reference, $memo_)
+function add_stock_adjustment($items, $location, $date_, $reference, $memo_)
 {
        global $SysPrefs, $path_to_root, $Refs;
 
        begin_transaction();
        $args = func_get_args();
-       $args = (object)array_combine(array('items', 'location', 'date_', 'increase',
-               'reference', 'memo_'), $args);
+       $args = (object)array_combine(array('items', 'location', 'date_', 'reference', 'memo_'), $args);
        $args->trans_no = 0;
        hook_db_prewrite($args, ST_INVADJUST);
 
        $adj_id = get_next_trans_no(ST_INVADJUST);
 
-       if ($SysPrefs->loc_notification() == 1 && !$increase)
+       if ($SysPrefs->loc_notification() == 1)
        {
                include_once($path_to_root . "/inventory/includes/inventory_db.inc");
                $st_ids = array();
@@ -34,11 +33,11 @@ function add_stock_adjustment($items, $location, $date_, $increase, $reference,
        foreach ($items as $line_item)
        {
 
-               if ($SysPrefs->loc_notification() == 1 && !$increase)
+               if ($SysPrefs->loc_notification() == 1 && $line_item->qty < 0)
+               {
+                       $chg = $line; $chg->qty = -$chg->qty;   // calculate_reorder_level expect positive qty
                        $loc = calculate_reorder_level($location, $line_item, $st_ids, $st_names, $st_num, $st_reorder); 
-
-               if (!$increase)
-                       $line_item->quantity = -$line_item->quantity;
+               }
 
                add_stock_adjustment_item($adj_id, $line_item->stock_id, $location, $date_, $reference,
                        $line_item->quantity, $line_item->standard_cost, $memo_);
@@ -52,7 +51,7 @@ function add_stock_adjustment($items, $location, $date_, $increase, $reference,
        $args->trans_no = $adj_id;
        hook_db_postwrite($args, ST_INVADJUST);
        commit_transaction();
-       if ($SysPrefs->loc_notification() == 1 && !$increase && count($st_ids) > 0)
+       if ($SysPrefs->loc_notification() == 1 && count($st_ids) > 0)
                send_reorder_email($loc, $st_ids, $st_names, $st_num, $st_reorder);
 
        return $adj_id;
index bed25415d792eb190a52257fb787cef5cdbcd4cb..eb2f03d26da770968c5253d27758e7c6141fdedb 100644 (file)
@@ -37,11 +37,6 @@ function display_order_header(&$order)
        table_section(2, "50%");
        ref_row(_("Reference:"), 'ref', '', $Refs->get_next(ST_INVADJUST));
 
-    if (!isset($_POST['Increase']))
-       $_POST['Increase'] = 1;
-    yesno_list_row(_("Type:"), 'Increase', $_POST['Increase'],
-       _("Positive Adjustment"), _("Negative Adjustment"));
-
        end_outer_table(1); // outer table
 }
 
@@ -62,7 +57,7 @@ function display_adjustment_items($title, &$order)
        $total = 0;
        $k = 0;  //row colour counter
 
-       $low_stock = $order->check_qoh($_POST['StockLocation'], $_POST['AdjDate'], !$_POST['Increase']);
+       $low_stock = $order->check_qoh($_POST['StockLocation'], $_POST['AdjDate']);
        $id = find_submit('Edit');
        foreach ($order->line_items as $line_no=>$stock_item)
        {