Bug [0000059] Direct Invoice or Delivery Notes doesn't account for negative inventory...
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Tue, 23 Sep 2008 00:17:38 +0000 (00:17 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Tue, 23 Sep 2008 00:17:38 +0000 (00:17 +0000)
CHANGELOG.txt
sales/sales_order_entry.php

index af677f0b513a9d6add365684f263b5d20865be7a..95765db9b15d46f01038c3cb1880ebb42b8af19c 100644 (file)
@@ -19,6 +19,10 @@ Legend:
 ! -> Note
 $ -> Affected files
 
+23-Sep-2008 Joe Hunt
+# Bug [0000059] Direct Invoice or Delivery Notes doesn't account for negative inventory flag
+$ /sales/sales_order_entry.php
+
 21-Sep-2008 Janusz Dobrowolski
 + Added submit_on_change option for date fields
 $ /includes/ui/ui_input.inc
index 211366261424caa503de8a012d5831e6feeb2aa2..9891d0c5d3d11788877bd3436e5cee5a1f51a4ec 100644 (file)
@@ -291,7 +291,6 @@ if (isset($_POST['ProcessOrder']) && can_process()) {
 
 function check_item_data()
 {
-
        if (!check_num('qty', 0) || !check_num('Disc', 0, 100)) {
                display_error( _("The item could not be updated because you are attempting to set the quantity ordered to less than 0, or the discount percent to more than 100."));
                set_focus('qty');
@@ -306,6 +305,20 @@ function check_item_data()
                set_focus('qty');
                display_error(_("You attempting to make the quantity ordered a quantity less than has already been delivered. The quantity delivered cannot be modified retrospectively."));
                return false;
+       } // Joe Hunt added 2008-09-22 -------------------------
+       elseif ($_SESSION['Items']->trans_type!=30 && !sys_prefs::allow_negative_stock() &&
+               is_inventory_item($_POST['stock_id']))
+       {
+               $qoh = get_qoh_on_date($_POST['stock_id'], $_POST['Location'], $_POST['OrderDate']);
+               if (input_num('qty') > $qoh)
+               {
+                       $stock = get_item($_POST['stock_id']);
+                       display_error(_("The delivery cannot be processed because there is an insufficient quantity for item:") .
+                               " " . $stock['stock_id'] . " - " . $stock['description'] . " - " .
+                               _("Quantity On Hand") . " = " . number_format2($qoh, get_qty_dec($_POST['stock_id'])));
+                       return false;
+               }
+               return true;
        }
        return true;
 }