Required Delivery Date was not implemented properly.
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Thu, 29 Mar 2012 09:12:19 +0000 (11:12 +0200)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Thu, 29 Mar 2012 09:12:19 +0000 (11:12 +0200)
purchasing/includes/ui/po_ui.inc
sales/includes/ui/sales_order_ui.inc

index ec5ad432683a4dfbb8503c4511739eedfdb1abdb..c91d42fd345ca34ee68ffe35b3834d8db85b6fce 100644 (file)
@@ -358,7 +358,7 @@ function display_po_summary(&$po, $is_self=false, $editable=false)
 
 function po_item_controls(&$order, &$rowcounter, $line_no=-1)
 {
-   global $Ajax;
+   global $Ajax, $SysPrefs;
 
        alt_table_row_color($rowcounter);
 
@@ -415,7 +415,7 @@ function po_item_controls(&$order, &$rowcounter, $line_no=-1)
                //$_POST['price'] = price_format(get_purchase_price ($order->supplier_id, $_POST['stock_id']));
                $_POST['price'] = price_decimal_format(get_purchase_price ($order->supplier_id, $_POST['stock_id']), $dec2);
                if ($order->trans_type == ST_PURCHORDER)
-                       $_POST['req_del_date'] = add_days(Today(), 10);
+                       $_POST['req_del_date'] = add_days(Today(), $SysPrefs->default_delivery_required_by());
                $qty_rcvd = '';
        }
 
index c9e63a1523c6f68a951687a14631c4642901c861..9cb6c363e0a9ffd2c6ffd0432c942f8efb14d002 100644 (file)
@@ -72,6 +72,8 @@ function add_to_order(&$order, $new_item, $new_item_qty, $price, $discount, $des
 
 function get_customer_details_to_order(&$order, $customer_id, $branch_id)
 {
+       global $SysPrefs;
+       
        $ret_error = "";
 
        $myrow = get_customer_to_order($customer_id);
@@ -116,9 +118,11 @@ function get_customer_details_to_order(&$order, $customer_id, $branch_id)
 
        $order->set_delivery($myrow["default_ship_via"], $myrow["br_name"],
                $address);
-       if ($order->trans_type == ST_SALESINVOICE || $order->trans_type == ST_SALESORDER) {
+       if ($order->trans_type == ST_SALESINVOICE) {
                $order->due_date = get_invoice_duedate($order->payment, $order->document_date);
        }
+       elseif ($order->trans_type == ST_SALESORDER)
+               $order->due_date = add_days($order->document_date, $SysPrefs->default_delivery_required_by());
        if($order->payment_terms['cash_sale']) {
                $order->set_location($order->pos["pos_location"], $order->pos["location_name"]);
        } else