Rerun. We must also test for availability on document date.
authorJoe <unknown>
Fri, 19 Sep 2014 00:40:34 +0000 (02:40 +0200)
committerJoe <unknown>
Fri, 19 Sep 2014 00:40:34 +0000 (02:40 +0200)
sales/sales_order_entry.php

index a147ea7f5925c71aa0625ebd06f13b9e39ef8ed4..90e768398ddc8d768d7bfb8566978b9589fc79df 100644 (file)
@@ -509,8 +509,10 @@ function check_item_data()
        elseif ($is_inventory_item && $_SESSION['Items']->trans_type!=ST_SALESORDER && $_SESSION['Items']->trans_type!=ST_SALESQUOTE 
                && !$SysPrefs->allow_negative_stock())
        {
-               $qoh = get_qoh_on_date($_POST['stock_id'], $_POST['Location'], null); // Of course we must always test for stock availability by todays date.
-               if (input_num('qty') > $qoh)
+               $qoh = get_qoh_on_date($_POST['stock_id'], $_POST['Location'], $_POST['OrderDate']);
+               $qoh_today = get_qoh_on_date($_POST['stock_id'], $_POST['Location'], null); // Of course we must also test for stock availability by todays date.
+               $qty = input_num('qty');
+               if ($qty > $qoh || $qty > $qoh_today)
                {
                        $stock = get_item($_POST['stock_id']);
                        display_error(_("The delivery cannot be processed because there is an insufficient quantity for item:") .